README
liblaf.cherries.core.assets
¶
Modules:
-
bundle–
Classes:
-
AssetPluginProtocol–Hook surface for plugins that receive artifact paths.
-
AssetsManager–Resolve experiment paths and flush existing artifacts to plugins.
-
Bundle–Base class for artifact companion-file discovery.
-
BundleItem–Related file discovered for a logged artifact.
-
BundleRegistry–Registry that expands logged artifacts through matching bundles.
Attributes:
AssetPluginProtocol
¶
Bases: Protocol
flowchart TD
liblaf.cherries.core.assets.AssetPluginProtocol[AssetPluginProtocol]
click liblaf.cherries.core.assets.AssetPluginProtocol href "" "liblaf.cherries.core.assets.AssetPluginProtocol"
Hook surface for plugins that receive artifact paths.
Methods:
-
log_asset–Record an existing artifact path.
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
AssetsManager
¶
Resolve experiment paths and flush existing artifacts to plugins.
Inputs are reported immediately because they should already exist. Outputs and temporary artifacts are queued until run shutdown so an experiment can create them after configuration is built.
Parameters:
-
working_dir(Path) –Directory used as the base for
data/andtmp/paths. -
plugins(AssetPluginProtocol) –Plugin delegate that receives existing artifacts.
-
bundles(BundleRegistry, default:BundleRegistry(registry=[BundleLandmarks(suffixes={'.vtr', '.vtkhdf', '.obj', '.stl', '.ply', '.vtu', '.vtp', '.vti', '.vts'}), BundleSeries()])) –Bundle registry used to expand related files.
-
pending(list[PendingAsset], default:<dynamic>) –Built-in mutable sequence.
If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified.
-
summary(AssetsSummary, default:<dynamic>) –Paths successfully reported during a run.
The summary contains only primary artifacts. Bundle companions are sent to plugins, but omitted from this user-facing record.
Methods:
-
end–Flush queued output and temporary paths.
-
input–Resolve and immediately log an input path.
-
log_asset–Log an existing path and any companion files from matching bundles.
-
log_input–Log
pathas an input artifact. -
log_output–Log
pathas an output artifact. -
log_temp–Log
pathas a temporary artifact. -
output–Resolve an output path and queue it for end-of-run logging.
-
temp–Resolve a temporary path and queue it for end-of-run logging.
Attributes:
-
bundles(BundleRegistry) –Bundle registry used to expand related files.
-
data_dir(Path) –Directory containing input and output data files.
-
pending(list[PendingAsset]) –Output and temporary paths waiting for run shutdown.
-
plugins(AssetPluginProtocol) –Plugin delegate that receives existing artifacts.
-
summary(AssetsSummary) –Artifact summary populated by successful log calls.
-
temp_dir(Path) –Directory containing temporary artifacts.
-
working_dir(Path) –Directory used as the base for
data/andtmp/paths.
bundles
class-attribute
instance-attribute
¶
bundles: BundleRegistry = field(default=bundles)
Bundle registry used to expand related files.
pending
class-attribute
instance-attribute
¶
Output and temporary paths waiting for run shutdown.
plugins
instance-attribute
¶
plugins: AssetPluginProtocol
Plugin delegate that receives existing artifacts.
summary
class-attribute
instance-attribute
¶
Artifact summary populated by successful log calls.
working_dir
instance-attribute
¶
working_dir: Path
Directory used as the base for data/ and tmp/ paths.
end
¶
Flush queued output and temporary paths.
Missing queued paths produce warnings and are left out of the summary.
Source code in src/liblaf/cherries/core/assets/_manager.py
input
¶
Resolve and immediately log an input path.
Parameters:
-
name(StrPath) –Path below
data/. -
metadata(Mapping[str, Any] | None, default:None) –Extra metadata merged with
{"type": "input"}.
Returns:
-
Path–Resolved input path.
Source code in src/liblaf/cherries/core/assets/_manager.py
log_asset
¶
Log an existing path and any companion files from matching bundles.
Missing primary paths are reported as warnings. Missing optional bundle files are ignored, while missing required bundle files are warned.
Source code in src/liblaf/cherries/core/assets/_manager.py
log_input
¶
Log path as an input artifact.
Source code in src/liblaf/cherries/core/assets/_manager.py
log_output
¶
Log path as an output artifact.
Source code in src/liblaf/cherries/core/assets/_manager.py
log_temp
¶
Log path as a temporary artifact.
Source code in src/liblaf/cherries/core/assets/_manager.py
output
¶
Resolve an output path and queue it for end-of-run logging.
Parameters:
-
name(StrPath) –Path below
data/. -
metadata(Mapping[str, Any] | None, default:None) –Extra metadata merged with
{"type": "output"}. -
mkdir(bool, default:True) –Whether to create the parent directory before returning.
Returns:
-
Path–Resolved output path.
Source code in src/liblaf/cherries/core/assets/_manager.py
temp
¶
Resolve a temporary path and queue it for end-of-run logging.
Parameters:
-
name(StrPath) –Path below
tmp/. -
metadata(Mapping[str, Any] | None, default:None) –Extra metadata merged with
{"type": "temp"}. -
mkdir(bool, default:True) –Whether to create the parent directory before returning.
Returns:
-
Path–Resolved temporary path.
Source code in src/liblaf/cherries/core/assets/_manager.py
Bundle
¶
Bases: ABC
flowchart TD
liblaf.cherries.core.assets.Bundle[Bundle]
click liblaf.cherries.core.assets.Bundle href "" "liblaf.cherries.core.assets.Bundle"
Base class for artifact companion-file discovery.
Methods:
-
ls_files–Yield files that should be logged with
path. -
match–Return whether this bundle can expand
path.
ls_files
abstractmethod
¶
ls_files(path: Path) -> Iterable[BundleItem]
Yield files that should be logged with path.
Parameters:
-
path(Path) –Primary artifact path.
Returns:
-
Iterable[BundleItem]–Iterable of companion files and their optional/missing-file policy.
Source code in src/liblaf/cherries/core/assets/bundle/_abc.py
BundleItem
¶
Bases: NamedTuple
flowchart TD
liblaf.cherries.core.assets.BundleItem[BundleItem]
click liblaf.cherries.core.assets.BundleItem href "" "liblaf.cherries.core.assets.BundleItem"
Related file discovered for a logged artifact.
Attributes:
Parameters:
-
path(ForwardRef, default:None) – -
optional(ForwardRef, default:None) –
BundleRegistry
¶
Registry that expands logged artifacts through matching bundles.
Examples:
Parameters:
-
registry(list[Bundle], default:[BundleLandmarks(suffixes={'.vtr', '.vtkhdf', '.obj', '.stl', '.ply', '.vtu', '.vtp', '.vti', '.vts'}), BundleSeries()]) –
Methods:
-
ls_files–Yield companion files from every bundle that matches
path. -
register–Append
bundleto the registry.
Attributes:
registry
class-attribute
instance-attribute
¶
ls_files
¶
ls_files(path: Path) -> Generator[BundleItem]
Yield companion files from every bundle that matches path.