Spaces:
				
			
			
	
			
			
					
		Running
		
	
	
	
			
			
	
	
	
	
		
		
					
		Running
		
	File size: 3,344 Bytes
			
			987a674  | 
								1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92  | 
								#!/usr/bin/env python3
"""
Add demo training data to an existing experiment
This will populate the experiment with realistic training metrics for visualization
"""
import json
import logging
import numpy as np
from datetime import datetime
from trackio_api_client import TrackioAPIClient
# Setup logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
def add_demo_training_data(experiment_id: str, num_steps: int = 50):
    """Add realistic demo training data to an experiment"""
    
    client = TrackioAPIClient("https://tonic-test-trackio-test.hf.space")
    
    print(f"π― Adding demo training data to experiment: {experiment_id}")
    print(f"π Will add {num_steps} metric entries...")
    
    # Simulate realistic training metrics
    for step in range(0, num_steps * 25, 25):  # Every 25 steps
        # Simulate loss decreasing over time with some noise
        base_loss = 2.0 * np.exp(-step / 500)
        noise = 0.1 * np.random.random()
        loss = max(0.1, base_loss + noise)
        
        # Simulate accuracy increasing over time
        base_accuracy = 0.3 + 0.6 * (1 - np.exp(-step / 300))
        accuracy = min(0.95, base_accuracy + 0.05 * np.random.random())
        
        # Simulate learning rate decay
        lr = 3.5e-6 * (0.9 ** (step // 200))
        
        # Simulate GPU memory usage
        gpu_memory = 20 + 5 * np.random.random()
        
        # Simulate training time per step
        training_time = 0.5 + 0.2 * np.random.random()
        
        metrics = {
            "loss": round(loss, 4),
            "accuracy": round(accuracy, 4),
            "learning_rate": round(lr, 8),
            "gpu_memory_gb": round(gpu_memory, 2),
            "training_time_per_step": round(training_time, 3),
            "epoch": step // 100 + 1,
            "samples_per_second": round(50 + 20 * np.random.random(), 1)
        }
        
        # Log metrics to the experiment
        result = client.log_metrics(experiment_id, metrics, step)
        
        if "success" in result:
            print(f"β
 Step {step}: Loss={loss:.4f}, Accuracy={accuracy:.4f}")
        else:
            print(f"β Step {step}: Failed to log metrics - {result}")
    
    print(f"\nπ Demo data added successfully!")
    print(f"π Total steps logged: {num_steps}")
    print(f"π View in Trackio Space: https://tonic-test-trackio-test.hf.space")
    print(f"π Go to 'Visualizations' tab and select experiment: {experiment_id}")
def main():
    """Main function"""
    print("π Trackio Demo Data Generator")
    print("=" * 50)
    
    # Your experiment ID from the logs
    experiment_id = "exp_20250720_101955"  # petit-elle-l-aime-3-balanced
    
    print(f"π Target experiment: {experiment_id}")
    print(f"π Experiment name: petit-elle-l-aime-3-balanced")
    
    # Add demo data
    add_demo_training_data(experiment_id, num_steps=50)
    
    print("\n" + "=" * 50)
    print("π― Next Steps:")
    print("1. Go to https://tonic-test-trackio-test.hf.space")
    print("2. Click on 'π Visualizations' tab")
    print("3. Enter your experiment ID: exp_20250720_101955")
    print("4. Select a metric (loss, accuracy, etc.)")
    print("5. Click 'Create Plot' to see the training curves!")
    print("=" * 50)
if __name__ == "__main__":
    main()  |