hydraflow 0.2.16__py3-none-any.whl → 0.2.17__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- hydraflow/param.py +64 -0
- hydraflow/run_collection.py +10 -28
- {hydraflow-0.2.16.dist-info → hydraflow-0.2.17.dist-info}/METADATA +1 -1
- {hydraflow-0.2.16.dist-info → hydraflow-0.2.17.dist-info}/RECORD +6 -5
- {hydraflow-0.2.16.dist-info → hydraflow-0.2.17.dist-info}/WHEEL +0 -0
- {hydraflow-0.2.16.dist-info → hydraflow-0.2.17.dist-info}/licenses/LICENSE +0 -0
hydraflow/param.py
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
|
3
|
+
from typing import Any
|
4
|
+
|
5
|
+
|
6
|
+
def match(param: str, value: Any) -> bool:
|
7
|
+
"""Check if the string matches the specified value.
|
8
|
+
|
9
|
+
Args:
|
10
|
+
param (str): The parameter to check.
|
11
|
+
value (Any): The value to check.
|
12
|
+
|
13
|
+
Returns:
|
14
|
+
True if the parameter matches the specified value,
|
15
|
+
False otherwise.
|
16
|
+
"""
|
17
|
+
if value in [None, True, False]:
|
18
|
+
return param == str(value)
|
19
|
+
|
20
|
+
if isinstance(value, list) and (m := _match_list(param, value)) is not None:
|
21
|
+
return m
|
22
|
+
|
23
|
+
if isinstance(value, tuple) and (m := _match_tuple(param, value)) is not None:
|
24
|
+
return m
|
25
|
+
|
26
|
+
if isinstance(value, int | float | str):
|
27
|
+
return type(value)(param) == value
|
28
|
+
|
29
|
+
return param == str(value)
|
30
|
+
|
31
|
+
|
32
|
+
def _match_list(param: str, value: list) -> bool | None:
|
33
|
+
if not value:
|
34
|
+
return None
|
35
|
+
|
36
|
+
if any(param.startswith(x) for x in ["[", "(", "{"]):
|
37
|
+
return None
|
38
|
+
|
39
|
+
if isinstance(value[0], bool):
|
40
|
+
return None
|
41
|
+
|
42
|
+
if not isinstance(value[0], int | float | str):
|
43
|
+
return None
|
44
|
+
|
45
|
+
return type(value[0])(param) in value
|
46
|
+
|
47
|
+
|
48
|
+
def _match_tuple(param: str, value: tuple) -> bool | None:
|
49
|
+
if len(value) != 2: # noqa: PLR2004
|
50
|
+
return None
|
51
|
+
|
52
|
+
if any(param.startswith(x) for x in ["[", "(", "{"]):
|
53
|
+
return None
|
54
|
+
|
55
|
+
if isinstance(value[0], bool):
|
56
|
+
return None
|
57
|
+
|
58
|
+
if not isinstance(value[0], int | float | str):
|
59
|
+
return None
|
60
|
+
|
61
|
+
if type(value[0]) is not type(value[1]):
|
62
|
+
return None
|
63
|
+
|
64
|
+
return value[0] <= type(value[0])(param) < value[1] # type: ignore
|
hydraflow/run_collection.py
CHANGED
@@ -23,6 +23,7 @@ from dataclasses import dataclass, field
|
|
23
23
|
from itertools import chain
|
24
24
|
from typing import TYPE_CHECKING, Any, Concatenate, ParamSpec, TypeVar, overload
|
25
25
|
|
26
|
+
import hydraflow.param
|
26
27
|
from hydraflow.config import iter_params
|
27
28
|
from hydraflow.info import RunCollectionInfo
|
28
29
|
|
@@ -86,6 +87,9 @@ class RunCollection:
|
|
86
87
|
def __contains__(self, run: Run) -> bool:
|
87
88
|
return run in self._runs
|
88
89
|
|
90
|
+
def __bool__(self) -> bool:
|
91
|
+
return bool(self._runs)
|
92
|
+
|
89
93
|
@classmethod
|
90
94
|
def from_list(cls, runs: list[Run]) -> RunCollection:
|
91
95
|
"""Create a `RunCollection` instance from a list of MLflow `Run` instances."""
|
@@ -569,37 +573,15 @@ class RunCollection:
|
|
569
573
|
|
570
574
|
|
571
575
|
def _param_matches(run: Run, key: str, value: Any) -> bool:
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
Check if the run's parameters contain the specified
|
576
|
-
key-value pair. It handles different types of values, including lists
|
577
|
-
and tuples.
|
578
|
-
|
579
|
-
Args:
|
580
|
-
run (Run): The run object to check.
|
581
|
-
key (str): The parameter key to check.
|
582
|
-
value (Any): The parameter value to check.
|
583
|
-
|
584
|
-
Returns:
|
585
|
-
True if the run's parameter matches the specified key-value pair,
|
586
|
-
False otherwise.
|
587
|
-
"""
|
588
|
-
param = run.data.params.get(key, value)
|
589
|
-
|
590
|
-
if param is None:
|
591
|
-
return False
|
576
|
+
params = run.data.params
|
577
|
+
if key not in params:
|
578
|
+
return True
|
592
579
|
|
580
|
+
param = params[key]
|
593
581
|
if param == "None":
|
594
|
-
return value is None
|
595
|
-
|
596
|
-
if isinstance(value, list) and value:
|
597
|
-
return type(value[0])(param) in value
|
598
|
-
|
599
|
-
if isinstance(value, tuple) and len(value) == 2: # noqa: PLR2004
|
600
|
-
return value[0] <= type(value[0])(param) < value[1]
|
582
|
+
return value is None or value == "None"
|
601
583
|
|
602
|
-
return
|
584
|
+
return hydraflow.param.match(param, value)
|
603
585
|
|
604
586
|
|
605
587
|
def filter_runs(
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: hydraflow
|
3
|
-
Version: 0.2.
|
3
|
+
Version: 0.2.17
|
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
|
@@ -4,10 +4,11 @@ hydraflow/config.py,sha256=YU6xYLinxq-Iqw1R3Zy7s3_u8nfpvnvXlGIkPXJTNLc,2116
|
|
4
4
|
hydraflow/context.py,sha256=4UDaWGoVmeF36UqsKoh6dd_cS_YVRfz80gFr28ouNlo,8040
|
5
5
|
hydraflow/info.py,sha256=7EsCMEH6LJZB3FZiQ3IpPFTD3Meaz7G3M-HvDQeo1rw,3466
|
6
6
|
hydraflow/mlflow.py,sha256=irD1INrVaI_1RIzUCjI36voBqgZszZ4dkSLo4aT1_FM,8271
|
7
|
+
hydraflow/param.py,sha256=W71zJH39s8cJcy3qV-PFQHJYyQnfa1GbnHOIqCMG3Jc,1573
|
7
8
|
hydraflow/progress.py,sha256=b5LvLm3d0eW3WsaidZAZotJNTTN3OwSY3XwxXXsJV9A,6561
|
8
9
|
hydraflow/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
9
|
-
hydraflow/run_collection.py,sha256=
|
10
|
-
hydraflow-0.2.
|
11
|
-
hydraflow-0.2.
|
12
|
-
hydraflow-0.2.
|
13
|
-
hydraflow-0.2.
|
10
|
+
hydraflow/run_collection.py,sha256=ym3M5ApEZVwJ1rYgOs4aYluTBfJeOECD6Z9SLFhv5O8,23260
|
11
|
+
hydraflow-0.2.17.dist-info/METADATA,sha256=uD6q000C_h2JsuFh0mkf1YmpTYxVDI1RLaAUKzZ6fDw,3819
|
12
|
+
hydraflow-0.2.17.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
|
13
|
+
hydraflow-0.2.17.dist-info/licenses/LICENSE,sha256=IGdDrBPqz1O0v_UwCW-NJlbX9Hy9b3uJ11t28y2srmY,1062
|
14
|
+
hydraflow-0.2.17.dist-info/RECORD,,
|
File without changes
|
File without changes
|