Skip to main content

Python SDK for Transformer Lab

Project description

Transformer Lab SDK

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

Install

pip install transformerlab

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")

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-app/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-app

To develop locally in editable mode and run automated tests:

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

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

transformerlab-0.1.34.tar.gz (112.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

transformerlab-0.1.34-py3-none-any.whl (95.5 kB view details)

Uploaded Python 3

File details

Details for the file transformerlab-0.1.34.tar.gz.

File metadata

  • Download URL: transformerlab-0.1.34.tar.gz
  • Upload date:
  • Size: 112.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for transformerlab-0.1.34.tar.gz
Algorithm Hash digest
SHA256 cd5651ef5cc023f611eebeccd81baa4d51ae8262642c1582e85ab9f0e844a3c6
MD5 4b837dcdb084b50457f87f6d86a180b6
BLAKE2b-256 33d3e44d4ac4e54879c6c62310034a79ec8149b660f86707760dcfbaa479ef83

See more details on using hashes here.

File details

Details for the file transformerlab-0.1.34-py3-none-any.whl.

File metadata

File hashes

Hashes for transformerlab-0.1.34-py3-none-any.whl
Algorithm Hash digest
SHA256 50e28b5ae463678f9145f020d11e1e7e1c9db688d2ac752f00aa0c7bd13ff6df
MD5 95f3e403aac0704dcaeec94b78b41e9b
BLAKE2b-256 d1db7f60493d5c46619c8ead70a1b7e124bb6fba30fc1755453091d64a268045

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page