Experiment tracking

Logs a Repository revision and its provenance bundle to Weights & Biases or MLflow, so a run pins the exact record CIDs and the lexicon manifest hash it was built against. Requires the lairs[tracking] extra. For usage see Guides > Experiment tracking.

lairs.integrations.tracking

Experiment-tracking hooks.

Logs a Repository revision (not a copy) as an artifact with the provenance bundle, so a logged run pins exact record CIDs. Backends are Weights & Biases and MLflow. Requires the lairs[tracking] extra at runtime.

Reproducibility comes from the revision id: a logged run records the exact commit (or tag) and the vendored lexicon manifest hash that the records were generated against, so the dataset behind a run can always be rebuilt. The revision is validated against the Repository before anything is logged, so a typo'd commit id fails loudly rather than pinning confidently-wrong provenance. The backend libraries are imported lazily inside their _import_* gates, so importing this module never pulls in wandb or mlflow.

ProvenanceBundle

Bases: Model

The provenance pinned alongside a logged Repository revision.

ATTRIBUTE DESCRIPTION
revision

The Repository revision (commit id or tag) the run was logged against.

TYPE: str

lexicon_tree_hash

The content hash of the vendored lexicon tree the records were generated from, read from lairs/lexicons/MANIFEST.toml.

TYPE: str

layers_version

The upstream Layers release version the lexicons were vendored from.

TYPE: str

working_dir

The Repository working directory the revision was read from.

TYPE: str

log_revision

log_revision(
    repo: Repository, revision: str, *, backend: str
) -> str

Log a Repository revision as a tracked artifact.

The revision itself (not a copy of the data) is recorded together with a :class:ProvenanceBundle, so a logged run pins the exact commit and the vendored lexicon manifest hash that the records were generated against. The revision is validated against the Repository first, so a typo'd commit id raises before anything is logged. The backend library is imported lazily, so a missing optional dependency raises a clear error only when that backend is used.

PARAMETER DESCRIPTION
repo

The Repository holding the revision.

TYPE: Repository

revision

The revision (commit id, tag, or branch) to log. It must resolve to a commit in repo.

TYPE: str

backend

The tracking backend ("wandb" or "mlflow").

TYPE: str

RETURNS DESCRIPTION
str

The tracked artifact identifier, as "lairs-revision:<revision>".

RAISES DESCRIPTION
ValueError

If backend is not a recognised tracking backend, or revision does not resolve to a commit in the Repository.

ImportError

If the backend's optional dependency is not installed.

RuntimeError

For the "wandb" backend, when there is no active run to log into.