hydraflow 0.4.0__py3-none-any.whl → 0.4.2__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.
- hydraflow/context.py +1 -0
- hydraflow/mlflow.py +1 -0
- hydraflow/param.py +89 -5
- hydraflow/run_collection.py +68 -47
- hydraflow/utils.py +1 -0
- {hydraflow-0.4.0.dist-info → hydraflow-0.4.2.dist-info}/METADATA +1 -1
- hydraflow-0.4.2.dist-info/RECORD +16 -0
- hydraflow-0.4.0.dist-info/RECORD +0 -16
- {hydraflow-0.4.0.dist-info → hydraflow-0.4.2.dist-info}/WHEEL +0 -0
- {hydraflow-0.4.0.dist-info → hydraflow-0.4.2.dist-info}/licenses/LICENSE +0 -0
hydraflow/context.py
CHANGED
@@ -10,6 +10,7 @@ from pathlib import Path
|
|
10
10
|
from typing import TYPE_CHECKING
|
11
11
|
|
12
12
|
import mlflow
|
13
|
+
import mlflow.artifacts
|
13
14
|
from hydra.core.hydra_config import HydraConfig
|
14
15
|
from watchdog.events import FileModifiedEvent, PatternMatchingEventHandler
|
15
16
|
from watchdog.observers import Observer
|
hydraflow/mlflow.py
CHANGED
@@ -21,6 +21,7 @@ from typing import TYPE_CHECKING
|
|
21
21
|
|
22
22
|
import joblib
|
23
23
|
import mlflow
|
24
|
+
import mlflow.artifacts
|
24
25
|
from hydra.core.hydra_config import HydraConfig
|
25
26
|
from mlflow.entities import ViewType
|
26
27
|
from mlflow.tracking.fluent import SEARCH_MAX_RESULTS_PANDAS, _get_experiment_id
|
hydraflow/param.py
CHANGED
@@ -10,7 +10,12 @@ matching for list and tuple types respectively.
|
|
10
10
|
|
11
11
|
from __future__ import annotations
|
12
12
|
|
13
|
-
from typing import Any
|
13
|
+
from typing import TYPE_CHECKING, Any
|
14
|
+
|
15
|
+
from omegaconf import ListConfig, OmegaConf
|
16
|
+
|
17
|
+
if TYPE_CHECKING:
|
18
|
+
from mlflow.entities import Run
|
14
19
|
|
15
20
|
|
16
21
|
def match(param: str, value: Any) -> bool:
|
@@ -25,7 +30,7 @@ def match(param: str, value: Any) -> bool:
|
|
25
30
|
False otherwise.
|
26
31
|
|
27
32
|
"""
|
28
|
-
if value in [None, True, False]:
|
33
|
+
if any(value is x for x in [None, True, False]):
|
29
34
|
return param == str(value)
|
30
35
|
|
31
36
|
if isinstance(value, list) and (m := _match_list(param, value)) is not None:
|
@@ -34,12 +39,12 @@ def match(param: str, value: Any) -> bool:
|
|
34
39
|
if isinstance(value, tuple) and (m := _match_tuple(param, value)) is not None:
|
35
40
|
return m
|
36
41
|
|
42
|
+
if isinstance(value, int | float):
|
43
|
+
return float(param) == value
|
44
|
+
|
37
45
|
if isinstance(value, str):
|
38
46
|
return param == value
|
39
47
|
|
40
|
-
if isinstance(value, int | float):
|
41
|
-
return type(value)(param) == value
|
42
|
-
|
43
48
|
return param == str(value)
|
44
49
|
|
45
50
|
|
@@ -76,3 +81,82 @@ def _match_tuple(param: str, value: tuple) -> bool | None:
|
|
76
81
|
return None
|
77
82
|
|
78
83
|
return value[0] <= type(value[0])(param) <= value[1] # type: ignore
|
84
|
+
|
85
|
+
|
86
|
+
def to_value(param: str | None, type_: type) -> Any:
|
87
|
+
"""Convert the parameter to the specified type.
|
88
|
+
|
89
|
+
Args:
|
90
|
+
param (str | None): The parameter to convert.
|
91
|
+
type_ (type): The type to convert to.
|
92
|
+
|
93
|
+
Returns:
|
94
|
+
The converted value.
|
95
|
+
|
96
|
+
"""
|
97
|
+
if param is None or param == "None":
|
98
|
+
return None
|
99
|
+
|
100
|
+
if type_ is int:
|
101
|
+
return int(param)
|
102
|
+
|
103
|
+
if type_ is float:
|
104
|
+
return float(param)
|
105
|
+
|
106
|
+
if type_ is bool:
|
107
|
+
return param == "True"
|
108
|
+
|
109
|
+
if type_ is list or type_ is ListConfig:
|
110
|
+
return list(OmegaConf.create(param))
|
111
|
+
|
112
|
+
return param
|
113
|
+
|
114
|
+
|
115
|
+
def get_params(run: Run, *names: str | list[str]) -> tuple[str | None, ...]:
|
116
|
+
"""Retrieve the values of specified parameters from the given run.
|
117
|
+
|
118
|
+
This function extracts the values of the parameters identified by the
|
119
|
+
provided names from the specified run. It can accept both individual
|
120
|
+
parameter names and lists of parameter names.
|
121
|
+
|
122
|
+
Args:
|
123
|
+
run (Run): The run object from which to extract parameter values.
|
124
|
+
*names (str | list[str]): The names of the parameters to retrieve.
|
125
|
+
This can be a single parameter name or multiple names provided
|
126
|
+
as separate arguments or as a list.
|
127
|
+
|
128
|
+
Returns:
|
129
|
+
tuple[str | None, ...]: A tuple containing the values of the specified
|
130
|
+
parameters in the order they were provided.
|
131
|
+
|
132
|
+
"""
|
133
|
+
names_ = []
|
134
|
+
for name in names:
|
135
|
+
if isinstance(name, list):
|
136
|
+
names_.extend(name)
|
137
|
+
else:
|
138
|
+
names_.append(name)
|
139
|
+
|
140
|
+
params = run.data.params
|
141
|
+
return tuple(params.get(name) for name in names_)
|
142
|
+
|
143
|
+
|
144
|
+
def get_values(run: Run, names: list[str], types: list[type]) -> tuple[Any, ...]:
|
145
|
+
"""Retrieve the values of specified parameters from the given run.
|
146
|
+
|
147
|
+
This function extracts the values of the parameters identified by the
|
148
|
+
provided names from the specified run.
|
149
|
+
|
150
|
+
Args:
|
151
|
+
run (Run): The run object from which to extract parameter values.
|
152
|
+
names (list[str]): The names of the parameters to retrieve.
|
153
|
+
types (list[type]): The types to convert to.
|
154
|
+
|
155
|
+
Returns:
|
156
|
+
tuple[Any, ...]: A tuple containing the values of the specified
|
157
|
+
parameters in the order they were provided.
|
158
|
+
|
159
|
+
"""
|
160
|
+
params = get_params(run, names)
|
161
|
+
it = zip(params, types, strict=True)
|
162
|
+
return tuple(to_value(param, type_) for param, type_ in it)
|
hydraflow/run_collection.py
CHANGED
@@ -27,6 +27,7 @@ from mlflow.entities import RunStatus
|
|
27
27
|
|
28
28
|
import hydraflow.param
|
29
29
|
from hydraflow.config import iter_params, select_config, select_overrides
|
30
|
+
from hydraflow.param import get_params, get_values
|
30
31
|
from hydraflow.run_data import RunCollectionData
|
31
32
|
from hydraflow.run_info import RunCollectionInfo
|
32
33
|
from hydraflow.utils import load_config
|
@@ -132,25 +133,6 @@ class RunCollection:
|
|
132
133
|
|
133
134
|
return self.__class__(self._runs[:n])
|
134
135
|
|
135
|
-
def sort(
|
136
|
-
self,
|
137
|
-
key: Callable[[Run], Any] | None = None,
|
138
|
-
*,
|
139
|
-
reverse: bool = False,
|
140
|
-
) -> None:
|
141
|
-
"""Sort the runs in the collection.
|
142
|
-
|
143
|
-
Sort the runs in the collection according to the provided key function
|
144
|
-
and optional reverse flag.
|
145
|
-
|
146
|
-
Args:
|
147
|
-
key (Callable[[Run], Any] | None): A function that takes a run and returns
|
148
|
-
a value to sort by.
|
149
|
-
reverse (bool): If True, sort in descending order.
|
150
|
-
|
151
|
-
"""
|
152
|
-
self._runs.sort(key=key or (lambda x: x.info.start_time), reverse=reverse)
|
153
|
-
|
154
136
|
def one(self) -> Run:
|
155
137
|
"""Get the only `Run` instance in the collection.
|
156
138
|
|
@@ -599,6 +581,73 @@ class RunCollection:
|
|
599
581
|
|
600
582
|
return {key: RunCollection(runs) for key, runs in grouped_runs.items()}
|
601
583
|
|
584
|
+
def sort(
|
585
|
+
self,
|
586
|
+
key: Callable[[Run], Any] | None = None,
|
587
|
+
*,
|
588
|
+
reverse: bool = False,
|
589
|
+
) -> None:
|
590
|
+
"""Sort the runs in the collection.
|
591
|
+
|
592
|
+
Sort the runs in the collection according to the provided key function
|
593
|
+
and optional reverse flag.
|
594
|
+
|
595
|
+
Args:
|
596
|
+
key (Callable[[Run], Any] | None): A function that takes a run and returns
|
597
|
+
a value to sort by.
|
598
|
+
reverse (bool): If True, sort in descending order.
|
599
|
+
|
600
|
+
"""
|
601
|
+
self._runs.sort(key=key or (lambda x: x.info.start_time), reverse=reverse)
|
602
|
+
|
603
|
+
def values(self, names: str | list[str]) -> list[Any]:
|
604
|
+
"""Get the values of specified parameters from the runs.
|
605
|
+
|
606
|
+
Args:
|
607
|
+
names (str | list[str]): The names of the parameters to get the values.
|
608
|
+
This can be a single parameter name or multiple names provided
|
609
|
+
as separate arguments or as a list.
|
610
|
+
|
611
|
+
Returns:
|
612
|
+
A list of values for the specified parameters.
|
613
|
+
|
614
|
+
"""
|
615
|
+
is_list = isinstance(names, list)
|
616
|
+
|
617
|
+
if isinstance(names, str):
|
618
|
+
names = [names]
|
619
|
+
|
620
|
+
config = load_config(self.first())
|
621
|
+
types = [type(v) for v in select_config(config, names).values()]
|
622
|
+
values = [get_values(run, names, types) for run in self]
|
623
|
+
|
624
|
+
if is_list:
|
625
|
+
return values
|
626
|
+
|
627
|
+
return [v[0] for v in values]
|
628
|
+
|
629
|
+
def sort_by(
|
630
|
+
self,
|
631
|
+
names: str | list[str],
|
632
|
+
*,
|
633
|
+
reverse: bool = False,
|
634
|
+
) -> RunCollection:
|
635
|
+
"""Sort the runs in the collection by specified parameter names.
|
636
|
+
|
637
|
+
Sort the runs in the collection based on the values of the specified
|
638
|
+
parameters.
|
639
|
+
|
640
|
+
Args:
|
641
|
+
names (str | list[str]): The names of the parameters to sort by.
|
642
|
+
This can be a single parameter name or multiple names provided
|
643
|
+
as separate arguments or as a list.
|
644
|
+
reverse (bool): If True, sort in descending order.
|
645
|
+
|
646
|
+
"""
|
647
|
+
values = self.values(names)
|
648
|
+
index = sorted(range(len(self)), key=lambda i: values[i], reverse=reverse)
|
649
|
+
return RunCollection([self[i] for i in index])
|
650
|
+
|
602
651
|
|
603
652
|
def _param_matches(run: Run, key: str, value: Any) -> bool:
|
604
653
|
params = run.data.params
|
@@ -703,31 +752,3 @@ def _to_lower(status: str | int) -> str:
|
|
703
752
|
return status.lower()
|
704
753
|
|
705
754
|
return RunStatus.to_string(status).lower()
|
706
|
-
|
707
|
-
|
708
|
-
def get_params(run: Run, *names: str | list[str]) -> tuple[str | None, ...]:
|
709
|
-
"""Retrieve the values of specified parameters from the given run.
|
710
|
-
|
711
|
-
This function extracts the values of the parameters identified by the
|
712
|
-
provided names from the specified run. It can accept both individual
|
713
|
-
parameter names and lists of parameter names.
|
714
|
-
|
715
|
-
Args:
|
716
|
-
run (Run): The run object from which to extract parameter values.
|
717
|
-
*names (str | list[str]): The names of the parameters to retrieve.
|
718
|
-
This can be a single parameter name or multiple names provided
|
719
|
-
as separate arguments or as a list.
|
720
|
-
|
721
|
-
Returns:
|
722
|
-
tuple[str | None, ...]: A tuple containing the values of the specified
|
723
|
-
parameters in the order they were provided.
|
724
|
-
|
725
|
-
"""
|
726
|
-
names_ = []
|
727
|
-
for name in names:
|
728
|
-
if isinstance(name, list):
|
729
|
-
names_.extend(name)
|
730
|
-
else:
|
731
|
-
names_.append(name)
|
732
|
-
|
733
|
-
return tuple(run.data.params.get(name) for name in names_)
|
hydraflow/utils.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: hydraflow
|
3
|
-
Version: 0.4.
|
3
|
+
Version: 0.4.2
|
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=VbrHKs2Cg93QJ8K9WHYxkXmzOpb8o9ugiwV-mXDT0JE,908
|
2
|
+
hydraflow/asyncio.py,sha256=-i1C8KAmNDImrjHnk92Csaa1mpjdK8Vp4ZVaQV-l94s,6634
|
3
|
+
hydraflow/config.py,sha256=MNX9da5bPVDcjnpji7Cm9ndK6ura92pt361m4PRh6_E,4326
|
4
|
+
hydraflow/context.py,sha256=a6bHmiY16hZ1wvzVzoa7eGDBFjz0GX0iuZNG0EW0wkE,8764
|
5
|
+
hydraflow/mlflow.py,sha256=kWVK_Xw2hkRnTg33jSP3VW13UZF6_hBGhN52mPmLgvk,8753
|
6
|
+
hydraflow/param.py,sha256=c5sc6NwD6DKwZzVwprXzZD5FSi6qRgSHkc6TXBKQEdg,4502
|
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=zO7OARn0QOGeK3FQH8GnuuDKCnYFqn1fbsKnOuGCa9M,25938
|
10
|
+
hydraflow/run_data.py,sha256=qeFX1iRvNAorXA9QQIjzr0o2_82TI44eZKp7llKG8GI,1549
|
11
|
+
hydraflow/run_info.py,sha256=sMXOo20ClaRIommMEzuAbO_OrcXx7M1Yt4FMV7spxz0,998
|
12
|
+
hydraflow/utils.py,sha256=Xq78F2iOkgi9JnCYfX1reQw_Y9K6o8oNYBDEwrf18cI,3552
|
13
|
+
hydraflow-0.4.2.dist-info/METADATA,sha256=YFnNdasT6OaEKeQy8Uw7AH3uZ5ecjbDjvXSsclhvoJc,3840
|
14
|
+
hydraflow-0.4.2.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
|
15
|
+
hydraflow-0.4.2.dist-info/licenses/LICENSE,sha256=IGdDrBPqz1O0v_UwCW-NJlbX9Hy9b3uJ11t28y2srmY,1062
|
16
|
+
hydraflow-0.4.2.dist-info/RECORD,,
|
hydraflow-0.4.0.dist-info/RECORD
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
hydraflow/__init__.py,sha256=VbrHKs2Cg93QJ8K9WHYxkXmzOpb8o9ugiwV-mXDT0JE,908
|
2
|
-
hydraflow/asyncio.py,sha256=-i1C8KAmNDImrjHnk92Csaa1mpjdK8Vp4ZVaQV-l94s,6634
|
3
|
-
hydraflow/config.py,sha256=MNX9da5bPVDcjnpji7Cm9ndK6ura92pt361m4PRh6_E,4326
|
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=-PEN8vO4beQkxhEQH9xh0_TzEIO34-eulwRt7WidrIA,25295
|
10
|
-
hydraflow/run_data.py,sha256=qeFX1iRvNAorXA9QQIjzr0o2_82TI44eZKp7llKG8GI,1549
|
11
|
-
hydraflow/run_info.py,sha256=sMXOo20ClaRIommMEzuAbO_OrcXx7M1Yt4FMV7spxz0,998
|
12
|
-
hydraflow/utils.py,sha256=gNI0Ln2VBHfMBzNB9SNxJfjCLf14irYt0EBeeMXMeyk,3528
|
13
|
-
hydraflow-0.4.0.dist-info/METADATA,sha256=w0gsff6RLwx4l8_Qlw-1SOu0dY4ySPCq2psm0THmvcY,3840
|
14
|
-
hydraflow-0.4.0.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
|
15
|
-
hydraflow-0.4.0.dist-info/licenses/LICENSE,sha256=IGdDrBPqz1O0v_UwCW-NJlbX9Hy9b3uJ11t28y2srmY,1062
|
16
|
-
hydraflow-0.4.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|