liblaf-cherries 0.0.12__tar.gz → 0.0.14__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.
- {liblaf_cherries-0.0.12 → liblaf_cherries-0.0.14}/PKG-INFO +2 -2
- {liblaf_cherries-0.0.12 → liblaf_cherries-0.0.14}/pyproject.toml +1 -2
- {liblaf_cherries-0.0.12 → liblaf_cherries-0.0.14}/src/liblaf/cherries/__init__.pyi +2 -2
- {liblaf_cherries-0.0.12 → liblaf_cherries-0.0.14}/src/liblaf/cherries/_run.py +3 -3
- {liblaf_cherries-0.0.12 → liblaf_cherries-0.0.14}/src/liblaf/cherries/_version.py +2 -2
- {liblaf_cherries-0.0.12 → liblaf_cherries-0.0.14}/src/liblaf/cherries/info/__init__.pyi +2 -1
- liblaf_cherries-0.0.12/src/liblaf/cherries/info/_exp_name.py → liblaf_cherries-0.0.14/src/liblaf/cherries/info/_name.py +11 -0
- {liblaf_cherries-0.0.12 → liblaf_cherries-0.0.14}/src/liblaf/cherries/pathutils/__init__.pyi +2 -2
- {liblaf_cherries-0.0.12 → liblaf_cherries-0.0.14}/src/liblaf/cherries/pathutils/_path.py +10 -10
- {liblaf_cherries-0.0.12 → liblaf_cherries-0.0.14}/src/liblaf/cherries/pathutils/_special.py +2 -2
- {liblaf_cherries-0.0.12 → liblaf_cherries-0.0.14}/src/liblaf/cherries/plugin/_dvc.py +18 -2
- {liblaf_cherries-0.0.12 → liblaf_cherries-0.0.14}/src/liblaf/cherries/plugin/_logging.py +2 -2
- {liblaf_cherries-0.0.12 → liblaf_cherries-0.0.14}/src/liblaf/cherries/plugin/_mlflow.py +7 -2
- {liblaf_cherries-0.0.12 → liblaf_cherries-0.0.14}/src/liblaf/cherries/plugin/_run.py +1 -1
- {liblaf_cherries-0.0.12 → liblaf_cherries-0.0.14}/.gitignore +0 -0
- {liblaf_cherries-0.0.12 → liblaf_cherries-0.0.14}/LICENSE +0 -0
- {liblaf_cherries-0.0.12 → liblaf_cherries-0.0.14}/docs/README.md +0 -0
- {liblaf_cherries-0.0.12 → liblaf_cherries-0.0.14}/src/liblaf/cherries/__init__.py +0 -0
- {liblaf_cherries-0.0.12 → liblaf_cherries-0.0.14}/src/liblaf/cherries/_config.py +0 -0
- {liblaf_cherries-0.0.12 → liblaf_cherries-0.0.14}/src/liblaf/cherries/_version.pyi +0 -0
- {liblaf_cherries-0.0.12 → liblaf_cherries-0.0.14}/src/liblaf/cherries/info/__init__.py +0 -0
- {liblaf_cherries-0.0.12 → liblaf_cherries-0.0.14}/src/liblaf/cherries/info/_git.py +0 -0
- {liblaf_cherries-0.0.12 → liblaf_cherries-0.0.14}/src/liblaf/cherries/pathutils/__init__.py +0 -0
- {liblaf_cherries-0.0.12 → liblaf_cherries-0.0.14}/src/liblaf/cherries/pathutils/_convert.py +0 -0
- {liblaf_cherries-0.0.12 → liblaf_cherries-0.0.14}/src/liblaf/cherries/plugin/__init__.py +0 -0
- {liblaf_cherries-0.0.12 → liblaf_cherries-0.0.14}/src/liblaf/cherries/plugin/__init__.pyi +0 -0
- {liblaf_cherries-0.0.12 → liblaf_cherries-0.0.14}/src/liblaf/cherries/plugin/_abc.py +0 -0
- {liblaf_cherries-0.0.12 → liblaf_cherries-0.0.14}/src/liblaf/cherries/plugin/_git.py +0 -0
- {liblaf_cherries-0.0.12 → liblaf_cherries-0.0.14}/src/liblaf/cherries/presets/__init__.py +0 -0
- {liblaf_cherries-0.0.12 → liblaf_cherries-0.0.14}/src/liblaf/cherries/presets/__init__.pyi +0 -0
- {liblaf_cherries-0.0.12 → liblaf_cherries-0.0.14}/src/liblaf/cherries/presets/_default.py +0 -0
- {liblaf_cherries-0.0.12 → liblaf_cherries-0.0.14}/src/liblaf/cherries/py.typed +0 -0
- {liblaf_cherries-0.0.12 → liblaf_cherries-0.0.14}/src/liblaf/cherries/typed.py +0 -0
- {liblaf_cherries-0.0.12 → liblaf_cherries-0.0.14}/src/liblaf/cherries/utils/__init__.py +0 -0
- {liblaf_cherries-0.0.12 → liblaf_cherries-0.0.14}/src/liblaf/cherries/utils/__init__.pyi +0 -0
- {liblaf_cherries-0.0.12 → liblaf_cherries-0.0.14}/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.
|
3
|
+
Version: 0.0.14
|
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/
|
@@ -35,7 +35,7 @@ Requires-Dist: dvc[webdav]<4,>=3.59.2
|
|
35
35
|
Requires-Dist: environs<15,>=14.1.1
|
36
36
|
Requires-Dist: gitpython<4,>=3.1.44
|
37
37
|
Requires-Dist: lazy-loader<0.5,>=0.4
|
38
|
-
Requires-Dist: liblaf-grapes<0.2,>=0.1.
|
38
|
+
Requires-Dist: liblaf-grapes<0.2,>=0.1.25
|
39
39
|
Requires-Dist: loguru<0.8,>=0.7.3
|
40
40
|
Requires-Dist: mlflow<3,>=2.22.0
|
41
41
|
Requires-Dist: pydantic-settings<3,>=2.9.1
|
@@ -64,7 +64,7 @@ dependencies = [
|
|
64
64
|
"environs>=14.1.1,<15",
|
65
65
|
"gitpython>=3.1.44,<4",
|
66
66
|
"lazy-loader>=0.4,<0.5",
|
67
|
-
"liblaf-grapes>=0.1.
|
67
|
+
"liblaf-grapes>=0.1.25,<0.2",
|
68
68
|
"loguru>=0.7.3,<0.8",
|
69
69
|
"mlflow>=2.22.0,<3",
|
70
70
|
"pydantic-settings>=2.9.1,<3",
|
@@ -124,5 +124,4 @@ linux = "6.13"
|
|
124
124
|
|
125
125
|
[tool.pytest.ini_options]
|
126
126
|
addopts = ["--showlocals", "--strict-config", "--strict-markers"]
|
127
|
-
junit_family = "legacy"
|
128
127
|
testpaths = ["benches/", "tests/"]
|
@@ -8,13 +8,13 @@ from .pathutils import (
|
|
8
8
|
config,
|
9
9
|
data,
|
10
10
|
entrypoint,
|
11
|
-
exp_dir,
|
12
11
|
git_root,
|
13
12
|
git_root_safe,
|
14
13
|
inputs,
|
15
14
|
outputs,
|
16
15
|
params,
|
17
16
|
path,
|
17
|
+
run_dir,
|
18
18
|
src,
|
19
19
|
)
|
20
20
|
from .plugin import (
|
@@ -61,7 +61,6 @@ __all__ = [
|
|
61
61
|
"data",
|
62
62
|
"end",
|
63
63
|
"entrypoint",
|
64
|
-
"exp_dir",
|
65
64
|
"git_root",
|
66
65
|
"git_root_safe",
|
67
66
|
"info",
|
@@ -82,6 +81,7 @@ __all__ = [
|
|
82
81
|
"plugin",
|
83
82
|
"presets",
|
84
83
|
"run",
|
84
|
+
"run_dir",
|
85
85
|
"set_tag",
|
86
86
|
"src",
|
87
87
|
"start",
|
@@ -17,9 +17,9 @@ def run[C: pydantic.BaseModel, T](main: Callable[[C], T]) -> T:
|
|
17
17
|
ret: T = main(cfg)
|
18
18
|
except BaseException as e:
|
19
19
|
if isinstance(e, KeyboardInterrupt):
|
20
|
-
run.end(
|
20
|
+
run.end(plugin.RunStatus.KILLED)
|
21
21
|
raise
|
22
|
-
run.end(
|
22
|
+
run.end(plugin.RunStatus.FAILED)
|
23
23
|
raise
|
24
24
|
else:
|
25
25
|
run.end()
|
@@ -31,7 +31,7 @@ def start() -> plugin.Run:
|
|
31
31
|
run.start()
|
32
32
|
run.log_src(_path.entrypoint(absolute=True))
|
33
33
|
run.set_tag("cherries.entrypoint", _path.entrypoint(absolute=False))
|
34
|
-
run.set_tag("cherries.
|
34
|
+
run.set_tag("cherries.run-dir", _path.run_dir(absolute=False))
|
35
35
|
return plugin.run
|
36
36
|
|
37
37
|
|
@@ -1,5 +1,5 @@
|
|
1
|
-
from ._exp_name import exp_name
|
2
1
|
from ._git import git_auto_commit, git_branch, git_commit_sha, git_commit_url, git_info
|
2
|
+
from ._name import exp_name, run_name
|
3
3
|
|
4
4
|
__all__ = [
|
5
5
|
"exp_name",
|
@@ -8,4 +8,5 @@ __all__ = [
|
|
8
8
|
"git_commit_sha",
|
9
9
|
"git_commit_url",
|
10
10
|
"git_info",
|
11
|
+
"run_name",
|
11
12
|
]
|
@@ -1,7 +1,10 @@
|
|
1
|
+
from pathlib import Path
|
2
|
+
|
1
3
|
import git.exc
|
2
4
|
from environs import env
|
3
5
|
|
4
6
|
from liblaf import grapes
|
7
|
+
from liblaf.cherries import pathutils as _path
|
5
8
|
|
6
9
|
from ._git import git_info
|
7
10
|
|
@@ -17,3 +20,11 @@ def exp_name() -> str:
|
|
17
20
|
return "Default"
|
18
21
|
else:
|
19
22
|
return info.repo
|
23
|
+
|
24
|
+
|
25
|
+
def run_name() -> str:
|
26
|
+
run_dir: Path = _path.run_dir(absolute=False)
|
27
|
+
run_name: str = _path.as_posix(run_dir)
|
28
|
+
run_name = run_name.removeprefix("exp")
|
29
|
+
run_name = run_name.removeprefix("/")
|
30
|
+
return run_name
|
{liblaf_cherries-0.0.12 → liblaf_cherries-0.0.14}/src/liblaf/cherries/pathutils/__init__.pyi
RENAMED
@@ -1,5 +1,5 @@
|
|
1
1
|
from ._convert import as_os_path, as_path, as_posix
|
2
|
-
from ._path import entrypoint,
|
2
|
+
from ._path import entrypoint, git_root, git_root_safe, run_dir
|
3
3
|
from ._special import config, data, inputs, outputs, params, path, src
|
4
4
|
|
5
5
|
__all__ = [
|
@@ -9,12 +9,12 @@ __all__ = [
|
|
9
9
|
"config",
|
10
10
|
"data",
|
11
11
|
"entrypoint",
|
12
|
-
"exp_dir",
|
13
12
|
"git_root",
|
14
13
|
"git_root_safe",
|
15
14
|
"inputs",
|
16
15
|
"outputs",
|
17
16
|
"params",
|
18
17
|
"path",
|
18
|
+
"run_dir",
|
19
19
|
"src",
|
20
20
|
]
|
@@ -15,13 +15,6 @@ def entrypoint(*, absolute: bool = False) -> Path:
|
|
15
15
|
return _entrypoint_relative()
|
16
16
|
|
17
17
|
|
18
|
-
@utils.cache
|
19
|
-
def exp_dir(*, absolute: bool = False) -> Path:
|
20
|
-
if absolute:
|
21
|
-
return _exp_dir_absolute()
|
22
|
-
return _exp_dir_relative()
|
23
|
-
|
24
|
-
|
25
18
|
@utils.cache
|
26
19
|
def git_root() -> Path:
|
27
20
|
entrypoint: Path = _entrypoint_absolute()
|
@@ -38,6 +31,13 @@ def git_root_safe() -> Path:
|
|
38
31
|
return _entrypoint_absolute().parent
|
39
32
|
|
40
33
|
|
34
|
+
@utils.cache
|
35
|
+
def run_dir(*, absolute: bool = False) -> Path:
|
36
|
+
if absolute:
|
37
|
+
return _run_dir_absolute()
|
38
|
+
return _run_dir_relative()
|
39
|
+
|
40
|
+
|
41
41
|
@utils.cache
|
42
42
|
def _entrypoint_absolute() -> Path:
|
43
43
|
path = Path(sys.argv[0])
|
@@ -51,7 +51,7 @@ def _entrypoint_relative() -> Path:
|
|
51
51
|
|
52
52
|
|
53
53
|
@utils.cache
|
54
|
-
def
|
54
|
+
def _run_dir_absolute() -> Path:
|
55
55
|
entrypoint: Path = _entrypoint_absolute()
|
56
56
|
for path in entrypoint.parents:
|
57
57
|
if (path / "exp.cherries.toml").is_file():
|
@@ -62,7 +62,7 @@ def _exp_dir_absolute() -> Path:
|
|
62
62
|
|
63
63
|
|
64
64
|
@utils.cache
|
65
|
-
def
|
66
|
-
absolute: Path =
|
65
|
+
def _run_dir_relative() -> Path:
|
66
|
+
absolute: Path = _run_dir_absolute()
|
67
67
|
root: Path = git_root_safe()
|
68
68
|
return absolute.relative_to(root)
|
@@ -2,7 +2,7 @@ from pathlib import Path
|
|
2
2
|
|
3
3
|
from liblaf.grapes.typed import PathLike
|
4
4
|
|
5
|
-
from ._path import
|
5
|
+
from ._path import run_dir
|
6
6
|
|
7
7
|
|
8
8
|
def config(
|
@@ -44,7 +44,7 @@ def src(path: PathLike = "", *, mkdir: bool = True, prefix: PathLike = "src") ->
|
|
44
44
|
def _path(path: PathLike = "", *, mkdir: bool = True, prefix: PathLike = "") -> Path:
|
45
45
|
path = Path(path)
|
46
46
|
if not path.is_absolute():
|
47
|
-
path =
|
47
|
+
path = run_dir(absolute=True) / prefix / path
|
48
48
|
if mkdir:
|
49
49
|
path.parent.mkdir(parents=True, exist_ok=True)
|
50
50
|
return path
|
@@ -3,6 +3,8 @@ from pathlib import Path
|
|
3
3
|
from typing import override
|
4
4
|
|
5
5
|
import attrs
|
6
|
+
import git
|
7
|
+
import git.exc
|
6
8
|
|
7
9
|
from liblaf.cherries import pathutils as _path
|
8
10
|
from liblaf.cherries.typed import PathLike
|
@@ -25,7 +27,9 @@ class DvcLogArtifact(LogArtifact):
|
|
25
27
|
self, local_path: PathLike, artifact_path: PathLike | None = None, **kwargs
|
26
28
|
) -> Path:
|
27
29
|
local_path: Path = _path.as_path(local_path)
|
28
|
-
|
30
|
+
if check_ignore(local_path) or tracked_by_git(local_path):
|
31
|
+
return local_path
|
32
|
+
sp.run(["dvc", "add", local_path], check=True)
|
29
33
|
return local_path
|
30
34
|
|
31
35
|
|
@@ -36,7 +40,9 @@ class DvcLogArtifacts(LogArtifacts):
|
|
36
40
|
self, local_dir: PathLike, artifact_path: PathLike | None = None, **kwargs
|
37
41
|
) -> Path:
|
38
42
|
local_dir: Path = _path.as_path(local_dir)
|
39
|
-
|
43
|
+
if check_ignore(local_dir) or tracked_by_git(local_dir):
|
44
|
+
return local_dir
|
45
|
+
sp.run(["dvc", "add", local_dir], check=True)
|
40
46
|
return local_dir
|
41
47
|
|
42
48
|
|
@@ -45,3 +51,13 @@ def check_ignore(local_path: PathLike) -> bool:
|
|
45
51
|
["dvc", "check-ignore", local_path], check=False
|
46
52
|
)
|
47
53
|
return proc.returncode == 0
|
54
|
+
|
55
|
+
|
56
|
+
def tracked_by_git(local_path: PathLike) -> bool:
|
57
|
+
local_path: Path = _path.as_path(local_path).absolute()
|
58
|
+
try:
|
59
|
+
repo = git.Repo(search_parent_directories=True)
|
60
|
+
repo.git.ls_files(local_path, error_unmatch=True)
|
61
|
+
except git.exc.GitCommandError:
|
62
|
+
return False
|
63
|
+
return True
|
@@ -25,7 +25,7 @@ class LoggingStart(Start):
|
|
25
25
|
grapes.init_logging(
|
26
26
|
handlers=[
|
27
27
|
grapes.logging.rich_handler(),
|
28
|
-
grapes.logging.file_handler(
|
29
|
-
grapes.logging.jsonl_handler(run.exp_dir / "run.log.jsonl"),
|
28
|
+
grapes.logging.file_handler(sink=run.exp_dir / "run.log"),
|
29
|
+
grapes.logging.jsonl_handler(sink=run.exp_dir / "run.log.jsonl"),
|
30
30
|
]
|
31
31
|
)
|
@@ -3,7 +3,6 @@ from typing import Any, override
|
|
3
3
|
|
4
4
|
import attrs
|
5
5
|
import mlflow
|
6
|
-
import mlflow.entities
|
7
6
|
|
8
7
|
from liblaf.cherries import info as _info
|
9
8
|
from liblaf.cherries import pathutils as _path
|
@@ -34,6 +33,9 @@ class MlflowLogArtifact(LogArtifact):
|
|
34
33
|
def __call__(
|
35
34
|
self, local_path: PathLike, artifact_path: PathLike | None = None, **kwargs
|
36
35
|
) -> Path:
|
36
|
+
local_path: Path = _path.as_path(local_path)
|
37
|
+
if (dvc_file := local_path.with_name(local_path.name + ".dvc")).is_file():
|
38
|
+
local_path = dvc_file
|
37
39
|
mlflow.log_artifact(
|
38
40
|
_path.as_os_path(local_path), _path.as_posix(artifact_path), **kwargs
|
39
41
|
)
|
@@ -46,6 +48,9 @@ class MlflowLogArtifacts(LogArtifacts):
|
|
46
48
|
def __call__(
|
47
49
|
self, local_dir: PathLike, artifact_path: PathLike | None = None, **kwargs
|
48
50
|
) -> Path:
|
51
|
+
local_dir: Path = _path.as_path(local_dir)
|
52
|
+
if (dvc_file := local_dir.with_name(local_dir.name + ".dvc")).is_file():
|
53
|
+
local_dir = dvc_file
|
49
54
|
mlflow.log_artifact(
|
50
55
|
_path.as_os_path(local_dir), _path.as_posix(artifact_path), **kwargs
|
51
56
|
)
|
@@ -80,4 +85,4 @@ class MlflowStart(Start):
|
|
80
85
|
@override
|
81
86
|
def __call__(self) -> None:
|
82
87
|
mlflow.set_experiment(_info.exp_name())
|
83
|
-
mlflow.start_run()
|
88
|
+
mlflow.start_run(run_name=_info.run_name())
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|