Skip to content

Commit 2b62858

Browse files
authored
Write documentation (#152)
1 parent 5bad7e8 commit 2b62858

13 files changed

Lines changed: 697 additions & 84 deletions

README.md

Lines changed: 56 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
11
<p align="center">
2-
32
<img width="75%" src="https://github.com/user-attachments/assets/6d6a41e7-fbc1-43ec-bda6-15f9ff4bd25c" />
4-
5-
63
</p>
74

85
`trackio` is a lightweight, free experiment tracking Python library built on top of Hugging Face Datasets and Spaces 🤗.
96

10-
117
![Screen Recording 2025-07-28 at 5 26 32 PM](https://github.com/user-attachments/assets/f3eac49e-d8ee-4fc0-b1ca-aedfc6d6fae1)
128

9+
- **API compatible** with `wandb.init`, `wandb.log`, and `wandb.finish`. Drop-in replacement: just
1310

14-
- **API compatible** with `wandb.init`, `wandb.log`, and `wandb.finish` (drop-in replacement: just `import trackio as wandb`)
15-
- *Local-first* design: dashboard runs locally by default. You can also host it on Spaces by specifying a `space_id`.
11+
```python
12+
import trackio as wandb
13+
```
14+
15+
- **Local-first** design: dashboard runs locally by default. You can also host it on Spaces by specifying a `space_id`.
1616
- Persists logs locally (or in a private Hugging Face Dataset)
1717
- Visualize experiments with a Gradio dashboard locally (or on Hugging Face Spaces)
18-
- Everything here, including hosting on Hugging Faces, is **free**!
19-
20-
Trackio is designed to be lightweight (the core codebase is <1,000 lines of Python code), not fully-featured. It is designed in an extensible way and written entirely in Python so that developers can easily fork the repository and add functionality that they care about.
18+
- Everything here, including hosting on Hugging Face, is **free**!
2119

20+
Trackio is designed to be lightweight (the core codebase is <3,000 lines of Python code), not fully-featured. It is designed in an extensible way and written entirely in Python so that developers can easily fork the repository and add functionality that they care about.
2221

2322
## Installation
2423

@@ -36,48 +35,51 @@ uv pip install trackio
3635

3736
## Usage
3837

39-
The usage of `trackio` is designed to be a identical to `wandb` in most cases:
38+
To get started, you can run a simple example that logs some fake training metrics:
4039

4140
```python
42-
import trackio as wandb
41+
import trackio
4342
import random
4443
import time
4544

4645
runs = 3
4746
epochs = 8
4847

49-
def simulate_multiple_runs():
50-
for run in range(runs):
51-
wandb.init(project="fake-training", config={
52-
"epochs": epochs,
53-
"learning_rate": 0.001,
54-
"batch_size": 64
48+
49+
for run in range(runs):
50+
trackio.init(
51+
project="my-project",
52+
config={"epochs": epochs, "learning_rate": 0.001, "batch_size": 64}
53+
)
54+
55+
for epoch in range(epochs):
56+
train_loss = random.uniform(0.2, 1.0)
57+
train_acc = random.uniform(0.6, 0.95)
58+
59+
val_loss = train_loss - random.uniform(0.01, 0.1)
60+
val_acc = train_acc + random.uniform(0.01, 0.05)
61+
62+
trackio.log({
63+
"epoch": epoch,
64+
"train_loss": train_loss,
65+
"train_accuracy": train_acc,
66+
"val_loss": val_loss,
67+
"val_accuracy": val_acc
5568
})
56-
57-
for epoch in range(epochs):
58-
train_loss = random.uniform(0.2, 1.0)
59-
train_acc = random.uniform(0.6, 0.95)
60-
61-
val_loss = train_loss - random.uniform(0.01, 0.1)
62-
val_acc = train_acc + random.uniform(0.01, 0.05)
63-
64-
wandb.log({
65-
"epoch": epoch,
66-
"train_loss": train_loss,
67-
"train_accuracy": train_acc,
68-
"val_loss": val_loss,
69-
"val_accuracy": val_acc
70-
})
71-
72-
time.sleep(0.2)
73-
74-
wandb.finish()
75-
76-
simulate_multiple_runs()
69+
70+
time.sleep(0.2)
71+
72+
trackio.finish()
7773
```
7874

7975
Running the above will print to the terminal instructions on launching the dashboard.
8076

77+
The usage of `trackio` is designed to be a identical to `wandb` in most cases, so you can easily switch between the two libraries.
78+
79+
```py
80+
import trackio as wandb
81+
```
82+
8183
## Dashboard
8284

8385
You can launch the dashboard by running in your terminal:
@@ -97,30 +99,32 @@ trackio.show()
9799
You can also provide an optional `project` name as the argument to load a specific project directly:
98100

99101
```bash
100-
trackio show --project "my project"
102+
trackio show --project "my-project"
101103
```
102104

103105
or, in Python:
104106

105107
```py
106108
import trackio
107109

108-
trackio.show(project="my project")
110+
trackio.show(project="my-project")
109111
```
110112

111113
## Deploying to Hugging Face Spaces
112114

113-
When calling `trackio.init()`, by default the service will run locally and store project data on the local machine.
115+
When calling `trackio.init()`, by default the service will run locally and store project data on the local machine.
114116

115117
But if you pass a `space_id` to `init`, like:
116118

117119
```py
118-
trackio.init(project="fake-training", space_id="org_name/space_name")
119-
```
120-
or
120+
trackio.init(project="my-project", space_id="orgname/space_id")
121+
```
122+
123+
or
124+
121125
```py
122-
trackio.init(project="fake-training", space_id="user_name/space_name")
123-
```
126+
trackio.init(project="my-project", space_id="username/space_id")
127+
```
124128

125129
it will use an existing or automatically deploy a new Hugging Face Space as needed. You should be logged in with the `huggingface-cli` locally and your token should have write permissions to create the Space.
126130

@@ -130,11 +134,10 @@ One of the reasons we created `trackio` was to make it easy to embed live dashbo
130134

131135
![image](https://github.com/user-attachments/assets/77f1424b-737b-4f04-b828-a12b2c1af4ef)
132136

133-
134137
If you are hosting your Trackio dashboard on Spaces, then you can embed the url of that Space as an IFrame. You can even use query parameters to only specific projects and/or metrics, e.g.
135138

136139
```html
137-
<iframe src="https://abidlabs-trackio-1234.hf.space/?project=fake-training&metrics=train_loss,train_accuracy&sidebar=hidden" width=1600 height=500 frameBorder="0">
140+
<iframe src="https://abidlabs-trackio-1234.hf.space/?project=my-project&metrics=train_loss,train_accuracy&sidebar=hidden" width=1600 height=500 frameBorder="0">
138141
```
139142

140143
Supported query parameters:
@@ -146,9 +149,10 @@ Supported query parameters:
146149
## Examples
147150

148151
To get started and see basic examples of usage, see these files:
149-
* [Basic example of logging metrics locally](https://github.com/gradio-app/trackio/blob/main/examples/fake-training.py)
150-
* [Persisting metrics in a Hugging Face Dataset](https://github.com/gradio-app/trackio/blob/main/examples/persist-dataset.py)
151-
* [Deploying the dashboard to Spaces](https://github.com/gradio-app/trackio/blob/main/examples/deploy-on-spaces.py)
152+
153+
- [Basic example of logging metrics locally](https://github.com/gradio-app/trackio/blob/main/examples/fake-training.py)
154+
- [Persisting metrics in a Hugging Face Dataset](https://github.com/gradio-app/trackio/blob/main/examples/persist-dataset.py)
155+
- [Deploying the dashboard to Spaces](https://github.com/gradio-app/trackio/blob/main/examples/deploy-on-spaces.py)
152156

153157
## Note: Trackio is in Beta (DB Schema May Change)
154158

@@ -158,7 +162,7 @@ Since Trackio is in beta, your feedback is welcome! Please create issues with bu
158162

159163
## License
160164

161-
MIT License
165+
MIT License
162166

163167
## Pronunciation
164168

docs/source/_toctree.yml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
11
- sections:
22
- local: index
3-
title: Trackio
3+
title: Trackio
4+
- local: installation
5+
title: Installation
6+
- local: quickstart
7+
title: Quickstart
8+
title: Getting started
9+
- sections:
10+
- local: track
11+
title: Track
12+
- local: launch
13+
title: Launch the Dashboard
14+
- local: deploy_embed
15+
title: Deploy and Embed Dashboards
16+
- local: manage
17+
title: Manage Projects
18+
title: How-to guides
19+
- sections:
20+
- local: transformers_integration
21+
title: Transformers Trainer
22+
title: Integration
23+
- sections:
24+
- local: api
25+
title: API Reference
26+
title: API

docs/source/api.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# API Reference
2+
3+
## Run
4+
5+
[[autodoc]] Run
6+
7+
## init
8+
9+
[[autodoc]] init
10+
11+
## log
12+
13+
[[autodoc]] log
14+
15+
## finish
16+
17+
[[autodoc]] finish
18+
19+
## show
20+
21+
[[autodoc]] show
22+
23+
## import_csv
24+
25+
[[autodoc]] import_csv
26+
27+
## import_tf_events
28+
29+
[[autodoc]] import_tf_events

docs/source/deploy_embed.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Deploying and Embedding Dashboards
2+
3+
## Deploying to Hugging Face Spaces
4+
5+
When calling [`init`], by default the service will run locally and store project data on the local machine.
6+
7+
But if you pass a `space_id` to [`init`], like:
8+
9+
```py
10+
trackio.init(project="my-project", space_id="orgname/space_id")
11+
```
12+
13+
or
14+
15+
```py
16+
trackio.init(project="my-project", space_id="username/space_id")
17+
```
18+
19+
it will use an existing or automatically deploy a new Hugging Face Space as needed. You should be logged in with the `huggingface-cli` locally and your token should have write permissions to create the Space.
20+
21+
## Embedding a Trackio Dashboard
22+
23+
One of the reasons we created `trackio` was to make it easy to embed live dashboards on websites, blog posts, or anywhere else you can embed a website.
24+
25+
![image](https://github.com/user-attachments/assets/77f1424b-737b-4f04-b828-a12b2c1af4ef)
26+
27+
If your Trackio dashboard is hosted on Spaces, you can embed it anywhere using an `<iframe>`:
28+
29+
```html
30+
<iframe src="https://username-space_id.hf.space"></iframe>
31+
```
32+
33+
You can also filter the dashboard to display only specific projects or metrics using query parameters. Supported parameters include:
34+
35+
* `project` (string): Show only a specific project.
36+
* `metrics` (comma-separated list): Show only specific metrics, e.g., `train_loss,train_accuracy`.
37+
* `sidebar` (string, `"hidden"` or `"collapsed"`):
38+
39+
* `"hidden"` hides the sidebar completely.
40+
* `"collapsed"` keeps the sidebar initially collapsed, but the user can expand it. By default, the sidebar is visible and open.
41+
42+
You can customize your `<iframe>` using standard attributes such as `width`, `height`, and `style`. For more details, see [MDN Web Docs: `<iframe>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/iframe). For example:
43+
44+
```html
45+
<iframe
46+
src="https://trackio-documentation.hf.space/?project=my-project&metrics=train_loss,train_accuracy&sidebar=hidden"
47+
width="600"
48+
height="630"
49+
style="border:0;">
50+
</iframe>
51+
```
52+
53+
<iframe
54+
src="https://trackio-documentation.hf.space/?project=my-project&metrics=train_loss,train_accuracy&sidebar=hidden"
55+
width="600"
56+
height="630"
57+
style="border:0;">
58+
</iframe>

docs/source/index.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,22 @@
11
# Trackio
2+
3+
<p align="center">
4+
<img width="75%" src="https://github.com/user-attachments/assets/6d6a41e7-fbc1-43ec-bda6-15f9ff4bd25c" />
5+
</p>
6+
7+
`trackio` is a lightweight, free experiment tracking Python library built on top of Hugging Face Datasets and Spaces 🤗.
8+
9+
![Screen Recording 2025-07-28 at 5 26 32 PM](https://github.com/user-attachments/assets/f3eac49e-d8ee-4fc0-b1ca-aedfc6d6fae1)
10+
11+
- **API compatible** with `wandb.init`, `wandb.log`, and `wandb.finish`. Drop-in replacement: just
12+
13+
```python
14+
import trackio as wandb
15+
```
16+
17+
- **Local-first** design: dashboard runs locally by default. You can also host it on Spaces by specifying a `space_id`.
18+
- Persists logs locally (or in a private Hugging Face Dataset)
19+
- Visualize experiments with a Gradio dashboard locally (or on Hugging Face Spaces)
20+
- Everything here, including hosting on Hugging Face, is **free**!
21+
22+
Trackio is designed to be lightweight (the core codebase is <3,000 lines of Python code), not fully-featured. It is designed in an extensible way and written entirely in Python so that developers can easily fork the repository and add functionality that they care about.

0 commit comments

Comments
 (0)