liblaf-cherries 0.0.11__py3-none-any.whl → 0.0.12__py3-none-any.whl

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.
@@ -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",
liblaf/cherries/_run.py CHANGED
@@ -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
@@ -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/
@@ -1,8 +1,8 @@
1
1
  liblaf/cherries/__init__.py,sha256=OHb6Xou2v6u42swTgjRfzej4CIlRg4OmgOIQXUiRjKA,97
2
- liblaf/cherries/__init__.pyi,sha256=F3-WoAFWZ5Kl4DnUcVIuSRFraHF_EWEhcaVBWnuBiXo,1338
2
+ liblaf/cherries/__init__.pyi,sha256=SuZgWY0gRNMTU-rAapdJ5mCHyYqeQmlR9DosaViUx1A,1370
3
3
  liblaf/cherries/_config.py,sha256=rm-Y6roi8hBvQYdH-VQh_ovWCyVsX_7R0x1jokBPCDM,741
4
- liblaf/cherries/_run.py,sha256=NyrhAbOAEu01Xo5Rxyo19PMcwxrCQGj0hbxt1eSnjPE,860
5
- liblaf/cherries/_version.py,sha256=rk0lhpp6Em5toAI4J7GwApfOdY7w_QTcFpJpUR4GdVY,513
4
+ liblaf/cherries/_run.py,sha256=aJonztFyqBeg9otqMGwkh2AOEjtFh85sC1riBa1ty38,1055
5
+ liblaf/cherries/_version.py,sha256=yXPCLHqHWroxl6PYku74xz7jqX7Xrf288eRJfEDWwBo,513
6
6
  liblaf/cherries/_version.pyi,sha256=Pnv4Bxw13LHeuVkPLPsTtnp4N4jOGcAfFJw05uMMgBY,108
7
7
  liblaf/cherries/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
8
  liblaf/cherries/typed.py,sha256=mim8QVtwczTSHyw5mhEdfFcXis9o32n0CZyu8BrEorE,50
@@ -16,12 +16,12 @@ liblaf/cherries/pathutils/_convert.py,sha256=JTO9vETXvj7f4GTtIbOmAoDNEDc_4hoEHZ7
16
16
  liblaf/cherries/pathutils/_path.py,sha256=igdLrCqk6aIX36V8c1LClhrFViDFWx4WbiR67BcbVIY,1548
17
17
  liblaf/cherries/pathutils/_special.py,sha256=b5D3PtW__u0Zpiv69OYoV7TTYc6Dgs4Bu-P8jwrROV4,1415
18
18
  liblaf/cherries/plugin/__init__.py,sha256=OHb6Xou2v6u42swTgjRfzej4CIlRg4OmgOIQXUiRjKA,97
19
- liblaf/cherries/plugin/__init__.pyi,sha256=GH1Hh8uvHdQmne0mJ4OJIM1RhxZAxmlaJ9PVyYO7lw0,1267
20
- liblaf/cherries/plugin/_abc.py,sha256=Y2IZTd7NPOFl5dv-DeX7H3LE7u4R0Utv9S8ho3pCJGA,3367
21
- liblaf/cherries/plugin/_dvc.py,sha256=Bl6SoZHDcOu86ybu9uPl-Zk3ezBcaAiW0tTPVuj2-5c,1226
22
- liblaf/cherries/plugin/_git.py,sha256=87gLkIsOc6_fO7RcNdwsXVzl1FCMzhDSkxeaMZwwXXM,1345
23
- liblaf/cherries/plugin/_logging.py,sha256=snCmJa1qTtNsJ5GzTkejgcO4ySWA0m0sMH8qY4w08ww,728
24
- liblaf/cherries/plugin/_mlflow.py,sha256=HlTat251ogGJBvxvw_-ZjDtCEsFtcDhofrjRfJIV2qY,1833
19
+ liblaf/cherries/plugin/__init__.pyi,sha256=2PPdTp-vfgP34sKGnjCR1oMG5ljTmkZkabr_LV74tXA,1299
20
+ liblaf/cherries/plugin/_abc.py,sha256=H-NH6Gpv3dTJKjaekuAKSn_H0TJPxF-TLa5UU51NNjg,3748
21
+ liblaf/cherries/plugin/_dvc.py,sha256=xmMhgZ8QTT-G15_BfpGzYqHjAa7NvspUkuKJvpIinfs,1277
22
+ liblaf/cherries/plugin/_git.py,sha256=AY6AugwyqtcCAaX475zDINFHgHG1UKupWplquEPbjWU,1396
23
+ liblaf/cherries/plugin/_logging.py,sha256=6ZlPQMSv1QmovjOPL6VMmJJOyufU1KCN1W7lOvkGcZs,779
24
+ liblaf/cherries/plugin/_mlflow.py,sha256=1AV_jIUgs2EYZU-7_e0EtkgYN3cBPS2Yjrs5AUu5v1Y,1950
25
25
  liblaf/cherries/plugin/_run.py,sha256=XqMOEFDqba8xOaUIynJwS1Dg6JGVpqtWsHG_XJenypk,3287
26
26
  liblaf/cherries/presets/__init__.py,sha256=OHb6Xou2v6u42swTgjRfzej4CIlRg4OmgOIQXUiRjKA,97
27
27
  liblaf/cherries/presets/__init__.pyi,sha256=ka0zjVDb1kWn1VuDGjAzMX5S9sVKKYcxKelp4EwUBf8,53
@@ -29,7 +29,7 @@ liblaf/cherries/presets/_default.py,sha256=hhe10JzMui8WJhvoLlOfDCHMRlPmdnzRSduFH
29
29
  liblaf/cherries/utils/__init__.py,sha256=OHb6Xou2v6u42swTgjRfzej4CIlRg4OmgOIQXUiRjKA,97
30
30
  liblaf/cherries/utils/__init__.pyi,sha256=F5aTcXpWVmUoctPbLfmQXKyuXYRspAIjaIzfL1_3Lrw,51
31
31
  liblaf/cherries/utils/_functools.py,sha256=0Puwvj1Wq4kp3S--hI-CXwUBZ56AtfkqIzFHllQtuug,181
32
- liblaf_cherries-0.0.11.dist-info/METADATA,sha256=Fno2MjAvm3-xeK5BLh8S5hicRp3mtX_YTDG337ykay4,1944
33
- liblaf_cherries-0.0.11.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
34
- liblaf_cherries-0.0.11.dist-info/licenses/LICENSE,sha256=Ph4NzyU3lGVDeYv-mf8aRmImH8v9rVL9F362FV4G6Ow,1063
35
- liblaf_cherries-0.0.11.dist-info/RECORD,,
32
+ liblaf_cherries-0.0.12.dist-info/METADATA,sha256=EznK6Za_uBu_9awxVrZzzkpR2DVzMZdpIWry4H5x5RY,1944
33
+ liblaf_cherries-0.0.12.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
34
+ liblaf_cherries-0.0.12.dist-info/licenses/LICENSE,sha256=Ph4NzyU3lGVDeYv-mf8aRmImH8v9rVL9F362FV4G6Ow,1063
35
+ liblaf_cherries-0.0.12.dist-info/RECORD,,