hydraflow 0.3.3__py3-none-any.whl → 0.3.5__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- hydraflow/__init__.py +4 -2
- hydraflow/config.py +42 -0
- hydraflow/context.py +1 -1
- hydraflow/param.py +4 -1
- hydraflow/utils.py +5 -5
- {hydraflow-0.3.3.dist-info → hydraflow-0.3.5.dist-info}/METADATA +1 -1
- hydraflow-0.3.5.dist-info/RECORD +16 -0
- hydraflow-0.3.3.dist-info/RECORD +0 -16
- {hydraflow-0.3.3.dist-info → hydraflow-0.3.5.dist-info}/WHEEL +0 -0
- {hydraflow-0.3.3.dist-info → hydraflow-0.3.5.dist-info}/licenses/LICENSE +0 -0
hydraflow/__init__.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
"""Integrate Hydra and MLflow to manage and track machine learning experiments."""
|
2
2
|
|
3
|
-
from .
|
3
|
+
from .config import select_config
|
4
|
+
from .context import chdir_artifact, chdir_hydra_output, log_run, start_run, watch
|
4
5
|
from .mlflow import list_runs, search_runs, set_experiment
|
5
6
|
from .progress import multi_tasks_progress, parallel_progress
|
6
7
|
from .run_collection import RunCollection
|
@@ -15,7 +16,7 @@ from .utils import (
|
|
15
16
|
__all__ = [
|
16
17
|
"RunCollection",
|
17
18
|
"chdir_artifact",
|
18
|
-
"
|
19
|
+
"chdir_hydra_output",
|
19
20
|
"get_artifact_dir",
|
20
21
|
"get_hydra_output_dir",
|
21
22
|
"get_overrides",
|
@@ -26,6 +27,7 @@ __all__ = [
|
|
26
27
|
"multi_tasks_progress",
|
27
28
|
"parallel_progress",
|
28
29
|
"search_runs",
|
30
|
+
"select_config",
|
29
31
|
"set_experiment",
|
30
32
|
"start_run",
|
31
33
|
"watch",
|
hydraflow/config.py
CHANGED
@@ -44,12 +44,25 @@ def iter_params(config: object, prefix: str = "") -> Iterator[tuple[str, Any]]:
|
|
44
44
|
if config is None:
|
45
45
|
return
|
46
46
|
|
47
|
+
if isinstance(config, list) and all(isinstance(x, str) for x in config):
|
48
|
+
config = _from_dotlist(config)
|
49
|
+
|
47
50
|
if not isinstance(config, DictConfig | ListConfig):
|
48
51
|
config = OmegaConf.create(config) # type: ignore
|
49
52
|
|
50
53
|
yield from _iter_params(config, prefix)
|
51
54
|
|
52
55
|
|
56
|
+
def _from_dotlist(config: list[str]) -> dict[str, str]:
|
57
|
+
result = {}
|
58
|
+
for item in config:
|
59
|
+
if "=" in item:
|
60
|
+
key, value = item.split("=", 1)
|
61
|
+
result[key.strip()] = value.strip()
|
62
|
+
|
63
|
+
return result
|
64
|
+
|
65
|
+
|
53
66
|
def _iter_params(config: object, prefix: str = "") -> Iterator[tuple[str, Any]]:
|
54
67
|
if isinstance(config, DictConfig):
|
55
68
|
for key, value in config.items():
|
@@ -86,3 +99,32 @@ def _convert(value: Any) -> Any:
|
|
86
99
|
return list(value)
|
87
100
|
|
88
101
|
return value
|
102
|
+
|
103
|
+
|
104
|
+
def select_config(config: object, names: list[str]) -> dict[str, Any]:
|
105
|
+
"""Select the given parameters from the configuration object.
|
106
|
+
|
107
|
+
This function selects the given parameters from the configuration object
|
108
|
+
and returns a new configuration object containing only the selected parameters.
|
109
|
+
|
110
|
+
Args:
|
111
|
+
config (object): The configuration object to select parameters from.
|
112
|
+
names (list[str]): The names of the parameters to select.
|
113
|
+
|
114
|
+
Returns:
|
115
|
+
DictConfig: A new configuration object containing only the selected parameters.
|
116
|
+
|
117
|
+
"""
|
118
|
+
if not isinstance(config, DictConfig):
|
119
|
+
cfg = OmegaConf.structured(config)
|
120
|
+
|
121
|
+
return {name: _get(cfg, name) for name in names}
|
122
|
+
|
123
|
+
|
124
|
+
def _get(config: DictConfig, name: str) -> Any:
|
125
|
+
"""Get the value of the given parameter from the configuration object."""
|
126
|
+
if "." not in name:
|
127
|
+
return config.get(name)
|
128
|
+
|
129
|
+
prefix, name = name.split(".", 1)
|
130
|
+
return _get(config.get(prefix), name)
|
hydraflow/context.py
CHANGED
@@ -239,7 +239,7 @@ class Handler(PatternMatchingEventHandler):
|
|
239
239
|
|
240
240
|
|
241
241
|
@contextmanager
|
242
|
-
def
|
242
|
+
def chdir_hydra_output() -> Iterator[Path]:
|
243
243
|
"""Change the current working directory to the hydra output directory.
|
244
244
|
|
245
245
|
This context manager changes the current working directory to the hydra output
|
hydraflow/param.py
CHANGED
@@ -34,7 +34,10 @@ def match(param: str, value: Any) -> bool:
|
|
34
34
|
if isinstance(value, tuple) and (m := _match_tuple(param, value)) is not None:
|
35
35
|
return m
|
36
36
|
|
37
|
-
if isinstance(value,
|
37
|
+
if isinstance(value, str):
|
38
|
+
return param == value
|
39
|
+
|
40
|
+
if isinstance(value, int | float):
|
38
41
|
return type(value)(param) == value
|
39
42
|
|
40
43
|
return param == str(value)
|
hydraflow/utils.py
CHANGED
@@ -68,11 +68,6 @@ def get_hydra_output_dir(run: Run | None = None) -> Path:
|
|
68
68
|
raise FileNotFoundError
|
69
69
|
|
70
70
|
|
71
|
-
def get_overrides() -> list[str]:
|
72
|
-
"""Retrieve the overrides for the current run."""
|
73
|
-
return HydraConfig.get().overrides.task
|
74
|
-
|
75
|
-
|
76
71
|
def load_config(run: Run) -> DictConfig:
|
77
72
|
"""Load the configuration for a given run.
|
78
73
|
|
@@ -93,6 +88,11 @@ def load_config(run: Run) -> DictConfig:
|
|
93
88
|
return OmegaConf.load(path) # type: ignore
|
94
89
|
|
95
90
|
|
91
|
+
def get_overrides() -> list[str]:
|
92
|
+
"""Retrieve the overrides for the current run."""
|
93
|
+
return HydraConfig.get().overrides.task
|
94
|
+
|
95
|
+
|
96
96
|
def load_overrides(run: Run) -> list[str]:
|
97
97
|
"""Load the overrides for a given run.
|
98
98
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: hydraflow
|
3
|
-
Version: 0.3.
|
3
|
+
Version: 0.3.5
|
4
4
|
Summary: Hydraflow integrates Hydra and MLflow to manage and track machine learning experiments.
|
5
5
|
Project-URL: Documentation, https://github.com/daizutabi/hydraflow
|
6
6
|
Project-URL: Source, https://github.com/daizutabi/hydraflow
|
@@ -0,0 +1,16 @@
|
|
1
|
+
hydraflow/__init__.py,sha256=p0GzgI2RYXuaBdgoDgmihkn2esUlcbPJlSwoXBdbZEw,866
|
2
|
+
hydraflow/asyncio.py,sha256=-i1C8KAmNDImrjHnk92Csaa1mpjdK8Vp4ZVaQV-l94s,6634
|
3
|
+
hydraflow/config.py,sha256=mQYEW_-kr-5cz64hGxI_gkK8XK_54M-3DX-YlE44A9A,3992
|
4
|
+
hydraflow/context.py,sha256=p1UYHvSCPrp10cBn9TUI9mXMv0h_I0Eou24Wp1rZZ0k,8740
|
5
|
+
hydraflow/mlflow.py,sha256=JELqXFCJ9MsEJaQWT5dyleTFk8BHL7cQwW_gzhkPoIg,8729
|
6
|
+
hydraflow/param.py,sha256=CO-6PRlnHo-7hlY_P6j_cGlC7vPY6t-Rr7p3OqeqDyU,1995
|
7
|
+
hydraflow/progress.py,sha256=zvKX1HCN8_xDOsgYOEcLLhkhdPdep-U8vHrc0XZ-6SQ,6163
|
8
|
+
hydraflow/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
9
|
+
hydraflow/run_collection.py,sha256=OiPibp8zM4gpsvqpHr9sBh4_1zmHRuXfPcmen7xND-s,24792
|
10
|
+
hydraflow/run_data.py,sha256=qeFX1iRvNAorXA9QQIjzr0o2_82TI44eZKp7llKG8GI,1549
|
11
|
+
hydraflow/run_info.py,sha256=sMXOo20ClaRIommMEzuAbO_OrcXx7M1Yt4FMV7spxz0,998
|
12
|
+
hydraflow/utils.py,sha256=qNN0JDbQJweTkcRMpZwMXTIuK_LVpoDJ2rOwfe01f3U,3500
|
13
|
+
hydraflow-0.3.5.dist-info/METADATA,sha256=UVUeGwlz9ZcdqOX-tWJ3MJX1KD05i4lkPj455J2vAik,3840
|
14
|
+
hydraflow-0.3.5.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
|
15
|
+
hydraflow-0.3.5.dist-info/licenses/LICENSE,sha256=IGdDrBPqz1O0v_UwCW-NJlbX9Hy9b3uJ11t28y2srmY,1062
|
16
|
+
hydraflow-0.3.5.dist-info/RECORD,,
|
hydraflow-0.3.3.dist-info/RECORD
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
hydraflow/__init__.py,sha256=aZWgotgg9BAYGOk6WAocOdo1M9ydAg_i7SThFeuLNo8,797
|
2
|
-
hydraflow/asyncio.py,sha256=-i1C8KAmNDImrjHnk92Csaa1mpjdK8Vp4ZVaQV-l94s,6634
|
3
|
-
hydraflow/config.py,sha256=6V5omJ3-h9-ZwVpM5rTA4FqE_mu8urTy9OqV4zG79gw,2671
|
4
|
-
hydraflow/context.py,sha256=412884e84qIEYtbxJT4roYsKfldGaTKzgo6Q1FAsT5U,8733
|
5
|
-
hydraflow/mlflow.py,sha256=JELqXFCJ9MsEJaQWT5dyleTFk8BHL7cQwW_gzhkPoIg,8729
|
6
|
-
hydraflow/param.py,sha256=QkLeQvt5ZF3GyRGnhP66o0GElc1ZOOCxCL7PdyfIUbA,1939
|
7
|
-
hydraflow/progress.py,sha256=zvKX1HCN8_xDOsgYOEcLLhkhdPdep-U8vHrc0XZ-6SQ,6163
|
8
|
-
hydraflow/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
9
|
-
hydraflow/run_collection.py,sha256=OiPibp8zM4gpsvqpHr9sBh4_1zmHRuXfPcmen7xND-s,24792
|
10
|
-
hydraflow/run_data.py,sha256=qeFX1iRvNAorXA9QQIjzr0o2_82TI44eZKp7llKG8GI,1549
|
11
|
-
hydraflow/run_info.py,sha256=sMXOo20ClaRIommMEzuAbO_OrcXx7M1Yt4FMV7spxz0,998
|
12
|
-
hydraflow/utils.py,sha256=XFZkUNQ6amYrlSJHIBoQvrxmDXwQG-M7T9BPpqid9Bc,3500
|
13
|
-
hydraflow-0.3.3.dist-info/METADATA,sha256=IH_V71WNJTLRItKdVASVm99ZmfXWQYj365RL_qDC_aY,3840
|
14
|
-
hydraflow-0.3.3.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
|
15
|
-
hydraflow-0.3.3.dist-info/licenses/LICENSE,sha256=IGdDrBPqz1O0v_UwCW-NJlbX9Hy9b3uJ11t28y2srmY,1062
|
16
|
-
hydraflow-0.3.3.dist-info/RECORD,,
|
File without changes
|
File without changes
|