Skip to content

Commit 4520576

Browse files
authored
Update Trainer API usage to remove environment variable (#406)
1 parent 39c4750 commit 4520576

2 files changed

Lines changed: 11 additions & 19 deletions

File tree

docs/source/transformers_integration.md

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,34 +14,29 @@ dataset = Dataset.from_dict({"input_ids": data, "labels": data})
1414
# Train a model using the Trainer API
1515
trainer = Trainer(
1616
model=AutoModelForCausalLM.from_pretrained("Qwen/Qwen3-0.6B"),
17-
args=TrainingArguments(run_name="Qwen3-0.6B-training", report_to="trackio"),
17+
args=TrainingArguments(report_to="trackio", run_name="Qwen3-0.6B-training"),
1818
train_dataset=dataset,
1919
)
2020
trainer.train()
2121
```
2222

2323
## Configuring Project and Space
2424

25-
You can specify your Trackio project name and space ID using environment variables:
26-
27-
```sh
28-
export TRACKIO_PROJECT_NAME="my-project"
29-
export TRACKIO_SPACE_ID="username/space_id"
30-
```
31-
32-
Or set them directly in Python:
25+
Set the project and space ID directly in your [`~transformers.TrainingArguments`]:
3326

3427
```python
35-
import os
28+
from transformers import TrainingArguments
3629

37-
os.environ["TRACKIO_PROJECT_NAME"] = "my-project"
38-
os.environ["TRACKIO_SPACE_ID"] = "username/space_id"
39-
40-
# rest of your code...
30+
args = TrainingArguments(
31+
report_to="trackio",
32+
run_name="my-run",
33+
project="my-project",
34+
trackio_space_id="username/space_id",
35+
)
4136
```
4237

4338
<iframe
4439
src="https://trackio-documentation.hf.space/?project=transformers-integration&sidebar=hidden"
4540
style="width: 100%; border:0;"
4641
height="1530">
47-
</iframe>
42+
</iframe>

examples/transformers-integration.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
# ]
88
# ///
99

10-
import os
11-
1210
import huggingface_hub
1311
from datasets import Dataset
1412
from transformers import (
@@ -31,8 +29,6 @@
3129
username = huggingface_hub.whoami()["name"]
3230
hub_model_id = f"{username}/trackio-transformers-demo"
3331

34-
os.environ["TRACKIO_PROJECT"] = "trackio-transformers-demo"
35-
3632
trainer = Trainer(
3733
model=model,
3834
args=TrainingArguments(
@@ -42,6 +38,7 @@
4238
learning_rate=2e-5,
4339
logging_steps=1,
4440
report_to="trackio",
41+
project="trackio-transformers-demo",
4542
push_to_hub=bool(hub_model_id),
4643
hub_model_id=hub_model_id,
4744
),

0 commit comments

Comments
 (0)