liblaf-cherries 0.0.11__tar.gz → 0.0.12__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. {liblaf_cherries-0.0.11 → liblaf_cherries-0.0.12}/PKG-INFO +1 -1
  2. {liblaf_cherries-0.0.11 → liblaf_cherries-0.0.12}/src/liblaf/cherries/__init__.pyi +2 -0
  3. {liblaf_cherries-0.0.11 → liblaf_cherries-0.0.12}/src/liblaf/cherries/_run.py +11 -3
  4. {liblaf_cherries-0.0.11 → liblaf_cherries-0.0.12}/src/liblaf/cherries/_version.py +2 -2
  5. {liblaf_cherries-0.0.11 → liblaf_cherries-0.0.12}/src/liblaf/cherries/plugin/__init__.pyi +2 -0
  6. {liblaf_cherries-0.0.11 → liblaf_cherries-0.0.12}/src/liblaf/cherries/plugin/_abc.py +11 -2
  7. {liblaf_cherries-0.0.11 → liblaf_cherries-0.0.12}/src/liblaf/cherries/plugin/_dvc.py +2 -2
  8. {liblaf_cherries-0.0.11 → liblaf_cherries-0.0.12}/src/liblaf/cherries/plugin/_git.py +2 -2
  9. {liblaf_cherries-0.0.11 → liblaf_cherries-0.0.12}/src/liblaf/cherries/plugin/_logging.py +2 -2
  10. {liblaf_cherries-0.0.11 → liblaf_cherries-0.0.12}/src/liblaf/cherries/plugin/_mlflow.py +13 -3
  11. {liblaf_cherries-0.0.11 → liblaf_cherries-0.0.12}/.gitignore +0 -0
  12. {liblaf_cherries-0.0.11 → liblaf_cherries-0.0.12}/LICENSE +0 -0
  13. {liblaf_cherries-0.0.11 → liblaf_cherries-0.0.12}/docs/README.md +0 -0
  14. {liblaf_cherries-0.0.11 → liblaf_cherries-0.0.12}/pyproject.toml +0 -0
  15. {liblaf_cherries-0.0.11 → liblaf_cherries-0.0.12}/src/liblaf/cherries/__init__.py +0 -0
  16. {liblaf_cherries-0.0.11 → liblaf_cherries-0.0.12}/src/liblaf/cherries/_config.py +0 -0
  17. {liblaf_cherries-0.0.11 → liblaf_cherries-0.0.12}/src/liblaf/cherries/_version.pyi +0 -0
  18. {liblaf_cherries-0.0.11 → liblaf_cherries-0.0.12}/src/liblaf/cherries/info/__init__.py +0 -0
  19. {liblaf_cherries-0.0.11 → liblaf_cherries-0.0.12}/src/liblaf/cherries/info/__init__.pyi +0 -0
  20. {liblaf_cherries-0.0.11 → liblaf_cherries-0.0.12}/src/liblaf/cherries/info/_exp_name.py +0 -0
  21. {liblaf_cherries-0.0.11 → liblaf_cherries-0.0.12}/src/liblaf/cherries/info/_git.py +0 -0
  22. {liblaf_cherries-0.0.11 → liblaf_cherries-0.0.12}/src/liblaf/cherries/pathutils/__init__.py +0 -0
  23. {liblaf_cherries-0.0.11 → liblaf_cherries-0.0.12}/src/liblaf/cherries/pathutils/__init__.pyi +0 -0
  24. {liblaf_cherries-0.0.11 → liblaf_cherries-0.0.12}/src/liblaf/cherries/pathutils/_convert.py +0 -0
  25. {liblaf_cherries-0.0.11 → liblaf_cherries-0.0.12}/src/liblaf/cherries/pathutils/_path.py +0 -0
  26. {liblaf_cherries-0.0.11 → liblaf_cherries-0.0.12}/src/liblaf/cherries/pathutils/_special.py +0 -0
  27. {liblaf_cherries-0.0.11 → liblaf_cherries-0.0.12}/src/liblaf/cherries/plugin/__init__.py +0 -0
  28. {liblaf_cherries-0.0.11 → liblaf_cherries-0.0.12}/src/liblaf/cherries/plugin/_run.py +0 -0
  29. {liblaf_cherries-0.0.11 → liblaf_cherries-0.0.12}/src/liblaf/cherries/presets/__init__.py +0 -0
  30. {liblaf_cherries-0.0.11 → liblaf_cherries-0.0.12}/src/liblaf/cherries/presets/__init__.pyi +0 -0
  31. {liblaf_cherries-0.0.11 → liblaf_cherries-0.0.12}/src/liblaf/cherries/presets/_default.py +0 -0
  32. {liblaf_cherries-0.0.11 → liblaf_cherries-0.0.12}/src/liblaf/cherries/py.typed +0 -0
  33. {liblaf_cherries-0.0.11 → liblaf_cherries-0.0.12}/src/liblaf/cherries/typed.py +0 -0
  34. {liblaf_cherries-0.0.11 → liblaf_cherries-0.0.12}/src/liblaf/cherries/utils/__init__.py +0 -0
  35. {liblaf_cherries-0.0.11 → liblaf_cherries-0.0.12}/src/liblaf/cherries/utils/__init__.pyi +0 -0
  36. {liblaf_cherries-0.0.11 → liblaf_cherries-0.0.12}/src/liblaf/cherries/utils/_functools.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: liblaf-cherries
3
- Version: 0.0.11
3
+ Version: 0.0.12
4
4
  Summary: Add your description here
5
5
  Project-URL: Changelog, https://github.com/liblaf/cherries/blob/main/CHANGELOG.md
6
6
  Project-URL: Documentation, https://liblaf.github.io/cherries/
@@ -27,6 +27,7 @@ from .plugin import (
27
27
  LogParam,
28
28
  Plugin,
29
29
  Run,
30
+ RunStatus,
30
31
  Start,
31
32
  log_artifact,
32
33
  log_artifacts,
@@ -51,6 +52,7 @@ __all__ = [
51
52
  "LoggingStart",
52
53
  "Plugin",
53
54
  "Run",
55
+ "RunStatus",
54
56
  "Start",
55
57
  "as_os_path",
56
58
  "as_path",
@@ -13,9 +13,17 @@ def run[C: pydantic.BaseModel, T](main: Callable[[C], T]) -> T:
13
13
  cls: type[C] = next(iter(type_hints.values()))
14
14
  cfg: C = cls()
15
15
  run.log_param("cherries.config", cfg.model_dump(mode="json"))
16
- ret: T = main(cfg)
17
- run.end()
18
- return ret
16
+ try:
17
+ ret: T = main(cfg)
18
+ except BaseException as e:
19
+ if isinstance(e, KeyboardInterrupt):
20
+ run.end("KILLED")
21
+ raise
22
+ run.end("FAILED")
23
+ raise
24
+ else:
25
+ run.end()
26
+ return ret
19
27
 
20
28
 
21
29
  def start() -> plugin.Run:
@@ -17,5 +17,5 @@ __version__: str
17
17
  __version_tuple__: VERSION_TUPLE
18
18
  version_tuple: VERSION_TUPLE
19
19
 
20
- __version__ = version = '0.0.11'
21
- __version_tuple__ = version_tuple = (0, 0, 11)
20
+ __version__ = version = '0.0.12'
21
+ __version_tuple__ = version_tuple = (0, 0, 12)
@@ -5,6 +5,7 @@ from ._abc import (
5
5
  LogMetric,
6
6
  LogParam,
7
7
  Plugin,
8
+ RunStatus,
8
9
  Start,
9
10
  )
10
11
  from ._dvc import DvcEnd, DvcLogArtifact, DvcLogArtifacts
@@ -58,6 +59,7 @@ __all__ = [
58
59
  "MlflowStart",
59
60
  "Plugin",
60
61
  "Run",
62
+ "RunStatus",
61
63
  "Start",
62
64
  "end",
63
65
  "log_artifact",
@@ -1,6 +1,7 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import bisect
4
+ import enum
4
5
  import functools
5
6
  import operator
6
7
  from collections.abc import Iterable
@@ -8,12 +9,20 @@ from pathlib import Path
8
9
  from typing import Any, override
9
10
 
10
11
  import attrs
12
+ import mlflow
13
+ import mlflow.entities
11
14
  from loguru import logger
12
15
 
13
16
  from liblaf.cherries import pathutils as _path
14
17
  from liblaf.cherries.typed import PathLike
15
18
 
16
19
 
20
+ class RunStatus(enum.StrEnum):
21
+ FAILED = mlflow.entities.RunStatus.to_string(mlflow.entities.RunStatus.FAILED)
22
+ FINISHED = mlflow.entities.RunStatus.to_string(mlflow.entities.RunStatus.FINISHED)
23
+ KILLED = mlflow.entities.RunStatus.to_string(mlflow.entities.RunStatus.KILLED)
24
+
25
+
17
26
  @functools.total_ordering
18
27
  @attrs.define
19
28
  class Plugin[**P, T]:
@@ -64,8 +73,8 @@ class Plugin[**P, T]:
64
73
  @attrs.define
65
74
  class End(Plugin):
66
75
  @override
67
- def __call__(self) -> None:
68
- return super().__call__()
76
+ def __call__(self, status: RunStatus = RunStatus.FINISHED) -> None:
77
+ return super().__call__(status)
69
78
 
70
79
 
71
80
  @attrs.define
@@ -7,13 +7,13 @@ import attrs
7
7
  from liblaf.cherries import pathutils as _path
8
8
  from liblaf.cherries.typed import PathLike
9
9
 
10
- from ._abc import End, LogArtifact, LogArtifacts
10
+ from ._abc import End, LogArtifact, LogArtifacts, RunStatus
11
11
 
12
12
 
13
13
  @attrs.define
14
14
  class DvcEnd(End):
15
15
  @override
16
- def __call__(self) -> None:
16
+ def __call__(self, status: RunStatus = RunStatus.FINISHED) -> None:
17
17
  sp.run(["dvc", "status"], check=True)
18
18
  sp.run(["dvc", "push"], check=True)
19
19
 
@@ -5,7 +5,7 @@ from environs import env
5
5
 
6
6
  from liblaf.cherries import info as _info
7
7
 
8
- from ._abc import End, Start
8
+ from ._abc import End, RunStatus, Start
9
9
  from ._run import run
10
10
 
11
11
 
@@ -14,7 +14,7 @@ class GitEnd(End):
14
14
  dry_run: bool = env.bool("LIBLAF_CHERRIES_GIT_DRY_RUN", default=False)
15
15
 
16
16
  @override
17
- def __call__(self) -> None:
17
+ def __call__(self, status: RunStatus = RunStatus.FINISHED) -> None:
18
18
  git_auto_commit(
19
19
  "chore(cherries): auto commit (on run end)", dry_run=self.dry_run
20
20
  )
@@ -5,14 +5,14 @@ from loguru import logger
5
5
 
6
6
  from liblaf import grapes
7
7
 
8
- from ._abc import End, Start
8
+ from ._abc import End, RunStatus, Start
9
9
  from ._run import run
10
10
 
11
11
 
12
12
  @attrs.define
13
13
  class LoggingEnd(End):
14
14
  @override
15
- def __call__(self) -> None:
15
+ def __call__(self, status: RunStatus = RunStatus.FINISHED) -> None:
16
16
  logger.complete()
17
17
  run.log_artifact(run.exp_dir / "run.log")
18
18
  run.log_artifact(run.exp_dir / "run.log.jsonl")
@@ -3,19 +3,29 @@ from typing import Any, override
3
3
 
4
4
  import attrs
5
5
  import mlflow
6
+ import mlflow.entities
6
7
 
7
8
  from liblaf.cherries import info as _info
8
9
  from liblaf.cherries import pathutils as _path
9
10
  from liblaf.cherries.typed import PathLike
10
11
 
11
- from ._abc import End, LogArtifact, LogArtifacts, LogMetric, LogParam, SetTag, Start
12
+ from ._abc import (
13
+ End,
14
+ LogArtifact,
15
+ LogArtifacts,
16
+ LogMetric,
17
+ LogParam,
18
+ RunStatus,
19
+ SetTag,
20
+ Start,
21
+ )
12
22
 
13
23
 
14
24
  @attrs.define
15
25
  class MlflowEnd(End):
16
26
  @override
17
- def __call__(self) -> None:
18
- mlflow.end_run()
27
+ def __call__(self, status: RunStatus = RunStatus.FINISHED) -> None:
28
+ mlflow.end_run(status)
19
29
 
20
30
 
21
31
  @attrs.define