liblaf-cherries 0.4.3__py3-none-any.whl → 0.5.1__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.
- liblaf/cherries/__init__.py +1 -0
- liblaf/cherries/__init__.pyi +5 -7
- liblaf/cherries/_entrypoint.py +11 -10
- liblaf/cherries/_version.py +2 -2
- liblaf/cherries/config/__init__.py +1 -0
- liblaf/cherries/config/__init__.pyi +16 -4
- liblaf/cherries/config/_config.py +1 -2
- liblaf/cherries/{paths → config/asset}/__init__.py +1 -0
- liblaf/cherries/config/asset/__init__.pyi +34 -0
- liblaf/cherries/config/asset/_meta.py +98 -0
- liblaf/cherries/config/asset/_registry.py +25 -0
- liblaf/cherries/config/asset/resolvers/__init__.py +4 -0
- liblaf/cherries/config/asset/resolvers/__init__.pyi +5 -0
- liblaf/cherries/config/asset/resolvers/_abc.py +17 -0
- liblaf/cherries/config/asset/resolvers/_series.py +18 -0
- liblaf/cherries/config/asset/resolvers/_vtk.py +33 -0
- liblaf/cherries/core/__init__.py +1 -0
- liblaf/cherries/core/__init__.pyi +15 -3
- liblaf/cherries/core/_impl.py +20 -7
- liblaf/cherries/core/_plugin.py +53 -50
- liblaf/cherries/core/_run.py +22 -52
- liblaf/cherries/core/_spec.py +10 -11
- liblaf/cherries/core/_utils.py +44 -1
- liblaf/cherries/meta/__init__.py +1 -0
- liblaf/cherries/meta/_git.py +3 -3
- liblaf/cherries/meta/_name.py +3 -3
- liblaf/cherries/path_utils/__init__.py +4 -0
- liblaf/cherries/{paths → path_utils}/__init__.pyi +2 -3
- liblaf/cherries/{paths → path_utils}/_convert.py +1 -1
- liblaf/cherries/path_utils/_path.py +43 -0
- liblaf/cherries/plugins/__init__.py +1 -0
- liblaf/cherries/plugins/comet.py +16 -9
- liblaf/cherries/plugins/dvc.py +1 -1
- liblaf/cherries/plugins/git_.py +17 -21
- liblaf/cherries/plugins/local.py +3 -3
- liblaf/cherries/plugins/logging.py +2 -2
- liblaf/cherries/profiles/__init__.py +1 -0
- liblaf/cherries/profiles/_factory.py +2 -3
- liblaf/cherries/utils/__init__.py +1 -0
- {liblaf_cherries-0.4.3.dist-info → liblaf_cherries-0.5.1.dist-info}/METADATA +2 -2
- liblaf_cherries-0.5.1.dist-info/RECORD +56 -0
- liblaf/cherries/config/_asset.py +0 -92
- liblaf/cherries/paths/_path.py +0 -70
- liblaf_cherries-0.4.3.dist-info/RECORD +0 -48
- /liblaf/cherries/core/{typed.py → typing.py} +0 -0
- /liblaf/cherries/{paths → path_utils}/_special.py +0 -0
- /liblaf/cherries/{typed.py → typing.py} +0 -0
- {liblaf_cherries-0.4.3.dist-info → liblaf_cherries-0.5.1.dist-info}/WHEEL +0 -0
- {liblaf_cherries-0.4.3.dist-info → liblaf_cherries-0.5.1.dist-info}/licenses/LICENSE +0 -0
liblaf/cherries/config/_asset.py
DELETED
@@ -1,92 +0,0 @@
|
|
1
|
-
import enum
|
2
|
-
from collections.abc import Callable, Iterable
|
3
|
-
from pathlib import Path
|
4
|
-
from typing import Any, Literal
|
5
|
-
|
6
|
-
import pydantic
|
7
|
-
|
8
|
-
from liblaf import grapes
|
9
|
-
from liblaf.cherries import paths
|
10
|
-
from liblaf.cherries.typed import PathLike
|
11
|
-
|
12
|
-
|
13
|
-
class AssetKind(enum.StrEnum):
|
14
|
-
INPUT = enum.auto()
|
15
|
-
OUTPUT = enum.auto()
|
16
|
-
|
17
|
-
|
18
|
-
type PathGenerator = (
|
19
|
-
PathLike | Iterable[PathLike] | Callable[[PathLike], PathLike | Iterable[PathLike]]
|
20
|
-
)
|
21
|
-
|
22
|
-
|
23
|
-
class MetaAsset:
|
24
|
-
kind: AssetKind
|
25
|
-
_extra: PathGenerator | None = None
|
26
|
-
|
27
|
-
def __init__(self, kind: AssetKind, extra: PathGenerator | None = None) -> None:
|
28
|
-
self.kind = kind
|
29
|
-
self._extra = extra
|
30
|
-
|
31
|
-
def get_extra(self, value: Path) -> list[Path]:
|
32
|
-
if self._extra is None:
|
33
|
-
return []
|
34
|
-
if callable(self._extra):
|
35
|
-
extra: Iterable[PathLike] = grapes.as_iterable(self._extra(value))
|
36
|
-
return [Path(p) for p in extra]
|
37
|
-
extra: Iterable[PathLike] = grapes.as_iterable(self._extra)
|
38
|
-
return [Path(p) for p in extra]
|
39
|
-
|
40
|
-
|
41
|
-
def get_assets(cfg: pydantic.BaseModel, kind: AssetKind) -> list[Path]:
|
42
|
-
assets: list[Path] = []
|
43
|
-
for name, info in type(cfg).model_fields.items():
|
44
|
-
value: Any = getattr(cfg, name)
|
45
|
-
if isinstance(value, pydantic.BaseModel):
|
46
|
-
assets.extend(get_assets(value, kind))
|
47
|
-
for meta in info.metadata:
|
48
|
-
if isinstance(meta, MetaAsset) and meta.kind == kind:
|
49
|
-
value: Path = Path(value)
|
50
|
-
assets.append(value)
|
51
|
-
assets.extend(meta.get_extra(value))
|
52
|
-
return assets
|
53
|
-
|
54
|
-
|
55
|
-
def get_inputs(cfg: pydantic.BaseModel) -> list[Path]:
|
56
|
-
return get_assets(cfg, AssetKind.INPUT)
|
57
|
-
|
58
|
-
|
59
|
-
def get_outputs(cfg: pydantic.BaseModel) -> list[Path]:
|
60
|
-
return get_assets(cfg, AssetKind.OUTPUT)
|
61
|
-
|
62
|
-
|
63
|
-
def input(path: PathLike, extra: PathGenerator | None = None, **kwargs) -> Path: # noqa: A001
|
64
|
-
field_info: pydantic.fields.FieldInfo = pydantic.Field(paths.data(path), **kwargs) # pyright: ignore[reportAssignmentType]
|
65
|
-
field_info.metadata.append(MetaAsset(kind=AssetKind.INPUT, extra=extra))
|
66
|
-
return field_info # pyright: ignore[reportReturnType]
|
67
|
-
|
68
|
-
|
69
|
-
def model_dump_without_assets(
|
70
|
-
model: pydantic.BaseModel,
|
71
|
-
*,
|
72
|
-
mode: str | Literal["json", "python"] = "json", # noqa: PYI051
|
73
|
-
**kwargs,
|
74
|
-
) -> dict[str, Any]:
|
75
|
-
data: dict[str, Any] = model.model_dump(mode=mode, **kwargs)
|
76
|
-
for name, info in type(model).model_fields.items():
|
77
|
-
value: Any = getattr(model, name)
|
78
|
-
if isinstance(value, pydantic.BaseModel):
|
79
|
-
value = model_dump_without_assets(value)
|
80
|
-
for meta in info.metadata:
|
81
|
-
if isinstance(meta, MetaAsset):
|
82
|
-
del data[name]
|
83
|
-
break
|
84
|
-
else:
|
85
|
-
data[name] = value
|
86
|
-
return data
|
87
|
-
|
88
|
-
|
89
|
-
def output(path: PathLike, extra: PathGenerator | None = None, **kwargs) -> Path:
|
90
|
-
field_info: pydantic.fields.FieldInfo = pydantic.Field(paths.data(path), **kwargs) # pyright: ignore[reportAssignmentType]
|
91
|
-
field_info.metadata.append(MetaAsset(kind=AssetKind.OUTPUT, extra=extra))
|
92
|
-
return field_info # pyright: ignore[reportReturnType]
|
liblaf/cherries/paths/_path.py
DELETED
@@ -1,70 +0,0 @@
|
|
1
|
-
import sys
|
2
|
-
from collections.abc import Container
|
3
|
-
from pathlib import Path
|
4
|
-
|
5
|
-
import git
|
6
|
-
import git.exc
|
7
|
-
from loguru import logger
|
8
|
-
|
9
|
-
from liblaf.cherries import utils
|
10
|
-
|
11
|
-
|
12
|
-
@utils.cache
|
13
|
-
def entrypoint(*, absolute: bool = True) -> Path:
|
14
|
-
if absolute:
|
15
|
-
return _entrypoint_absolute()
|
16
|
-
return _entrypoint_relative()
|
17
|
-
|
18
|
-
|
19
|
-
@utils.cache
|
20
|
-
def git_root() -> Path:
|
21
|
-
entrypoint: Path = _entrypoint_absolute()
|
22
|
-
repo = git.Repo(entrypoint, search_parent_directories=True)
|
23
|
-
return Path(repo.working_dir)
|
24
|
-
|
25
|
-
|
26
|
-
@utils.cache
|
27
|
-
def git_root_safe() -> Path:
|
28
|
-
try:
|
29
|
-
return git_root()
|
30
|
-
except git.exc.InvalidGitRepositoryError:
|
31
|
-
logger.warning("Not in a git repository, using current directory", once=True)
|
32
|
-
return _entrypoint_absolute().parent
|
33
|
-
|
34
|
-
|
35
|
-
@utils.cache
|
36
|
-
def exp_dir(*, absolute: bool = True) -> Path:
|
37
|
-
if absolute:
|
38
|
-
return _exp_dir_absolute()
|
39
|
-
return _exp_dir_relative()
|
40
|
-
|
41
|
-
|
42
|
-
@utils.cache
|
43
|
-
def _entrypoint_absolute() -> Path:
|
44
|
-
path = Path(sys.argv[0])
|
45
|
-
return path.absolute()
|
46
|
-
|
47
|
-
|
48
|
-
@utils.cache
|
49
|
-
def _entrypoint_relative() -> Path:
|
50
|
-
path: Path = _entrypoint_absolute()
|
51
|
-
return path.relative_to(git_root_safe())
|
52
|
-
|
53
|
-
|
54
|
-
EXP_DIR_NAMES: Container[str] = {"exp", "experiment", "experiments", "exps", "src"}
|
55
|
-
|
56
|
-
|
57
|
-
@utils.cache
|
58
|
-
def _exp_dir_absolute() -> Path:
|
59
|
-
entrypoint: Path = _entrypoint_absolute()
|
60
|
-
parent: Path = entrypoint.parent
|
61
|
-
if parent.name in EXP_DIR_NAMES:
|
62
|
-
return parent.parent
|
63
|
-
return parent
|
64
|
-
|
65
|
-
|
66
|
-
@utils.cache
|
67
|
-
def _exp_dir_relative() -> Path:
|
68
|
-
absolute: Path = _exp_dir_absolute()
|
69
|
-
root: Path = git_root_safe()
|
70
|
-
return absolute.relative_to(root)
|
@@ -1,48 +0,0 @@
|
|
1
|
-
liblaf/cherries/__init__.py,sha256=OHb6Xou2v6u42swTgjRfzej4CIlRg4OmgOIQXUiRjKA,97
|
2
|
-
liblaf/cherries/__init__.pyi,sha256=vQIYxi3iwe0Uij8Q8RCFlzN5MCCDuWgcnyox01C_nJo,1066
|
3
|
-
liblaf/cherries/_entrypoint.py,sha256=pSRbOCuMhUnYrAsZTEideVbUDEmGocvKlMgGt_MX_Z0,2262
|
4
|
-
liblaf/cherries/_version.py,sha256=bmI9ViMEsJ1Rjce-6ExwiNh2B7sZKTyBkze4k8NsTrU,704
|
5
|
-
liblaf/cherries/_version.pyi,sha256=Pnv4Bxw13LHeuVkPLPsTtnp4N4jOGcAfFJw05uMMgBY,108
|
6
|
-
liblaf/cherries/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
7
|
-
liblaf/cherries/typed.py,sha256=mim8QVtwczTSHyw5mhEdfFcXis9o32n0CZyu8BrEorE,50
|
8
|
-
liblaf/cherries/config/__init__.py,sha256=OHb6Xou2v6u42swTgjRfzej4CIlRg4OmgOIQXUiRjKA,97
|
9
|
-
liblaf/cherries/config/__init__.pyi,sha256=Tl-GCtMEtQOcYC5poH3qzQxR91A1RcjYDP3fEdJ9Qzc,425
|
10
|
-
liblaf/cherries/config/_asset.py,sha256=pKHlzjOBc5yso3zJ18QfPzMwNETq1557E13qberoWZ0,3119
|
11
|
-
liblaf/cherries/config/_config.py,sha256=WPwwk-3O96FyHGb2W8__LDfHpXBHLQM44aOcrMPjDL4,171
|
12
|
-
liblaf/cherries/core/__init__.py,sha256=OHb6Xou2v6u42swTgjRfzej4CIlRg4OmgOIQXUiRjKA,97
|
13
|
-
liblaf/cherries/core/__init__.pyi,sha256=jgmGgzlTDlyFKHnSjNw3g22ZBuBQ07NmeRiq4qKZFdg,727
|
14
|
-
liblaf/cherries/core/_impl.py,sha256=LCd4f5oX5bEMa4uX37r0yiPntqZM1Lwqrd7vKL1oc7w,1459
|
15
|
-
liblaf/cherries/core/_plugin.py,sha256=LcCxNQkkInOOrPnSd5ZwKhnKQiUl4T-YicE9PEvF3XI,3198
|
16
|
-
liblaf/cherries/core/_run.py,sha256=GNJEHGldjbvURkN5nAy8K9u1mWwxYHd-vkbnvfaOw8U,5403
|
17
|
-
liblaf/cherries/core/_spec.py,sha256=F73wxygkc_3v0hOKwfFSGaLRHEDhhENWLQZakruuRq8,1950
|
18
|
-
liblaf/cherries/core/_utils.py,sha256=WpS79yqTH0Kl9ewzCIAiUcxamHKzJOB7ZWhjq_13bzY,572
|
19
|
-
liblaf/cherries/core/typed.py,sha256=razpiUtLAGFD9J4H5RbIEHKEXWzxFHFjtOBBRllhea4,42
|
20
|
-
liblaf/cherries/meta/__init__.py,sha256=OHb6Xou2v6u42swTgjRfzej4CIlRg4OmgOIQXUiRjKA,97
|
21
|
-
liblaf/cherries/meta/__init__.pyi,sha256=kQFneP3IiV9rBIzpep_uX0z-5IRPrXkPmyNRt19j8fg,282
|
22
|
-
liblaf/cherries/meta/_git.py,sha256=HhxqwKY52KahvAYU0R3BTRNT7lMJIjJLpnuSYfm02W4,1219
|
23
|
-
liblaf/cherries/meta/_name.py,sha256=7sUZMYpGzW8ZKSNPITybrjnD2vLY57O91aK6Gd7Ud5M,550
|
24
|
-
liblaf/cherries/paths/__init__.py,sha256=OHb6Xou2v6u42swTgjRfzej4CIlRg4OmgOIQXUiRjKA,97
|
25
|
-
liblaf/cherries/paths/__init__.pyi,sha256=Xf6-Igmj2K8hmLsJ3sXCj2Lrm0gIWcbARQB4oMP1zps,367
|
26
|
-
liblaf/cherries/paths/_convert.py,sha256=IrXN_9s-rfH7EKk0_ilr1giGmfN8FlvB_edm2kI-k3I,807
|
27
|
-
liblaf/cherries/paths/_path.py,sha256=36T4eE8OdT83LDwEaKjcBWS5r4jZEGBXFxeJqiB7-IQ,1604
|
28
|
-
liblaf/cherries/paths/_special.py,sha256=HVmH6lCnj1TVzjAEmO93MGMTQi7JQWss4sHSNMieczY,1100
|
29
|
-
liblaf/cherries/plugins/__init__.py,sha256=OHb6Xou2v6u42swTgjRfzej4CIlRg4OmgOIQXUiRjKA,97
|
30
|
-
liblaf/cherries/plugins/__init__.pyi,sha256=dyTB5ZS78Kg_7oWeChk_h7Ry_gU9k1sDiL5YOmnoG7I,177
|
31
|
-
liblaf/cherries/plugins/comet.py,sha256=DzQ-ktyFO6JeV1di89J3P38Ok4X07mTVtAgUZDm0FLc,3607
|
32
|
-
liblaf/cherries/plugins/dvc.py,sha256=2HslDy_8gcFehly2CNCSZpRs0Wet7RTGMwbxxlo9IVc,1052
|
33
|
-
liblaf/cherries/plugins/git_.py,sha256=pcJDYUl3D11h4_v0paEH2SyfswTmicAjluWoWJpeJjM,2194
|
34
|
-
liblaf/cherries/plugins/local.py,sha256=WHBJo6HIJOoTBRedd2a6nKoTJsaSUxhGN0jSAV94de8,1714
|
35
|
-
liblaf/cherries/plugins/logging.py,sha256=A2-fd7H96Jtg1eOOmMYp7AmT3133vDHd4HAklhjH6n0,533
|
36
|
-
liblaf/cherries/profiles/__init__.py,sha256=OHb6Xou2v6u42swTgjRfzej4CIlRg4OmgOIQXUiRjKA,97
|
37
|
-
liblaf/cherries/profiles/__init__.pyi,sha256=qXxy2LOG9hE0LKCnECdJSv2VoHhOTMVDE3sUKIuZKmw,292
|
38
|
-
liblaf/cherries/profiles/_abc.py,sha256=1tpRrocBZNHonWaj3a264GnL5UoGS_HqU06aNZpruqY,193
|
39
|
-
liblaf/cherries/profiles/_default.py,sha256=cfV003HBA5aGAZkgDDaHAyongFcxCWYsEFpSQNICcMs,440
|
40
|
-
liblaf/cherries/profiles/_factory.py,sha256=d-PaE8JYllkzcqQDiyi5aP52lFJOkFdLai3XXgSKAE8,758
|
41
|
-
liblaf/cherries/profiles/_playground.py,sha256=Aru-7RVoxNhomPLUxDLiM5wD5ZCPLy5Eymw0xQL2F9g,384
|
42
|
-
liblaf/cherries/utils/__init__.py,sha256=OHb6Xou2v6u42swTgjRfzej4CIlRg4OmgOIQXUiRjKA,97
|
43
|
-
liblaf/cherries/utils/__init__.pyi,sha256=F5aTcXpWVmUoctPbLfmQXKyuXYRspAIjaIzfL1_3Lrw,51
|
44
|
-
liblaf/cherries/utils/_functools.py,sha256=0Puwvj1Wq4kp3S--hI-CXwUBZ56AtfkqIzFHllQtuug,181
|
45
|
-
liblaf_cherries-0.4.3.dist-info/METADATA,sha256=l4dJ7883MyxpE1TkIigzEYAIpjWKWRKiJ2UJx6tVC3g,7023
|
46
|
-
liblaf_cherries-0.4.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
47
|
-
liblaf_cherries-0.4.3.dist-info/licenses/LICENSE,sha256=Ph4NzyU3lGVDeYv-mf8aRmImH8v9rVL9F362FV4G6Ow,1063
|
48
|
-
liblaf_cherries-0.4.3.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|