Skip to content

README

liblaf.cherries.core.params

Classes:

  • ParamPluginProtocol

    Hook surface for plugins that receive experiment parameters.

  • ParamsManager

    Store experiment parameters and mirror them to plugins.

ParamPluginProtocol

Bases: Protocol


              flowchart TD
              liblaf.cherries.core.params.ParamPluginProtocol[ParamPluginProtocol]

              

              click liblaf.cherries.core.params.ParamPluginProtocol href "" "liblaf.cherries.core.params.ParamPluginProtocol"
            

Hook surface for plugins that receive experiment parameters.

Methods:

  • log_param

    Record one flattened parameter value.

  • log_params

    Record multiple already-flattened parameter values.

log_param

log_param(name: str, value: Any) -> None

Record one flattened parameter value.

Source code in src/liblaf/cherries/core/params/_protocol.py
7
8
9
def log_param(self, name: str, value: Any) -> None:
    """Record one flattened parameter value."""
    ...

log_params

log_params(params: dict[str, Any]) -> None

Record multiple already-flattened parameter values.

Source code in src/liblaf/cherries/core/params/_protocol.py
def log_params(self, params: dict[str, Any]) -> None:
    """Record multiple already-flattened parameter values."""
    ...

ParamsManager

Store experiment parameters and mirror them to plugins.

Parameters are stored internally with slash-delimited keys and returned as a nested dictionary for summaries.

Parameters:

  • plugins (ParamPluginProtocol) –

    Plugin delegate that receives parameter events.

  • params (dict[str, Any], 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)

Methods:

  • get_param

    Return one flattened parameter value.

  • get_params

    Return parameters as a nested dictionary.

  • log_param

    Store and publish one parameter.

  • log_params

    Store and publish multiple parameters.

Attributes:

params class-attribute instance-attribute

params: dict[str, Any] = field(factory=dict)

Flattened parameter values by slash-delimited name.

plugins instance-attribute

Plugin delegate that receives parameter events.

get_param

get_param(name: str) -> Any

Return one flattened parameter value.

Source code in src/liblaf/cherries/core/params/_manager.py
def get_param(self, name: str) -> Any:
    """Return one flattened parameter value."""
    return self.params[name]

get_params

get_params() -> dict[str, Any]

Return parameters as a nested dictionary.

Source code in src/liblaf/cherries/core/params/_manager.py
def get_params(self) -> dict[str, Any]:
    """Return parameters as a nested dictionary."""
    return unflatten_dict(self.params)

log_param

log_param(name: str, value: Any) -> None

Store and publish one parameter.

Source code in src/liblaf/cherries/core/params/_manager.py
def log_param(self, name: str, value: Any) -> None:
    """Store and publish one parameter."""
    self.params[name] = value
    self.plugins.log_param(name, value)

log_params

log_params(params: Mapping[str, Any]) -> None

Store and publish multiple parameters.

Nested mappings are flattened before storage and plugin delegation.

Source code in src/liblaf/cherries/core/params/_manager.py
def log_params(self, params: Mapping[str, Any]) -> None:
    """Store and publish multiple parameters.

    Nested mappings are flattened before storage and plugin delegation.
    """
    params: dict[str, Any] = flatten_dict(params)
    self.params.update(params)
    self.plugins.log_params(params)