Skip to content

README

liblaf.cherries.core.others

Classes:

  • OtherPluginProtocol

    Hook surface for plugins that receive miscellaneous run metadata.

  • OthersManager

    Store miscellaneous run metadata and mirror it to plugins.

OtherPluginProtocol

Bases: Protocol


              flowchart TD
              liblaf.cherries.core.others.OtherPluginProtocol[OtherPluginProtocol]

              

              click liblaf.cherries.core.others.OtherPluginProtocol href "" "liblaf.cherries.core.others.OtherPluginProtocol"
            

Hook surface for plugins that receive miscellaneous run metadata.

Methods:

  • log_other

    Record one flattened metadata value.

  • log_others

    Record multiple already-flattened metadata values.

log_other

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

Record one flattened metadata value.

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

log_others

log_others(others: dict[str, Any]) -> None

Record multiple already-flattened metadata values.

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

OthersManager

Store miscellaneous run metadata and mirror it to plugins.

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

Parameters:

  • plugins (OtherPluginProtocol) –

    Plugin delegate that receives metadata events.

  • others (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_other

    Return one flattened metadata value.

  • get_others

    Return metadata as a nested dictionary.

  • log_other

    Store and publish one metadata value.

  • log_others

    Store and publish multiple metadata values.

Attributes:

others class-attribute instance-attribute

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

Flattened metadata values by slash-delimited name.

plugins instance-attribute

Plugin delegate that receives metadata events.

get_other

get_other(name: str) -> Any

Return one flattened metadata value.

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

get_others

get_others() -> dict[str, Any]

Return metadata as a nested dictionary.

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

log_other

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

Store and publish one metadata value.

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

log_others

log_others(others: Mapping[str, Any]) -> None

Store and publish multiple metadata values.

Nested mappings are flattened before storage and plugin delegation.

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

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