Skip to main content

Transformer Lab SDK

The Transformer Lab Python SDK provides a way for ML scripts to integrate with Transformer Lab.

Install

pip install transformerlab-internal

Usage

from lab import lab

# Initialize with experiment ID
lab.init("my-experiment")
lab.log("Job initiated")

config_artifact_path = lab.save_artifact(<config_file>, "training_config.json")
lab.log(f"Saved training config: {config_artifact_path}")
lab.update_progress(1)

...
lab.update_progress(99)

model_path = lab.save_model(<training_output_dir>, name="trained_model")
lab.log("Saved model file to {model_path}")

lab.finish("Training completed successfully")

Shared storage

Each user has a personal area of the team workspace for large files reused across experiments and jobs — a base model, a tokenized corpus, a reference checkpoint. Upload once from the terminal with lab storage upload, then read it from any job:

from lab import lab

corpus = lab.storage_download("tokenized-corpus")                 # directory → local dir
weights = lab.storage_download("models/base-model.safetensors")   # file → local path

for entry in lab.storage_list("models"):
    print(entry["relpath"], entry["size"])

lab.storage_upload("./derived-index.faiss", "indexes/wiki.faiss")

Downloads land in an on-node cache by default (pass dest= to choose a location) and read straight from object storage, so a multi-GB file moves at full bandwidth without routing through the API server. A local copy whose size already matches is reused, so re-running a job does not re-fetch it; pass force=True to override.

Every path is relative to your own storage root. Async variants exist for all three (async_storage_download, async_storage_upload, async_storage_list).

Reporting metrics

Pass a dict of named metrics to lab.finish(score=...). The dict shape is required — metrics are stored under job_data.score and surfaced by lab job list (Score column) and lab job info, and read by sweep / autoresearch flows for optimization.

lab.finish(message="Done!")                              # success, no score
lab.finish(message="Done!", score={"accuracy": 0.78})    # success with one metric
lab.finish(score={"accuracy": 0.78, "f1": 0.83})         # multiple metrics

Do not pass a scalar (e.g. lab.finish(score=0.78)) — wrap it in a dict instead: lab.finish(score={"score": 0.78}).

Sample scripts can be found at https://github.com/transformerlab/transformerlab-platform/tree/main/lab-sdk/scripts/examples

Development

The code for this can be found in the lab-sdk directory of https://github.com/transformerlab/transformerlab-platform

To develop locally in editable mode and run automated tests:

cd lab-sdk
uv venv
uv pip install -e .
uv run pytest  # Run tests

Release files for transformerlab-internal 0.1.51

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for transformerlab-internal 0.1.51
File Size Uploaded
transformerlab_internal-0.1.51.tar.gz 131.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for transformerlab-internal 0.1.51
File Interpreter ABI Platform
transformerlab_internal-0.1.51-py3-none-any.whl Python 3 none any Details

Total release size: 238.5 kB

Release files / transformerlab_internal-0.1.51.tar.gz

Download URL transformerlab_internal-0.1.51.tar.gz
Size 131.7 kB
Tags Source
SHA-256 checksum
How to use checksums
32132da12d2f3674da232f0c2e63222aa83f3629b810ad597963d97a16098b24
BLAKE2b-256 checksum
How to use checksums
2519d219c9fd620b2b4b29d1f64aeab229263b429b73fee9903e0b49e7cc6cdc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / transformerlab_internal-0.1.51-py3-none-any.whl

Download URL transformerlab_internal-0.1.51-py3-none-any.whl
Size 106.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e7868da511c77001f34413e112c7b4db0e3399bf504f026ac3caf8bf1f45a593
BLAKE2b-256 checksum
How to use checksums
310b558cc36858c1ed484b896e238bad4d60faaec1db7754d4e74b7f6564694f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

0.1.56

2 release files

0.1.53

2 release files

0.1.52

2 release files

This release

0.1.51 This release

2 release files

0.1.50

2 release files

0.1.49

2 release files

0.1.48

2 release files

0.1.47

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page