README
liblaf.cherries.core
¶
Modules:
Classes:
-
Plugin–Base class for Cherries plugins.
-
PluginProtocol–Complete hook surface implemented by Cherries plugin delegates.
-
Run–Mutable state for one Cherries experiment run.
Functions:
-
end– -
get_metric– -
get_metrics– -
get_other– -
get_others– -
get_param– -
get_params– -
get_step– -
impl–Mark a method as a plugin hook implementation.
-
input– -
log_asset– -
log_input– -
log_metric– -
log_metrics– -
log_other– -
log_others– -
log_output– -
log_param– -
log_params– -
log_temp– -
output– -
set_step– -
start– -
temp–
Attributes:
Plugin
¶
Base class for Cherries plugins.
Attributes:
Parameters:
-
name(PluginName, default:<dynamic>) –
name
class-attribute
instance-attribute
¶
name: PluginName = field(
default=Factory(_default_name, takes_self=True),
kw_only=True,
)
PluginProtocol
¶
Bases: AssetPluginProtocol, MetricPluginProtocol, OtherPluginProtocol, ParamPluginProtocol, Protocol
flowchart TD
liblaf.cherries.core.PluginProtocol[PluginProtocol]
liblaf.cherries.core.assets._protocol.AssetPluginProtocol[AssetPluginProtocol]
liblaf.cherries.core.metrics._protocol.MetricPluginProtocol[MetricPluginProtocol]
liblaf.cherries.core.others._protocol.OtherPluginProtocol[OtherPluginProtocol]
liblaf.cherries.core.params._protocol.ParamPluginProtocol[ParamPluginProtocol]
liblaf.cherries.core.assets._protocol.AssetPluginProtocol --> liblaf.cherries.core.PluginProtocol
liblaf.cherries.core.metrics._protocol.MetricPluginProtocol --> liblaf.cherries.core.PluginProtocol
liblaf.cherries.core.others._protocol.OtherPluginProtocol --> liblaf.cherries.core.PluginProtocol
liblaf.cherries.core.params._protocol.ParamPluginProtocol --> liblaf.cherries.core.PluginProtocol
click liblaf.cherries.core.PluginProtocol href "" "liblaf.cherries.core.PluginProtocol"
click liblaf.cherries.core.assets._protocol.AssetPluginProtocol href "" "liblaf.cherries.core.assets._protocol.AssetPluginProtocol"
click liblaf.cherries.core.metrics._protocol.MetricPluginProtocol href "" "liblaf.cherries.core.metrics._protocol.MetricPluginProtocol"
click liblaf.cherries.core.others._protocol.OtherPluginProtocol href "" "liblaf.cherries.core.others._protocol.OtherPluginProtocol"
click liblaf.cherries.core.params._protocol.ParamPluginProtocol href "" "liblaf.cherries.core.params._protocol.ParamPluginProtocol"
Complete hook surface implemented by Cherries plugin delegates.
Methods:
-
end–End a run.
-
log_asset–Record an existing artifact path.
-
log_metric–Record one metric sample.
-
log_metrics–Record a batch of already-flattened metric samples.
-
log_other–Record one flattened metadata value.
-
log_others–Record multiple already-flattened metadata values.
-
log_param–Record one flattened parameter value.
-
log_params–Record multiple already-flattened parameter values.
-
start–Start a run.
end
¶
end(exc: BaseException | None = None) -> None
End a run.
Parameters:
-
exc(BaseException | None, default:None) –Exception raised by the experiment, if any.
log_asset
¶
Record an existing artifact path.
Parameters:
-
path(Path) –Existing file or directory to record.
-
metadata(Mapping[str, Any] | None, default:None) –Optional artifact metadata, usually including
type. -
report(bool, default:True) –Whether the path is the primary user-facing artifact. Companion files are logged with
report=False.
Source code in src/liblaf/cherries/core/assets/_protocol.py
log_metric
¶
log_metrics
¶
log_other
¶
log_others
¶
log_param
¶
log_params
¶
Run
¶
Mutable state for one Cherries experiment run.
A Run owns plugin registration, path helpers, metrics, parameters, and
miscellaneous metadata. Profiles configure the process-global run, while
main starts and ends it around an experiment
callable.
Parameters:
-
plugins(PluginManager, default:<dynamic>) –Register plugins and delegate hook calls in dependency order.
Only methods decorated with
implare invoked. Hook order is cached per method and recalculated whenever a plugin is registered.
Methods:
-
end–Flush artifacts, record shutdown metadata, and end plugins.
-
get_metric–Return one metric series.
-
get_metrics–Return selected metric series concatenated into one dataframe.
-
get_other–Return one flattened metadata value.
-
get_others–Return logged metadata as a nested dictionary.
-
get_param–Return one flattened parameter value.
-
get_params–Return logged parameters as a nested dictionary.
-
get_step–Return the default metric step.
-
input–Resolve and immediately log an input below
data/. -
log_asset–Log an existing generic artifact immediately.
-
log_input–Log an existing input artifact immediately.
-
log_metric–Log one scalar metric.
-
log_metrics–Log multiple scalar metrics, flattening nested mappings with
/. -
log_other–Log one metadata value.
-
log_others–Log multiple metadata values.
-
log_output–Log an existing output artifact immediately.
-
log_param–Log one parameter value.
-
log_params–Log multiple parameter values.
-
log_temp–Log an existing temporary artifact immediately.
-
output–Resolve an output below
data/and queue it until run end. -
set_step–Set the default metric step.
-
start–Start plugins and record Cherries run metadata.
-
summary–Build a JSON/YAML-friendly run summary.
-
temp–Resolve a temporary artifact below
tmp/and queue it until run end.
Attributes:
-
entrypoint(Path) –Python entrypoint used to derive the experiment name and folders.
-
plugins(PluginManager) – -
project_dir(Path) –Git repository root, or the current directory outside a Git repo.
-
project_name(str) –Project name reported to plugins.
-
repo(Repo | None) – -
run_key(Path) – -
run_name(str) –Run name from
CHERRIES_NAMEor the entrypoint path. -
start_time(datetime) –Timezone-aware timestamp captured when the run object is first used.
-
step(int) –Default metric step.
-
tags(list[str]) –Tags parsed from the
CHERRIES_TAGSenvironment variable. -
working_dir(Path) –Directory used to resolve data, temporary, log, and local snapshot paths.
entrypoint
cached
property
¶
entrypoint: Path
Python entrypoint used to derive the experiment name and folders.
project_dir
cached
property
¶
project_dir: Path
Git repository root, or the current directory outside a Git repo.
start_time
cached
property
¶
start_time: datetime
Timezone-aware timestamp captured when the run object is first used.
working_dir
cached
property
¶
working_dir: Path
Directory used to resolve data, temporary, log, and local snapshot paths.
end
¶
end(exc: BaseException | None = None) -> None
Flush artifacts, record shutdown metadata, and end plugins.
Parameters:
-
exc(BaseException | None, default:None) –Exception raised by the experiment, if any.
Source code in src/liblaf/cherries/core/_run.py
get_metrics
¶
Return selected metric series concatenated into one dataframe.
get_other
¶
get_others
¶
get_param
¶
get_params
¶
input
¶
Resolve and immediately log an input below data/.
log_asset
¶
Log an existing generic artifact immediately.
log_input
¶
log_metric
¶
log_metric(
name: str,
value: SupportsFloat,
*,
step: int | None = None,
time: datetime | None = None,
) -> None
Log one scalar metric.
log_metrics
¶
log_metrics(
metrics: MetricsLike,
*,
step: int | None = None,
time: datetime | None = None,
) -> None
Log multiple scalar metrics, flattening nested mappings with /.
Source code in src/liblaf/cherries/core/_run.py
log_other
¶
log_others
¶
log_output
¶
Log an existing output artifact immediately.
log_param
¶
log_params
¶
log_temp
¶
Log an existing temporary artifact immediately.
output
¶
Resolve an output below data/ and queue it until run end.
Source code in src/liblaf/cherries/core/_run.py
start
¶
Start plugins and record Cherries run metadata.
Source code in src/liblaf/cherries/core/_run.py
summary
¶
Build a JSON/YAML-friendly run summary.
Parameters:
-
prefix(StrPath | None, default:None) –Optional directory to strip from artifact paths.
Returns:
Source code in src/liblaf/cherries/core/_run.py
temp
¶
Resolve a temporary artifact below tmp/ and queue it until run end.
Source code in src/liblaf/cherries/core/_run.py
impl
¶
impl[F: Callable[..., Any]](
func: F,
/,
*,
after: Iterable[PluginName] = (),
before: Iterable[PluginName] = (),
) -> F
impl[F: Callable[..., Any]](
*,
after: Iterable[PluginName] = (),
before: Iterable[PluginName] = (),
) -> Callable[[F], F]
Mark a method as a plugin hook implementation.
Parameters:
-
func(Callable[..., Any] | None, default:None) –Method being decorated.
-
**kwargs(Any, default:{}) –Ordering metadata accepted by [
ImplInfo][liblaf.cherries.core.ImplInfo].
Examples:
>>> @impl(before=("Comet",))
... def log_metric():
... return None
>>> get_impl_info(log_metric).before
('Comet',)
Source code in src/liblaf/cherries/core/plugin/_impl.py
log_metric
¶
log_metric(
name: str,
value: SupportsFloat,
*,
step: int | None = None,
time: datetime | None = None,
) -> None
log_metrics
¶
log_metrics(
metrics: MetricsLike,
*,
step: int | None = None,
time: datetime | None = None,
) -> None