Bases: PluginManager
flowchart TD
liblaf.cherries.Run[Run]
liblaf.cherries.core._plugin_manager.PluginManager[PluginManager]
liblaf.cherries.core._plugin_manager.PluginManager --> liblaf.cherries.Run
click liblaf.cherries.Run href "" "liblaf.cherries.Run"
click liblaf.cherries.core._plugin_manager.PluginManager href "" "liblaf.cherries.core._plugin_manager.PluginManager"
Parameters:
-
plugins
(dict[PluginId, Plugin], default:
<class 'dict'>
)
–
dict() -> new empty dictionary
dict(mapping) -> new dictionary initialized from a mapping object’s
(key, value) pairs
dict(iterable) -> new dictionary initialized as if via:
d = {}
for k, v in iterable:
d[k] = v
dict(**kwargs) -> new dictionary initialized with the name=value pairs
in the keyword argument list. For example: dict(one=1, two=2)
Returned by:
-
Reference
Liblaf
cherries
Methods:
Attributes:
entrypoint
cached
property
plugins
class-attribute
instance-attribute
project_dir
cached
property
project_name
cached
property
start_time
cached
property
asset
asset(path: StrPath, *, mkdir: bool = False) -> Path
Source code in src/liblaf/cherries/core/_run.py
| def asset(self, path: StrPath, *, mkdir: bool = False) -> Path:
absolute: Path = self.exp_dir / path
if mkdir:
absolute.parent.mkdir(parents=True, exist_ok=True)
self._assets_queue.append(absolute)
return absolute
|
delegate
Source code in src/liblaf/cherries/core/_plugin_manager.py
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80 | def delegate(
self,
method: MethodName,
args: Sequence[Any] = (),
kwargs: Mapping[str, Any] = {},
*,
first_result: bool = False,
) -> Any:
__tracebackhide__ = True
results: list[Any] = []
for plugin in self._sort_plugins(method):
try:
result: Any = getattr(plugin, method)(*args, **kwargs)
except Exception:
logger.exception("Plugin %s", plugin.id)
else:
if result is None:
continue
if first_result:
return result
results.append(result)
if first_result:
return None
return results
|
end
end(*args, **kwargs) -> None
Source code in src/liblaf/cherries/core/_run.py
135
136
137
138
139
140
141
142
143
144
145
146 | def end(self, *args, **kwargs) -> None:
__tracebackhide__ = True
self.log_other("cherries.end_time", datetime.now().astimezone())
for path in self._assets_queue:
self.log_asset(path)
for path in self._inputs_queue:
self.log_input(path)
for path in self._outputs_queue:
self.log_output(path)
for path in self._temps_queue:
self.log_temp(path)
self.delegate("end", args, kwargs)
|
get_other
Source code in src/liblaf/cherries/core/_run.py
| @delegate(first_result=True)
def get_other(self, name: str) -> Any: ...
|
get_others
Source code in src/liblaf/cherries/core/_run.py
| @delegate(first_result=True)
def get_others(self) -> Mapping[str, Any]: ...
|
get_param
Source code in src/liblaf/cherries/core/_run.py
| @delegate(first_result=True)
def get_param(self, name: str) -> Any: ...
|
get_params
Source code in src/liblaf/cherries/core/_run.py
| @delegate(first_result=True)
def get_params(self) -> Mapping[str, Any]: ...
|
get_step
Source code in src/liblaf/cherries/core/_run.py
| @delegate(first_result=True)
def get_step(self) -> int | None: ...
|
get_url
Source code in src/liblaf/cherries/core/_run.py
| @delegate(first_result=True)
def get_url(self) -> str: ...
|
input(path: StrPath, *, mkdir: bool = False) -> Path
Source code in src/liblaf/cherries/core/_run.py
| def input(self, path: StrPath, *, mkdir: bool = False) -> Path:
absolute: Path = self.data_dir / path
if mkdir:
absolute.parent.mkdir(parents=True, exist_ok=True)
self._inputs_queue.append(absolute)
return absolute
|
log_asset
log_asset(path: StrPath, **kwargs) -> None
Source code in src/liblaf/cherries/core/_run.py
| def log_asset(self, path: StrPath, **kwargs) -> None:
__tracebackhide__ = True
self._log_asset(path, "log_asset", self.exp_dir, **kwargs)
|
log_input(path: StrPath, **kwargs) -> None
Source code in src/liblaf/cherries/core/_run.py
| def log_input(self, path: StrPath, **kwargs) -> None:
__tracebackhide__ = True
self._log_asset(path, "log_input", self.data_dir, **kwargs)
|
log_metric
log_metric(
name: str, value: Any, step: int | None = None, **kwargs
) -> None
Source code in src/liblaf/cherries/core/_run.py
| @delegate
def log_metric(
self, name: str, value: Any, step: int | None = None, **kwargs
) -> None: ...
|
log_metrics
log_metrics(
metrics: Mapping[str, Any],
step: int | None = None,
**kwargs,
) -> None
Source code in src/liblaf/cherries/core/_run.py
| @delegate
def log_metrics(
self, metrics: Mapping[str, Any], step: int | None = None, **kwargs
) -> None: ...
|
log_other
log_other(name: str, value: Any) -> None
Source code in src/liblaf/cherries/core/_run.py
| @delegate
def log_other(self, name: str, value: Any) -> None: ...
|
log_others
Source code in src/liblaf/cherries/core/_run.py
| @delegate
def log_others(self, others: Mapping[str, Any]) -> None: ...
|
log_output
log_output(path: StrPath, **kwargs) -> None
Source code in src/liblaf/cherries/core/_run.py
| def log_output(self, path: StrPath, **kwargs) -> None:
__tracebackhide__ = True
self._log_asset(path, "log_output", self.data_dir, **kwargs)
|
log_param
log_param(name: str, value: Any) -> None
Source code in src/liblaf/cherries/core/_run.py
| @delegate
def log_param(self, name: str, value: Any) -> None: ...
|
log_params
Source code in src/liblaf/cherries/core/_run.py
| @delegate
def log_params(self, params: Mapping[str, Any]) -> None: ...
|
log_temp
log_temp(path: StrPath, **kwargs) -> None
Source code in src/liblaf/cherries/core/_run.py
| def log_temp(self, path: StrPath, **kwargs) -> None:
__tracebackhide__ = True
self._log_asset(path, "log_temp", self.temp_dir, **kwargs)
|
output
output(path: StrPath, *, mkdir: bool = False) -> Path
Source code in src/liblaf/cherries/core/_run.py
| def output(self, path: StrPath, *, mkdir: bool = False) -> Path:
absolute: Path = self.data_dir / path
if mkdir:
absolute.parent.mkdir(parents=True, exist_ok=True)
self._outputs_queue.append(absolute)
return absolute
|
register
register(plugin: Plugin) -> None
Source code in src/liblaf/cherries/core/_plugin_manager.py
| def register(self, plugin: Plugin) -> None:
for method_name in collect_impls(plugin):
self._sort_plugins_cache.pop(method_name, None)
plugin.manager = self
self.plugins[plugin.id] = plugin
|
set_step
set_step(step: int | None = None) -> None
Source code in src/liblaf/cherries/core/_run.py
| @delegate
def set_step(self, step: int | None = None) -> None: ...
|
start
start(*args, **kwargs) -> None
Source code in src/liblaf/cherries/core/_run.py
207
208
209
210
211
212
213
214
215
216
217 | def start(self, *args, **kwargs) -> None:
__tracebackhide__ = True
self.delegate("start", args, kwargs)
self.log_other(
"cherries.entrypoint",
_relative_or_absolute(self.entrypoint, self.project_dir),
)
self.log_other(
"cherries.exp_dir", _relative_or_absolute(self.exp_dir, self.project_dir)
)
self.log_other("cherries.start_time", self.start_time)
|
temp
temp(path: StrPath, *, mkdir: bool = False) -> Path
Source code in src/liblaf/cherries/core/_run.py
| def temp(self, path: StrPath, *, mkdir: bool = False) -> Path:
absolute: Path = self.temp_dir / path
if mkdir:
absolute.parent.mkdir(parents=True, exist_ok=True)
self._temps_queue.append(absolute)
return absolute
|