Python API¶
Normal recording returns a directory under
<repo>/cherries/runs/YYYY/mm/dd/<UUIDv7>/. The date is the original local date
in the persisted run.yaml start-time; finishing after midnight or transferring
across timezones keeps the same partition. See the storage design.
liblaf.cherries
¶
Record Python experiments as ordinary local files and portable remote archives.
Classes:
-
BaseConfig–Parameters defined in the experiment script, serialized as ordinary JSON.
Functions:
-
end–Record end-time, then save files, metrics and Git state; finalize directory.
-
fig–Return absolute study/figs/path, create parents and register the figure.
-
get_step–Return the current step, initially zero.
-
input–Return absolute study/data/path and register its end-of-run input copy.
-
log_metric–Append and flush one metric using the current step and time by default.
-
log_metrics–Append in mapping order, sharing step/time, and flush once without fsync.
-
output–Return absolute study/data/path, create parents and register the output.
-
run–Execute main and return its saved directory, or None when DEBUG=1.
-
set_step–Set the current step; logging does not increment it.
-
start–Begin at step zero; DEBUG=1 skips recording and retains workspace paths.
-
tmp–Return absolute study/tmp/path, creating parents without recording it.
Attributes:
-
__commit_id__(str | None) – -
__version__(str) – -
__version_tuple__(tuple[int | str, ...]) –
__version_tuple__
module-attribute
¶
BaseConfig
pydantic-model
¶
end
¶
Record end-time, then save files, metrics and Git state; finalize directory.
log_metric
¶
log_metric(
key: str,
value: float,
*,
step: int | None = None,
timestamp_ms: int | None = None,
) -> None
Append and flush one metric using the current step and time by default.
Source code in src/liblaf/cherries/_runtime.py
log_metrics
¶
log_metrics(
metrics: Mapping[str, int | float],
*,
step: int | None = None,
timestamp_ms: int | None = None,
) -> None
Append in mapping order, sharing step/time, and flush once without fsync.
Source code in src/liblaf/cherries/_runtime.py
run
¶
run(
main: Callable[..., None],
*,
project_id: str | None = None,
name: str | None = None,
description: str | None = None,
tags: Sequence[str] = (),
metadata: Mapping[str, Any] | None = None,
) -> Path | None
Execute main and return its saved directory, or None when DEBUG=1.
Source code in src/liblaf/cherries/_runtime.py
start
¶
start(
*,
project_id: str | None = None,
name: str | None = None,
description: str | None = None,
tags: Sequence[str] = (),
params: Mapping[str, Any] | None = None,
metadata: Mapping[str, Any] | None = None,
) -> None
Begin at step zero; DEBUG=1 skips recording and retains workspace paths.
Source code in src/liblaf/cherries/_runtime.py
tmp
¶
tmp(path: Pathish) -> Path
Return absolute study/tmp/path, creating parents without recording it.