Skip to content

liblaf.cherries ¤

Modules:

Classes:

Functions:

Attributes:

add_tag module-attribute ¤

add_tag: AddTag = add_tag

add_tags module-attribute ¤

add_tags: AddTags = add_tags

log_asset module-attribute ¤

log_asset: LogAsset = log_asset

log_code module-attribute ¤

log_code: LogCode = log_code

log_metric module-attribute ¤

log_metric: LogMetric = log_metric

log_metrics module-attribute ¤

log_metrics: LogMetrics = log_metrics

log_other module-attribute ¤

log_other: LogOther = log_other

log_others module-attribute ¤

log_others: LogOthers = log_others

log_param module-attribute ¤

log_param: LogParam = log_param

log_params module-attribute ¤

log_params: LogParams = log_params

AddTag ¤

Bases: Plugin

Parameters:

  • priority (int, default: 0 ) –
  • _children (list[str], 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.

Methods:

Attributes:

children property ¤

children: list[Plugin]

priority class-attribute instance-attribute ¤

priority: int = field(default=0, kw_only=True)

__attrs_post_init__ ¤

__attrs_post_init__() -> None
Source code in src/liblaf/cherries/integration/_abc.py
21
22
def __attrs_post_init__(self) -> None:
    self._children.sort(key=operator.attrgetter("priority"))

__call__ ¤

__call__(tag: str, /, **kwargs) -> None
Source code in src/liblaf/cherries/integration/_abc.py
62
63
def __call__(self, tag: str, /, **kwargs) -> None:
    super().__call__(tag, **kwargs)

__eq__ ¤

__eq__(other: Plugin) -> bool
Source code in src/liblaf/cherries/integration/_abc.py
40
41
42
43
def __eq__(self, other: "Plugin") -> bool:  # pyright: ignore[reportIncompatibleMethodOverride]
    if not isinstance(other, Plugin):
        return NotImplemented
    return self.priority == other.priority

__lt__ ¤

__lt__(other: Plugin) -> bool
Source code in src/liblaf/cherries/integration/_abc.py
35
36
37
38
def __lt__(self, other: "Plugin") -> bool:
    if not isinstance(other, Plugin):
        return NotImplemented
    return self.priority < other.priority

add ¤

add(*children: Plugin) -> None
Source code in src/liblaf/cherries/integration/_abc.py
49
50
51
def add(self, *children: "Plugin") -> None:
    for c in children:
        bisect.insort(self._children, c, key=operator.attrgetter("priority"))

extend ¤

extend(children: Iterable[Plugin]) -> None
Source code in src/liblaf/cherries/integration/_abc.py
53
54
def extend(self, children: Iterable["Plugin"]) -> None:
    self.add(*children)

remove ¤

remove(child: Plugin) -> None
Source code in src/liblaf/cherries/integration/_abc.py
56
57
def remove(self, child: "Plugin") -> None:
    self._children.remove(child)

AddTags ¤

Bases: Plugin

Parameters:

  • priority (int, default: 0 ) –
  • _children (list[str], 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.

Methods:

Attributes:

children property ¤

children: list[Plugin]

priority class-attribute instance-attribute ¤

priority: int = field(default=0, kw_only=True)

__attrs_post_init__ ¤

__attrs_post_init__() -> None
Source code in src/liblaf/cherries/integration/_abc.py
21
22
def __attrs_post_init__(self) -> None:
    self._children.sort(key=operator.attrgetter("priority"))

__call__ ¤

__call__(tags: Iterable[str], /, **kwargs) -> None
Source code in src/liblaf/cherries/integration/_abc.py
68
69
def __call__(self, tags: Iterable[str], /, **kwargs) -> None:
    super().__call__(tags, **kwargs)

__eq__ ¤

__eq__(other: Plugin) -> bool
Source code in src/liblaf/cherries/integration/_abc.py
40
41
42
43
def __eq__(self, other: "Plugin") -> bool:  # pyright: ignore[reportIncompatibleMethodOverride]
    if not isinstance(other, Plugin):
        return NotImplemented
    return self.priority == other.priority

__lt__ ¤

__lt__(other: Plugin) -> bool
Source code in src/liblaf/cherries/integration/_abc.py
35
36
37
38
def __lt__(self, other: "Plugin") -> bool:
    if not isinstance(other, Plugin):
        return NotImplemented
    return self.priority < other.priority

add ¤

add(*children: Plugin) -> None
Source code in src/liblaf/cherries/integration/_abc.py
49
50
51
def add(self, *children: "Plugin") -> None:
    for c in children:
        bisect.insort(self._children, c, key=operator.attrgetter("priority"))

extend ¤

extend(children: Iterable[Plugin]) -> None
Source code in src/liblaf/cherries/integration/_abc.py
53
54
def extend(self, children: Iterable["Plugin"]) -> None:
    self.add(*children)

remove ¤

remove(child: Plugin) -> None
Source code in src/liblaf/cherries/integration/_abc.py
56
57
def remove(self, child: "Plugin") -> None:
    self._children.remove(child)

AssetKind ¤

Bases: StrEnum

Attributes:

INPUT class-attribute instance-attribute ¤

INPUT = auto()

OUTPUT class-attribute instance-attribute ¤

OUTPUT = auto()

BaseConfig ¤

Bases: BaseSettings

Attributes:

model_config class-attribute instance-attribute ¤

model_config = SettingsConfigDict(cli_parse_args=True)

ConcreteImpl ¤

Bases: ImplDef

Parameters:

Attributes:

after class-attribute instance-attribute ¤

after: str | Sequence[str] = field(
    default=(), converter=as_seq
)

before class-attribute instance-attribute ¤

before: str | Sequence[str] = field(
    default=(), converter=as_seq
)

fn class-attribute instance-attribute ¤

fn: C = field(kw_only=True)

name instance-attribute ¤

name: str

plugin_name class-attribute instance-attribute ¤

plugin_name: str = field(kw_only=True)

priority class-attribute instance-attribute ¤

priority: int = 0

End ¤

Bases: Plugin

Parameters:

  • priority (int, default: 0 ) –
  • _children (list[str], 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.

Methods:

Attributes:

children property ¤

children: list[Plugin]

priority class-attribute instance-attribute ¤

priority: int = field(default=0, kw_only=True)

__attrs_post_init__ ¤

__attrs_post_init__() -> None
Source code in src/liblaf/cherries/integration/_abc.py
21
22
def __attrs_post_init__(self) -> None:
    self._children.sort(key=operator.attrgetter("priority"))

__call__ ¤

__call__(**kwargs) -> None
Source code in src/liblaf/cherries/integration/_abc.py
74
75
def __call__(self, **kwargs) -> None:
    super().__call__(**kwargs)

__eq__ ¤

__eq__(other: Plugin) -> bool
Source code in src/liblaf/cherries/integration/_abc.py
40
41
42
43
def __eq__(self, other: "Plugin") -> bool:  # pyright: ignore[reportIncompatibleMethodOverride]
    if not isinstance(other, Plugin):
        return NotImplemented
    return self.priority == other.priority

__lt__ ¤

__lt__(other: Plugin) -> bool
Source code in src/liblaf/cherries/integration/_abc.py
35
36
37
38
def __lt__(self, other: "Plugin") -> bool:
    if not isinstance(other, Plugin):
        return NotImplemented
    return self.priority < other.priority

add ¤

add(*children: Plugin) -> None
Source code in src/liblaf/cherries/integration/_abc.py
49
50
51
def add(self, *children: "Plugin") -> None:
    for c in children:
        bisect.insort(self._children, c, key=operator.attrgetter("priority"))

extend ¤

extend(children: Iterable[Plugin]) -> None
Source code in src/liblaf/cherries/integration/_abc.py
53
54
def extend(self, children: Iterable["Plugin"]) -> None:
    self.add(*children)

remove ¤

remove(child: Plugin) -> None
Source code in src/liblaf/cherries/integration/_abc.py
56
57
def remove(self, child: "Plugin") -> None:
    self._children.remove(child)

Experiment ¤

Attributes:

Methods:

add_tag class-attribute instance-attribute ¤

add_tag: AddTag = field(factory=AddTag, init=False)

add_tags class-attribute instance-attribute ¤

add_tags: AddTags = field(factory=AddTags, init=False)

comet property ¤

comet: CometExperiment

end class-attribute instance-attribute ¤

end: End = field(factory=End, init=False)

exp_dir cached property ¤

exp_dir: Path

exp_key property ¤

exp_key: str

exp_name property writable ¤

exp_name: str

exp_url property ¤

exp_url: str

log_asset class-attribute instance-attribute ¤

log_asset: LogAsset = field(factory=LogAsset, init=False)

log_code class-attribute instance-attribute ¤

log_code: LogCode = field(factory=LogCode, init=False)

log_metric class-attribute instance-attribute ¤

log_metric: LogMetric = field(factory=LogMetric, init=False)

log_metrics class-attribute instance-attribute ¤

log_metrics: LogMetrics = field(
    factory=LogMetrics, init=False
)

log_other class-attribute instance-attribute ¤

log_other: LogOther = field(factory=LogOther, init=False)

log_others class-attribute instance-attribute ¤

log_others: LogOthers = field(factory=LogOthers, init=False)

log_param class-attribute instance-attribute ¤

log_param: LogParam = field(factory=LogParam, init=False)

log_params class-attribute instance-attribute ¤

log_params: LogParams = field(factory=LogParams, init=False)

project_id property ¤

project_id: str

project_name property ¤

project_name: str

start class-attribute instance-attribute ¤

start: Start = field(factory=Start, init=False)

start_time cached property ¤

start_time: datetime

log_input ¤

log_input(path: PathLike, /, **kwargs) -> None
Source code in src/liblaf/cherries/integration/_exp.py
78
79
def log_input(self, path: PathLike, /, **kwargs) -> None:
    self.log_asset(path, prefix="inputs/", **kwargs)

log_output ¤

log_output(path: PathLike, /, **kwargs) -> None
Source code in src/liblaf/cherries/integration/_exp.py
81
82
def log_output(self, path: PathLike, /, **kwargs) -> None:
    self.log_asset(path, prefix="outputs/", **kwargs)

ImplDef ¤

Parameters:

Attributes:

after class-attribute instance-attribute ¤

after: str | Sequence[str] = field(
    default=(), converter=as_seq
)

before class-attribute instance-attribute ¤

before: str | Sequence[str] = field(
    default=(), converter=as_seq
)

name instance-attribute ¤

name: str

priority class-attribute instance-attribute ¤

priority: int = 0

LogAsset ¤

Bases: Plugin

Parameters:

  • priority (int, default: 0 ) –
  • _children (list[str], 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.

Methods:

Attributes:

children property ¤

children: list[Plugin]

priority class-attribute instance-attribute ¤

priority: int = field(default=0, kw_only=True)

__attrs_post_init__ ¤

__attrs_post_init__() -> None
Source code in src/liblaf/cherries/integration/_abc.py
21
22
def __attrs_post_init__(self) -> None:
    self._children.sort(key=operator.attrgetter("priority"))

__call__ ¤

__call__(
    path: PathLike, /, prefix: str | None = None, **kwargs
) -> None
Source code in src/liblaf/cherries/integration/_abc.py
80
81
def __call__(self, path: PathLike, /, prefix: str | None = None, **kwargs) -> None:
    super().__call__(path, prefix=prefix, **kwargs)

__eq__ ¤

__eq__(other: Plugin) -> bool
Source code in src/liblaf/cherries/integration/_abc.py
40
41
42
43
def __eq__(self, other: "Plugin") -> bool:  # pyright: ignore[reportIncompatibleMethodOverride]
    if not isinstance(other, Plugin):
        return NotImplemented
    return self.priority == other.priority

__lt__ ¤

__lt__(other: Plugin) -> bool
Source code in src/liblaf/cherries/integration/_abc.py
35
36
37
38
def __lt__(self, other: "Plugin") -> bool:
    if not isinstance(other, Plugin):
        return NotImplemented
    return self.priority < other.priority

add ¤

add(*children: Plugin) -> None
Source code in src/liblaf/cherries/integration/_abc.py
49
50
51
def add(self, *children: "Plugin") -> None:
    for c in children:
        bisect.insort(self._children, c, key=operator.attrgetter("priority"))

extend ¤

extend(children: Iterable[Plugin]) -> None
Source code in src/liblaf/cherries/integration/_abc.py
53
54
def extend(self, children: Iterable["Plugin"]) -> None:
    self.add(*children)

remove ¤

remove(child: Plugin) -> None
Source code in src/liblaf/cherries/integration/_abc.py
56
57
def remove(self, child: "Plugin") -> None:
    self._children.remove(child)

LogCode ¤

Bases: Plugin

Parameters:

  • priority (int, default: 0 ) –
  • _children (list[str], 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.

Methods:

Attributes:

children property ¤

children: list[Plugin]

priority class-attribute instance-attribute ¤

priority: int = field(default=0, kw_only=True)

__attrs_post_init__ ¤

__attrs_post_init__() -> None
Source code in src/liblaf/cherries/integration/_abc.py
21
22
def __attrs_post_init__(self) -> None:
    self._children.sort(key=operator.attrgetter("priority"))

__call__ ¤

__call__(path: PathLike, /, **kwargs) -> None
Source code in src/liblaf/cherries/integration/_abc.py
86
87
def __call__(self, path: PathLike, /, **kwargs) -> None:
    super().__call__(path, **kwargs)

__eq__ ¤

__eq__(other: Plugin) -> bool
Source code in src/liblaf/cherries/integration/_abc.py
40
41
42
43
def __eq__(self, other: "Plugin") -> bool:  # pyright: ignore[reportIncompatibleMethodOverride]
    if not isinstance(other, Plugin):
        return NotImplemented
    return self.priority == other.priority

__lt__ ¤

__lt__(other: Plugin) -> bool
Source code in src/liblaf/cherries/integration/_abc.py
35
36
37
38
def __lt__(self, other: "Plugin") -> bool:
    if not isinstance(other, Plugin):
        return NotImplemented
    return self.priority < other.priority

add ¤

add(*children: Plugin) -> None
Source code in src/liblaf/cherries/integration/_abc.py
49
50
51
def add(self, *children: "Plugin") -> None:
    for c in children:
        bisect.insort(self._children, c, key=operator.attrgetter("priority"))

extend ¤

extend(children: Iterable[Plugin]) -> None
Source code in src/liblaf/cherries/integration/_abc.py
53
54
def extend(self, children: Iterable["Plugin"]) -> None:
    self.add(*children)

remove ¤

remove(child: Plugin) -> None
Source code in src/liblaf/cherries/integration/_abc.py
56
57
def remove(self, child: "Plugin") -> None:
    self._children.remove(child)

LogMetric ¤

Bases: Plugin

Parameters:

  • priority (int, default: 0 ) –
  • _children (list[str], 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.

Methods:

Attributes:

children property ¤

children: list[Plugin]

priority class-attribute instance-attribute ¤

priority: int = field(default=0, kw_only=True)

__attrs_post_init__ ¤

__attrs_post_init__() -> None
Source code in src/liblaf/cherries/integration/_abc.py
21
22
def __attrs_post_init__(self) -> None:
    self._children.sort(key=operator.attrgetter("priority"))

__call__ ¤

__call__(
    key: str,
    value: float,
    /,
    step: int | None = None,
    epoch: int | None = None,
    **kwargs,
) -> None
Source code in src/liblaf/cherries/integration/_abc.py
 92
 93
 94
 95
 96
 97
 98
 99
100
101
def __call__(
    self,
    key: str,
    value: float,
    /,
    step: int | None = None,
    epoch: int | None = None,
    **kwargs,
) -> None:
    super().__call__(key, value, step=step, epoch=epoch, **kwargs)

__eq__ ¤

__eq__(other: Plugin) -> bool
Source code in src/liblaf/cherries/integration/_abc.py
40
41
42
43
def __eq__(self, other: "Plugin") -> bool:  # pyright: ignore[reportIncompatibleMethodOverride]
    if not isinstance(other, Plugin):
        return NotImplemented
    return self.priority == other.priority

__lt__ ¤

__lt__(other: Plugin) -> bool
Source code in src/liblaf/cherries/integration/_abc.py
35
36
37
38
def __lt__(self, other: "Plugin") -> bool:
    if not isinstance(other, Plugin):
        return NotImplemented
    return self.priority < other.priority

add ¤

add(*children: Plugin) -> None
Source code in src/liblaf/cherries/integration/_abc.py
49
50
51
def add(self, *children: "Plugin") -> None:
    for c in children:
        bisect.insort(self._children, c, key=operator.attrgetter("priority"))

extend ¤

extend(children: Iterable[Plugin]) -> None
Source code in src/liblaf/cherries/integration/_abc.py
53
54
def extend(self, children: Iterable["Plugin"]) -> None:
    self.add(*children)

remove ¤

remove(child: Plugin) -> None
Source code in src/liblaf/cherries/integration/_abc.py
56
57
def remove(self, child: "Plugin") -> None:
    self._children.remove(child)

LogMetrics ¤

Bases: Plugin

Parameters:

  • priority (int, default: 0 ) –
  • _children (list[str], 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.

Methods:

Attributes:

children property ¤

children: list[Plugin]

priority class-attribute instance-attribute ¤

priority: int = field(default=0, kw_only=True)

__attrs_post_init__ ¤

__attrs_post_init__() -> None
Source code in src/liblaf/cherries/integration/_abc.py
21
22
def __attrs_post_init__(self) -> None:
    self._children.sort(key=operator.attrgetter("priority"))

__call__ ¤

__call__(
    metrics: Mapping[str, Any],
    /,
    step: int | None = None,
    epoch: int | None = None,
    **kwargs,
) -> None
Source code in src/liblaf/cherries/integration/_abc.py
106
107
108
109
110
111
112
113
114
def __call__(
    self,
    metrics: Mapping[str, Any],
    /,
    step: int | None = None,
    epoch: int | None = None,
    **kwargs,
) -> None:
    super().__call__(metrics, step=step, epoch=epoch, **kwargs)

__eq__ ¤

__eq__(other: Plugin) -> bool
Source code in src/liblaf/cherries/integration/_abc.py
40
41
42
43
def __eq__(self, other: "Plugin") -> bool:  # pyright: ignore[reportIncompatibleMethodOverride]
    if not isinstance(other, Plugin):
        return NotImplemented
    return self.priority == other.priority

__lt__ ¤

__lt__(other: Plugin) -> bool
Source code in src/liblaf/cherries/integration/_abc.py
35
36
37
38
def __lt__(self, other: "Plugin") -> bool:
    if not isinstance(other, Plugin):
        return NotImplemented
    return self.priority < other.priority

add ¤

add(*children: Plugin) -> None
Source code in src/liblaf/cherries/integration/_abc.py
49
50
51
def add(self, *children: "Plugin") -> None:
    for c in children:
        bisect.insort(self._children, c, key=operator.attrgetter("priority"))

extend ¤

extend(children: Iterable[Plugin]) -> None
Source code in src/liblaf/cherries/integration/_abc.py
53
54
def extend(self, children: Iterable["Plugin"]) -> None:
    self.add(*children)

remove ¤

remove(child: Plugin) -> None
Source code in src/liblaf/cherries/integration/_abc.py
56
57
def remove(self, child: "Plugin") -> None:
    self._children.remove(child)

LogOther ¤

Bases: Plugin

Parameters:

  • priority (int, default: 0 ) –
  • _children (list[str], 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.

Methods:

Attributes:

children property ¤

children: list[Plugin]

priority class-attribute instance-attribute ¤

priority: int = field(default=0, kw_only=True)

__attrs_post_init__ ¤

__attrs_post_init__() -> None
Source code in src/liblaf/cherries/integration/_abc.py
21
22
def __attrs_post_init__(self) -> None:
    self._children.sort(key=operator.attrgetter("priority"))

__call__ ¤

__call__(key: str, value: Any, /, **kwargs) -> None
Source code in src/liblaf/cherries/integration/_abc.py
119
120
def __call__(self, key: str, value: Any, /, **kwargs) -> None:
    super().__call__(key, value, **kwargs)

__eq__ ¤

__eq__(other: Plugin) -> bool
Source code in src/liblaf/cherries/integration/_abc.py
40
41
42
43
def __eq__(self, other: "Plugin") -> bool:  # pyright: ignore[reportIncompatibleMethodOverride]
    if not isinstance(other, Plugin):
        return NotImplemented
    return self.priority == other.priority

__lt__ ¤

__lt__(other: Plugin) -> bool
Source code in src/liblaf/cherries/integration/_abc.py
35
36
37
38
def __lt__(self, other: "Plugin") -> bool:
    if not isinstance(other, Plugin):
        return NotImplemented
    return self.priority < other.priority

add ¤

add(*children: Plugin) -> None
Source code in src/liblaf/cherries/integration/_abc.py
49
50
51
def add(self, *children: "Plugin") -> None:
    for c in children:
        bisect.insort(self._children, c, key=operator.attrgetter("priority"))

extend ¤

extend(children: Iterable[Plugin]) -> None
Source code in src/liblaf/cherries/integration/_abc.py
53
54
def extend(self, children: Iterable["Plugin"]) -> None:
    self.add(*children)

remove ¤

remove(child: Plugin) -> None
Source code in src/liblaf/cherries/integration/_abc.py
56
57
def remove(self, child: "Plugin") -> None:
    self._children.remove(child)

LogOthers ¤

Bases: Plugin

Parameters:

  • priority (int, default: 0 ) –
  • _children (list[str], 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.

Methods:

Attributes:

children property ¤

children: list[Plugin]

priority class-attribute instance-attribute ¤

priority: int = field(default=0, kw_only=True)

__attrs_post_init__ ¤

__attrs_post_init__() -> None
Source code in src/liblaf/cherries/integration/_abc.py
21
22
def __attrs_post_init__(self) -> None:
    self._children.sort(key=operator.attrgetter("priority"))

__call__ ¤

__call__(others: Mapping[str, Any], /, **kwargs) -> None
Source code in src/liblaf/cherries/integration/_abc.py
125
126
def __call__(self, others: Mapping[str, Any], /, **kwargs) -> None:
    super().__call__(others, **kwargs)

__eq__ ¤

__eq__(other: Plugin) -> bool
Source code in src/liblaf/cherries/integration/_abc.py
40
41
42
43
def __eq__(self, other: "Plugin") -> bool:  # pyright: ignore[reportIncompatibleMethodOverride]
    if not isinstance(other, Plugin):
        return NotImplemented
    return self.priority == other.priority

__lt__ ¤

__lt__(other: Plugin) -> bool
Source code in src/liblaf/cherries/integration/_abc.py
35
36
37
38
def __lt__(self, other: "Plugin") -> bool:
    if not isinstance(other, Plugin):
        return NotImplemented
    return self.priority < other.priority

add ¤

add(*children: Plugin) -> None
Source code in src/liblaf/cherries/integration/_abc.py
49
50
51
def add(self, *children: "Plugin") -> None:
    for c in children:
        bisect.insort(self._children, c, key=operator.attrgetter("priority"))

extend ¤

extend(children: Iterable[Plugin]) -> None
Source code in src/liblaf/cherries/integration/_abc.py
53
54
def extend(self, children: Iterable["Plugin"]) -> None:
    self.add(*children)

remove ¤

remove(child: Plugin) -> None
Source code in src/liblaf/cherries/integration/_abc.py
56
57
def remove(self, child: "Plugin") -> None:
    self._children.remove(child)

LogParam ¤

Bases: Plugin

Parameters:

  • priority (int, default: 0 ) –
  • _children (list[str], 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.

Methods:

Attributes:

children property ¤

children: list[Plugin]

priority class-attribute instance-attribute ¤

priority: int = field(default=0, kw_only=True)

__attrs_post_init__ ¤

__attrs_post_init__() -> None
Source code in src/liblaf/cherries/integration/_abc.py
21
22
def __attrs_post_init__(self) -> None:
    self._children.sort(key=operator.attrgetter("priority"))

__call__ ¤

__call__(name: str, value: Any, /, **kwargs) -> None
Source code in src/liblaf/cherries/integration/_abc.py
131
132
def __call__(self, name: str, value: Any, /, **kwargs) -> None:
    super().__call__(name, value, **kwargs)

__eq__ ¤

__eq__(other: Plugin) -> bool
Source code in src/liblaf/cherries/integration/_abc.py
40
41
42
43
def __eq__(self, other: "Plugin") -> bool:  # pyright: ignore[reportIncompatibleMethodOverride]
    if not isinstance(other, Plugin):
        return NotImplemented
    return self.priority == other.priority

__lt__ ¤

__lt__(other: Plugin) -> bool
Source code in src/liblaf/cherries/integration/_abc.py
35
36
37
38
def __lt__(self, other: "Plugin") -> bool:
    if not isinstance(other, Plugin):
        return NotImplemented
    return self.priority < other.priority

add ¤

add(*children: Plugin) -> None
Source code in src/liblaf/cherries/integration/_abc.py
49
50
51
def add(self, *children: "Plugin") -> None:
    for c in children:
        bisect.insort(self._children, c, key=operator.attrgetter("priority"))

extend ¤

extend(children: Iterable[Plugin]) -> None
Source code in src/liblaf/cherries/integration/_abc.py
53
54
def extend(self, children: Iterable["Plugin"]) -> None:
    self.add(*children)

remove ¤

remove(child: Plugin) -> None
Source code in src/liblaf/cherries/integration/_abc.py
56
57
def remove(self, child: "Plugin") -> None:
    self._children.remove(child)

LogParams ¤

Bases: Plugin

Parameters:

  • priority (int, default: 0 ) –
  • _children (list[str], 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.

Methods:

Attributes:

children property ¤

children: list[Plugin]

priority class-attribute instance-attribute ¤

priority: int = field(default=0, kw_only=True)

__attrs_post_init__ ¤

__attrs_post_init__() -> None
Source code in src/liblaf/cherries/integration/_abc.py
21
22
def __attrs_post_init__(self) -> None:
    self._children.sort(key=operator.attrgetter("priority"))

__call__ ¤

__call__(params: Mapping[str, Any], /, **kwargs) -> None
Source code in src/liblaf/cherries/integration/_abc.py
137
138
def __call__(self, params: Mapping[str, Any], /, **kwargs) -> None:
    super().__call__(params, **kwargs)

__eq__ ¤

__eq__(other: Plugin) -> bool
Source code in src/liblaf/cherries/integration/_abc.py
40
41
42
43
def __eq__(self, other: "Plugin") -> bool:  # pyright: ignore[reportIncompatibleMethodOverride]
    if not isinstance(other, Plugin):
        return NotImplemented
    return self.priority == other.priority

__lt__ ¤

__lt__(other: Plugin) -> bool
Source code in src/liblaf/cherries/integration/_abc.py
35
36
37
38
def __lt__(self, other: "Plugin") -> bool:
    if not isinstance(other, Plugin):
        return NotImplemented
    return self.priority < other.priority

add ¤

add(*children: Plugin) -> None
Source code in src/liblaf/cherries/integration/_abc.py
49
50
51
def add(self, *children: "Plugin") -> None:
    for c in children:
        bisect.insort(self._children, c, key=operator.attrgetter("priority"))

extend ¤

extend(children: Iterable[Plugin]) -> None
Source code in src/liblaf/cherries/integration/_abc.py
53
54
def extend(self, children: Iterable["Plugin"]) -> None:
    self.add(*children)

remove ¤

remove(child: Plugin) -> None
Source code in src/liblaf/cherries/integration/_abc.py
56
57
def remove(self, child: "Plugin") -> None:
    self._children.remove(child)

MetaAsset ¤

MetaAsset(
    kind: AssetKind, extra: PathProvider | None = None
)

Methods:

Attributes:

Source code in src/liblaf/cherries/config/_asset.py
27
28
29
def __init__(self, kind: AssetKind, extra: PathProvider | None = None) -> None:
    self.kind = kind
    self._extra = extra

kind instance-attribute ¤

kind: AssetKind = kind

get_extra ¤

get_extra(value: Path) -> list[Path]
Source code in src/liblaf/cherries/config/_asset.py
31
32
33
34
35
36
37
38
def get_extra(self, value: Path) -> list[Path]:
    if self._extra is None:
        return []
    if callable(self._extra):
        extra: Iterable[PathLike] = grapes.as_iterable(self._extra(value))
        return [Path(p) for p in extra]
    extra: Iterable[PathLike] = grapes.as_iterable(self._extra)
    return [Path(p) for p in extra]

Plugin ¤

Parameters:

  • priority (int, default: 0 ) –
  • _children (list[str], 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.

Methods:

Attributes:

children property ¤

children: list[Plugin]

priority class-attribute instance-attribute ¤

priority: int = field(default=0, kw_only=True)

__attrs_post_init__ ¤

__attrs_post_init__() -> None
Source code in src/liblaf/cherries/integration/_abc.py
21
22
def __attrs_post_init__(self) -> None:
    self._children.sort(key=operator.attrgetter("priority"))

__call__ ¤

__call__(*args: args, **kwargs: kwargs) -> T
Source code in src/liblaf/cherries/integration/_abc.py
24
25
26
27
28
29
30
31
32
33
def __call__(self, *args: P.args, **kwargs: P.kwargs) -> T:
    ret: T | None = None
    for child in self._children:
        try:
            ret = child(*args, **kwargs)
        except BaseException as err:
            if isinstance(err, (KeyboardInterrupt, SystemExit)):
                raise
            logger.exception(child)
    return ret  # pyright: ignore[reportReturnType]

__eq__ ¤

__eq__(other: Plugin) -> bool
Source code in src/liblaf/cherries/integration/_abc.py
40
41
42
43
def __eq__(self, other: "Plugin") -> bool:  # pyright: ignore[reportIncompatibleMethodOverride]
    if not isinstance(other, Plugin):
        return NotImplemented
    return self.priority == other.priority

__lt__ ¤

__lt__(other: Plugin) -> bool
Source code in src/liblaf/cherries/integration/_abc.py
35
36
37
38
def __lt__(self, other: "Plugin") -> bool:
    if not isinstance(other, Plugin):
        return NotImplemented
    return self.priority < other.priority

add ¤

add(*children: Plugin) -> None
Source code in src/liblaf/cherries/integration/_abc.py
49
50
51
def add(self, *children: "Plugin") -> None:
    for c in children:
        bisect.insort(self._children, c, key=operator.attrgetter("priority"))

extend ¤

extend(children: Iterable[Plugin]) -> None
Source code in src/liblaf/cherries/integration/_abc.py
53
54
def extend(self, children: Iterable["Plugin"]) -> None:
    self.add(*children)

remove ¤

remove(child: Plugin) -> None
Source code in src/liblaf/cherries/integration/_abc.py
56
57
def remove(self, child: "Plugin") -> None:
    self._children.remove(child)

SpecDef ¤

Parameters:

  • name (str) –
  • firstresult (bool) –

Attributes:

firstresult instance-attribute ¤

firstresult: bool

name instance-attribute ¤

name: str

Start ¤

Bases: Plugin

Parameters:

  • priority (int, default: 0 ) –
  • _children (list[str], 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.

Methods:

Attributes:

children property ¤

children: list[Plugin]

priority class-attribute instance-attribute ¤

priority: int = field(default=0, kw_only=True)

__attrs_post_init__ ¤

__attrs_post_init__() -> None
Source code in src/liblaf/cherries/integration/_abc.py
21
22
def __attrs_post_init__(self) -> None:
    self._children.sort(key=operator.attrgetter("priority"))

__call__ ¤

__call__(**kwargs) -> None
Source code in src/liblaf/cherries/integration/_abc.py
143
144
def __call__(self, **kwargs) -> None:
    super().__call__(**kwargs)

__eq__ ¤

__eq__(other: Plugin) -> bool
Source code in src/liblaf/cherries/integration/_abc.py
40
41
42
43
def __eq__(self, other: "Plugin") -> bool:  # pyright: ignore[reportIncompatibleMethodOverride]
    if not isinstance(other, Plugin):
        return NotImplemented
    return self.priority == other.priority

__lt__ ¤

__lt__(other: Plugin) -> bool
Source code in src/liblaf/cherries/integration/_abc.py
35
36
37
38
def __lt__(self, other: "Plugin") -> bool:
    if not isinstance(other, Plugin):
        return NotImplemented
    return self.priority < other.priority

add ¤

add(*children: Plugin) -> None
Source code in src/liblaf/cherries/integration/_abc.py
49
50
51
def add(self, *children: "Plugin") -> None:
    for c in children:
        bisect.insort(self._children, c, key=operator.attrgetter("priority"))

extend ¤

extend(children: Iterable[Plugin]) -> None
Source code in src/liblaf/cherries/integration/_abc.py
53
54
def extend(self, children: Iterable["Plugin"]) -> None:
    self.add(*children)

remove ¤

remove(child: Plugin) -> None
Source code in src/liblaf/cherries/integration/_abc.py
56
57
def remove(self, child: "Plugin") -> None:
    self._children.remove(child)

as_os_path ¤

as_os_path(path: PathLike) -> str
as_os_path(path: None) -> None
as_os_path(path: PathLike | None) -> str | None
Source code in src/liblaf/cherries/pathutils/_convert.py
11
12
13
14
def as_os_path(path: PathLike | None) -> str | None:
    if path is None:
        return None
    return str(path)

as_path ¤

as_path(path: PathLike) -> Path
as_path(path: None) -> None
as_path(path: PathLike | None) -> Path | None
Source code in src/liblaf/cherries/pathutils/_convert.py
21
22
23
24
def as_path(path: PathLike | None) -> Path | None:
    if path is None:
        return None
    return Path(path)

as_posix ¤

as_posix(path: PathLike) -> str
as_posix(path: None) -> None
as_posix(path: PathLike | None) -> str | None
Source code in src/liblaf/cherries/pathutils/_convert.py
31
32
33
34
35
36
def as_posix(path: PathLike | None) -> str | None:
    if path is None:
        return None
    if isinstance(path, str):
        return path
    return Path(path).as_posix()

current_exp ¤

current_exp() -> Experiment
Source code in src/liblaf/cherries/integration/_exp.py
100
101
def current_exp() -> Experiment:
    return exp

data ¤

data(
    path: PathLike = "",
    *,
    mkdir: bool = True,
    prefix: PathLike = "data",
) -> Path
Source code in src/liblaf/cherries/pathutils/_special.py
14
15
def data(path: PathLike = "", *, mkdir: bool = True, prefix: PathLike = "data") -> Path:
    return _path(path, mkdir=mkdir, prefix=prefix)

end ¤

end() -> None
Source code in src/liblaf/cherries/_run.py
50
51
def end() -> None:
    integration.exp.end()

entrypoint ¤

entrypoint(*, absolute: bool = False) -> Path
Source code in src/liblaf/cherries/pathutils/_path.py
11
12
13
14
15
@utils.cache
def entrypoint(*, absolute: bool = False) -> Path:
    if absolute:
        return _entrypoint_absolute()
    return _entrypoint_relative()

exp_dir ¤

exp_dir(*, absolute: bool = False) -> Path
Source code in src/liblaf/cherries/pathutils/_path.py
34
35
36
37
38
@utils.cache
def exp_dir(*, absolute: bool = False) -> Path:
    if absolute:
        return _exp_dir_absolute()
    return _exp_dir_relative()

get_assets ¤

get_assets(cfg: BaseModel, kind: AssetKind) -> list[Path]
Source code in src/liblaf/cherries/config/_asset.py
41
42
43
44
45
46
47
48
49
50
51
52
def get_assets(cfg: pydantic.BaseModel, kind: AssetKind) -> list[Path]:
    assets: list[Path] = []
    for name, info in type(cfg).model_fields.items():
        value: Any = getattr(cfg, name)
        if isinstance(value, pydantic.BaseModel):
            assets.extend(get_assets(value, kind))
        for meta in info.metadata:
            if isinstance(meta, MetaAsset) and meta.kind == kind:
                value: Path = Path(value)
                assets.append(value)
                assets.extend(meta.get_extra(value))
    return assets

get_inputs ¤

get_inputs(cfg: BaseModel) -> list[Path]
Source code in src/liblaf/cherries/config/_asset.py
55
56
def get_inputs(cfg: pydantic.BaseModel) -> list[Path]:
    return get_assets(cfg, AssetKind.INPUT)

get_outputs ¤

get_outputs(cfg: BaseModel) -> list[Path]
Source code in src/liblaf/cherries/config/_asset.py
59
60
def get_outputs(cfg: pydantic.BaseModel) -> list[Path]:
    return get_assets(cfg, AssetKind.OUTPUT)

git_root ¤

git_root() -> Path
Source code in src/liblaf/cherries/pathutils/_path.py
18
19
20
21
22
@utils.cache
def git_root() -> Path:
    entrypoint: Path = _entrypoint_absolute()
    repo = git.Repo(entrypoint, search_parent_directories=True)
    return Path(repo.working_dir)

git_root_safe ¤

git_root_safe() -> Path
Source code in src/liblaf/cherries/pathutils/_path.py
25
26
27
28
29
30
31
@utils.cache
def git_root_safe() -> Path:
    try:
        return git_root()
    except git.exc.InvalidGitRepositoryError:
        logger.warning("Not in a git repository, using current directory")
        return _entrypoint_absolute().parent

impl ¤

impl(
    *,
    name: str,
    after: str | Sequence[str] = (),
    before: str | Sequence[str] = (),
    priority: int = 0,
) -> Decorator
impl(
    fn: C,
    /,
    *,
    name: str,
    after: str | Sequence[str] = (),
    before: str | Sequence[str] = (),
    priority: int = 0,
) -> C
impl(
    fn: Callable | None = None,
    /,
    *,
    name: str,
    after: str | Sequence[str] = (),
    before: str | Sequence[str] = (),
    priority: int = 0,
) -> Decorator | Callable
Source code in src/liblaf/cherries/core/_spec.py
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
def impl(
    fn: Callable | None = None,
    /,
    *,
    name: str,
    after: str | Sequence[str] = (),
    before: str | Sequence[str] = (),
    priority: int = 0,
) -> Decorator | Callable:
    if fn is None:
        return functools.partial(
            impl, name=name, after=after, before=before, priority=priority
        )
    fn.impl = ImplDef(name=name, after=after, before=before, priority=priority)  # pyright: ignore[reportFunctionMemberAccess]
    return override(fn)

input ¤

input(
    path: PathLike,
    extra: PathProvider | None = None,
    **kwargs,
) -> Path
Source code in src/liblaf/cherries/config/_asset.py
63
64
65
66
def input(path: PathLike, extra: PathProvider | None = None, **kwargs) -> Path:  # noqa: A001
    field_info: pydantic.fields.FieldInfo = pydantic.Field(_path.data(path), **kwargs)  # pyright: ignore[reportAssignmentType]
    field_info.metadata.append(MetaAsset(kind=AssetKind.INPUT, extra=extra))
    return field_info  # pyright: ignore[reportReturnType]

inputs ¤

inputs(
    path: PathLike = "",
    *,
    mkdir: bool = True,
    prefix: PathLike = "data/inputs",
) -> Path
Source code in src/liblaf/cherries/pathutils/_special.py
18
19
20
21
def inputs(
    path: PathLike = "", *, mkdir: bool = True, prefix: PathLike = "data/inputs"
) -> Path:
    return _path(path, mkdir=mkdir, prefix=prefix)

log_input ¤

log_input(path: PathLike, /, **kwargs) -> None
Source code in src/liblaf/cherries/integration/_exp.py
104
105
def log_input(path: PathLike, /, **kwargs) -> None:
    exp.log_input(path, **kwargs)

log_output ¤

log_output(path: PathLike, /, **kwargs) -> None
Source code in src/liblaf/cherries/integration/_exp.py
108
109
def log_output(path: PathLike, /, **kwargs) -> None:
    exp.log_output(path, **kwargs)

output ¤

output(
    path: PathLike,
    extra: PathProvider | None = None,
    **kwargs,
) -> Path
Source code in src/liblaf/cherries/config/_asset.py
69
70
71
72
def output(path: PathLike, extra: PathProvider | None = None, **kwargs) -> Path:
    field_info: pydantic.fields.FieldInfo = pydantic.Field(_path.data(path), **kwargs)  # pyright: ignore[reportAssignmentType]
    field_info.metadata.append(MetaAsset(kind=AssetKind.OUTPUT, extra=extra))
    return field_info  # pyright: ignore[reportReturnType]

outputs ¤

outputs(
    path: PathLike = "",
    *,
    mkdir: bool = True,
    prefix: PathLike = "data/outputs",
) -> Path
Source code in src/liblaf/cherries/pathutils/_special.py
24
25
26
27
def outputs(
    path: PathLike = "", *, mkdir: bool = True, prefix: PathLike = "data/outputs"
) -> Path:
    return _path(path, mkdir=mkdir, prefix=prefix)

params ¤

params(
    path: PathLike = "",
    *,
    mkdir: bool = True,
    prefix: PathLike = "params",
) -> Path
Source code in src/liblaf/cherries/pathutils/_special.py
30
31
32
33
def params(
    path: PathLike = "", *, mkdir: bool = True, prefix: PathLike = "params"
) -> Path:
    return _path(path, mkdir=mkdir, prefix=prefix)

path ¤

path(
    path: PathLike = "",
    *,
    mkdir: bool = True,
    prefix: PathLike = "",
) -> Path
Source code in src/liblaf/cherries/pathutils/_special.py
36
37
def path(path: PathLike = "", *, mkdir: bool = True, prefix: PathLike = "") -> Path:
    return _path(path, mkdir=mkdir, prefix=prefix)

run ¤

run(
    main: Callable[[], T] | Callable[[C], T],
    *,
    play: bool = False,
    preset: Preset = default,
) -> T
Source code in src/liblaf/cherries/_run.py
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
def run[C: pydantic.BaseModel, T](
    main: Callable[[], T] | Callable[[C], T],
    *,
    play: bool = False,
    preset: presets.Preset = presets.default,
) -> T:
    exp: integration.Experiment = start(preset=preset, play=play)
    type_hints: dict[str, type[C]] = get_type_hints(main)
    del type_hints["return"]
    args: list[C] = []
    if len(type_hints) == 1:
        cls: type[C] = next(iter(type_hints.values()))
        cfg: C = cls()
        args.append(cfg)
        for path in config.get_inputs(cfg):
            exp.log_input(path)
    try:
        result: T = main(*args)
    finally:
        if len(type_hints) == 1:
            cfg: C = args[0]
            for path in config.get_outputs(cfg):
                exp.log_output(path)
        exp.end()
    return result

spec ¤

spec(*, firstresult: bool = False) -> Decorator
spec(fn: C, /, *, firstresult: bool = False) -> C
spec(
    fn: Callable | None = None,
    /,
    *,
    firstresult: bool = False,
) -> Decorator | Callable
Source code in src/liblaf/cherries/core/_spec.py
131
132
133
134
135
136
137
138
139
140
141
142
def spec(
    fn: Callable | None = None, /, *, firstresult: bool = False
) -> Decorator | Callable:
    if fn is None:
        return functools.partial(spec, firstresult=firstresult)

    @functools.wraps(fn)
    def wrapper(self: Plugin, *args, **kwargs) -> Any:
        return self.call(wrapper.spec, *args, **kwargs)  # pyright: ignore[reportAttributeAccessIssue]

    wrapper.spec = SpecDef(name=fn.__name__, firstresult=firstresult)  # pyright: ignore[reportAttributeAccessIssue]
    return wrapper

src ¤

src(
    path: PathLike = "",
    *,
    mkdir: bool = True,
    prefix: PathLike = "src",
) -> Path
Source code in src/liblaf/cherries/pathutils/_special.py
40
41
def src(path: PathLike = "", *, mkdir: bool = True, prefix: PathLike = "src") -> Path:
    return _path(path, mkdir=mkdir, prefix=prefix)

start ¤

start(
    preset: Preset = default, *, play: bool = False
) -> Experiment
Source code in src/liblaf/cherries/_run.py
37
38
39
40
41
42
43
44
45
46
47
def start(
    preset: presets.Preset = presets.default, *, play: bool = False
) -> integration.Experiment:
    if play:
        preset = presets.playground
    exp: integration.Experiment = preset(integration.exp)
    exp.start()
    exp.log_other("cherries.entrypoint", _path.entrypoint(absolute=False))
    exp.log_other("cherries.exp-dir", _path.exp_dir(absolute=False))
    exp.log_other("cherries.start-time", exp.start_time)
    return exp