Tracking¶
tinax.tracking wraps Weights & Biases run tracking. Constructing WandbRun is the explicit start of the lifecycle: it imports wandb on demand, calls wandb.init, and stores the returned run. log and log_artifact require an unfinished run, finish is idempotent, and the context manager finishes the run on exit. Importing tinax.tracking imports neither wandb nor JAX.
from tinax.tracking import WandbRun
with WandbRun(project="demo", name="baseline", config={"learning_rate": 0.1}) as run:
run.log({"loss": 0.5}, step=0)
WandbRun
¶
WandbRun(
*,
project: str,
name: str | None = None,
config: Mapping[str, Any] | None = None,
tags: Sequence[str] | None = None,
group: str | None = None,
)
An explicitly started Weights & Biases run with explicit finish semantics.
Constructing the handle starts the run by calling wandb.init and storing the
returned run object; finish or leaving the context manager ends it. log and
log_artifact require an unfinished run. The wandb package is imported only
when a handle is constructed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project
|
str
|
Weights & Biases project name. Must be non-empty. |
required |
name
|
str | None
|
Optional run name. |
None
|
config
|
Mapping[str, Any] | None
|
Optional run configuration mapping with string keys. |
None
|
tags
|
Sequence[str] | None
|
Optional sequence of non-empty tag strings. |
None
|
group
|
str | None
|
Optional group name for related runs. |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If a string argument is not a string, |
ValueError
|
If |
log
¶
Log one mapping of scalar metrics to the started run.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
metrics
|
Mapping[str, float]
|
Non-empty mapping of metric names to finite |
required |
step
|
int | None
|
Optional non-negative step associated with the metrics. |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If |
RuntimeError
|
If the run was already finished. |
log_artifact
¶
log_artifact(
path: str | PathLike[str],
*,
name: str,
artifact_type: str = "model",
metadata: Mapping[str, Any] | None = None,
aliases: Sequence[str] | None = None,
) -> None
Log one existing local file to the started run as a Weights & Biases artifact.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | PathLike[str]
|
Path to an existing local file. |
required |
name
|
str
|
Non-empty artifact name. |
required |
artifact_type
|
str
|
Non-empty artifact type label. |
'model'
|
metadata
|
Mapping[str, Any] | None
|
Optional mapping stored as artifact metadata. |
None
|
aliases
|
Sequence[str] | None
|
Optional sequence of non-empty alias strings. |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If |
FileNotFoundError
|
If no file exists at |
RuntimeError
|
If the run was already finished. |