|
| 1 | +# Migrating to Trackio |
| 2 | + |
| 3 | +It's easy to migrate to Trackio from other experiment tracking libraries with minimal code changes. This guide shows you how to migrate from popular experiment tracking tools. |
| 4 | + |
| 5 | +## Weights & Biases (`wandb`) |
| 6 | + |
| 7 | +Migrating from Weights & Biases to Trackio is extremely easy because **Trackio uses the exact same API syntax as wandb**. In most cases, you only need to change the import statement! |
| 8 | + |
| 9 | +### Simple Migration |
| 10 | + |
| 11 | +The most basic migration requires just changing your import: |
| 12 | + |
| 13 | +```diff |
| 14 | +- import wandb |
| 15 | ++ import trackio as wandb |
| 16 | + |
| 17 | +wandb.init(project="my-project") |
| 18 | +wandb.log({"loss": 0.5, "accuracy": 0.8}) |
| 19 | +wandb.finish() |
| 20 | +``` |
| 21 | + |
| 22 | +### Complete Example |
| 23 | + |
| 24 | +Here's a more complete example showing how the rest of your code stays exactly the same! |
| 25 | + |
| 26 | + |
| 27 | +```diff |
| 28 | +- import wandb |
| 29 | ++ import trackio as wandb |
| 30 | +import numpy as np |
| 31 | + |
| 32 | +wandb.init( |
| 33 | + project="image-classification", |
| 34 | + name="experiment-1", |
| 35 | + config={ |
| 36 | + "learning_rate": 0.01, |
| 37 | + "batch_size": 32, |
| 38 | + "epochs": 10 |
| 39 | + } |
| 40 | +) |
| 41 | + |
| 42 | +for epoch in range(10): |
| 43 | + loss = np.random.random() |
| 44 | + accuracy = np.random.random() |
| 45 | + |
| 46 | + wandb.log({ |
| 47 | + "epoch": epoch, |
| 48 | + "loss": loss, |
| 49 | + "accuracy": accuracy, |
| 50 | + "learning_rate": wandb.config.learning_rate |
| 51 | + }) |
| 52 | + |
| 53 | +wandb.finish() |
| 54 | +``` |
| 55 | + |
| 56 | +### Advanced Features |
| 57 | + |
| 58 | +Trackio supports logging Tables, Images, Audio, etc. - same API as wandb: |
| 59 | + |
| 60 | +```diff |
| 61 | +- import wandb |
| 62 | ++ import trackio as wandb |
| 63 | +import numpy as np |
| 64 | + |
| 65 | +wandb.init(project="data-analysis") |
| 66 | + |
| 67 | +image_array = np.random.randint(0, 255, (100, 100, 3), dtype=np.uint8) |
| 68 | +wandb.log({ |
| 69 | + "sample_image": wandb.Image(image_array, caption="Generated sample"), |
| 70 | + "model_diagram": wandb.Image("architecture.png") |
| 71 | +}) |
| 72 | + |
| 73 | +columns = ["epoch", "train_loss", "val_loss", "accuracy"] |
| 74 | +data = [ |
| 75 | + [1, 0.8, 0.6, 0.75], |
| 76 | + [2, 0.6, 0.5, 0.82], |
| 77 | + [3, 0.4, 0.45, 0.89] |
| 78 | +] |
| 79 | +table = wandb.Table(data=data, columns=columns) |
| 80 | +wandb.log({"training_results": table}) |
| 81 | + |
| 82 | +wandb.finish() |
| 83 | +``` |
| 84 | + |
| 85 | + |
| 86 | +## Neptune (`neptune`) |
| 87 | + |
| 88 | +Migrating from Neptune requires a few more changes since Neptune has a different API structure, but the migration is still straightforward. |
| 89 | + |
| 90 | +### Basic Logging Migration |
| 91 | + |
| 92 | +```diff |
| 93 | +- import neptune |
| 94 | + |
| 95 | ++ import trackio |
| 96 | + |
| 97 | +- run = neptune.init_run( |
| 98 | +- project="my-workspace/my-project", |
| 99 | +- api_token="your-token" |
| 100 | +- ) |
| 101 | + |
| 102 | ++ trackio.init(project="my-project") |
| 103 | + |
| 104 | +- run["parameters"] = {"learning_rate": 0.01, "batch_size": 32} |
| 105 | +- run["metrics/loss"].log(0.5) |
| 106 | +- run["metrics/accuracy"].log(0.8) |
| 107 | + |
| 108 | ++ trackio.config.update({"learning_rate": 0.01, "batch_size": 32}) |
| 109 | ++ trackio.log({"loss": 0.5, "accuracy": 0.8}) |
| 110 | + |
| 111 | +- run.stop() |
| 112 | + |
| 113 | ++ trackio.finish() |
| 114 | +``` |
| 115 | + |
| 116 | +### Complete Training Loop Migration |
| 117 | + |
| 118 | +```diff |
| 119 | +- import neptune |
| 120 | ++ import trackio |
| 121 | +import numpy as np |
| 122 | + |
| 123 | +- run = neptune.init_run( |
| 124 | +- project="my-workspace/classification-project", |
| 125 | +- name="experiment-1", |
| 126 | +- tags=["pytorch", "cnn"] |
| 127 | +- ) |
| 128 | + |
| 129 | ++ trackio.init( |
| 130 | ++ project="classification-project", |
| 131 | ++ name="experiment-1", |
| 132 | ++ tags=["pytorch", "cnn"] |
| 133 | ++ ) |
| 134 | + |
| 135 | +config = {"learning_rate": 0.01, "epochs": 10, "batch_size": 32} |
| 136 | + |
| 137 | +- run["parameters"] = config |
| 138 | ++ trackio.config.update(config) |
| 139 | + |
| 140 | +for epoch in range(config["epochs"]): |
| 141 | + # Simulate training |
| 142 | + train_loss = np.random.random() |
| 143 | + val_accuracy = np.random.random() |
| 144 | + |
| 145 | + # Neptune logging |
| 146 | +- run["metrics/train/loss"].log(train_loss) |
| 147 | +- run["metrics/val/accuracy"].log(val_accuracy) |
| 148 | +- run["metrics/epoch"].log(epoch) |
| 149 | + |
| 150 | + # Trackio logging |
| 151 | ++ trackio.log({ |
| 152 | ++ "train/loss": train_loss, |
| 153 | ++ "val/accuracy": val_accuracy, |
| 154 | ++ "epoch": epoch |
| 155 | ++ }) |
| 156 | + |
| 157 | +- run["model/weights"].upload("model.pth") |
| 158 | ++ trackio.save("model.pth") |
| 159 | + |
| 160 | +- run.stop() |
| 161 | ++ trackio.finish() |
| 162 | +``` |
| 163 | + |
| 164 | +### Key Migration Points |
| 165 | + |
| 166 | +1. **Initialization**: Replace `neptune.init_run()` with `trackio.init()` |
| 167 | +2. **Logging**: Use `trackio.log()` with dictionaries instead of individual metric assignments |
| 168 | +3. **Cleanup**: Replace `run.stop()` with `trackio.finish()` |
| 169 | + |
| 170 | +## Benefits to Migrating |
| 171 | + |
| 172 | +- **Simpler API**: Flat dictionary logging vs nested attribute access |
| 173 | +- **Local development**: Work offline by default |
| 174 | +- **Free hosting**: Deploy dashboards on Hugging Face Spaces at no cost |
| 175 | +- **Familiar interface**: If you've used `wandb` before in particular, the API is unchanged |
0 commit comments