hydraflow 0.12.3__py3-none-any.whl → 0.12.4__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/core/io.py CHANGED
@@ -12,7 +12,7 @@ from hydra.core.hydra_config import HydraConfig
12
12
  from omegaconf import DictConfig, ListConfig, OmegaConf
13
13
 
14
14
  if TYPE_CHECKING:
15
- from collections.abc import Iterable, Iterator
15
+ from collections.abc import Callable, Iterable, Iterator
16
16
 
17
17
  from mlflow.entities import Run
18
18
 
@@ -179,8 +179,29 @@ def get_experiment_name(path: Path) -> str | None:
179
179
  return None
180
180
 
181
181
 
182
+ def predicate_experiment_dir(
183
+ path: Path,
184
+ experiment_names: list[str] | Callable[[str], bool] | None = None,
185
+ ) -> bool:
186
+ """Predicate an experiment directory based on the path and experiment names."""
187
+ if not path.is_dir() or path.name in [".trash", "0"]:
188
+ return False
189
+
190
+ name = get_experiment_name(path)
191
+ if not name:
192
+ return False
193
+
194
+ if experiment_names is None:
195
+ return True
196
+
197
+ if isinstance(experiment_names, list):
198
+ return name in experiment_names
199
+
200
+ return experiment_names(name)
201
+
202
+
182
203
  def iter_experiment_dirs(
183
- experiment_names: str | list[str] | None = None,
204
+ experiment_names: str | list[str] | Callable[[str], bool] | None = None,
184
205
  root_dir: str | Path | None = None,
185
206
  ) -> Iterator[Path]:
186
207
  """Iterate over the experiment directories in the root directory."""
@@ -189,14 +210,12 @@ def iter_experiment_dirs(
189
210
 
190
211
  root_dir = get_root_dir(root_dir)
191
212
  for path in root_dir.iterdir():
192
- if path.is_dir() and path.name not in [".trash", "0"]:
193
- if name := get_experiment_name(path):
194
- if experiment_names is None or name in experiment_names:
195
- yield path
213
+ if predicate_experiment_dir(path, experiment_names):
214
+ yield path
196
215
 
197
216
 
198
217
  def iter_run_dirs(
199
- experiment_names: str | list[str] | None = None,
218
+ experiment_names: str | list[str] | Callable[[str], bool] | None = None,
200
219
  root_dir: str | Path | None = None,
201
220
  ) -> Iterator[Path]:
202
221
  """Iterate over the run directories in the root directory."""
@@ -207,7 +226,7 @@ def iter_run_dirs(
207
226
 
208
227
 
209
228
  def iter_artifacts_dirs(
210
- experiment_names: str | list[str] | None = None,
229
+ experiment_names: str | list[str] | Callable[[str], bool] | None = None,
211
230
  root_dir: str | Path | None = None,
212
231
  ) -> Iterator[Path]:
213
232
  """Iterate over the artifacts directories in the root directory."""
@@ -217,7 +236,7 @@ def iter_artifacts_dirs(
217
236
 
218
237
  def iter_artifact_paths(
219
238
  artifact_path: str | Path,
220
- experiment_names: str | list[str] | None = None,
239
+ experiment_names: str | list[str] | Callable[[str], bool] | None = None,
221
240
  root_dir: str | Path | None = None,
222
241
  ) -> Iterator[Path]:
223
242
  """Iterate over the artifact paths in the root directory."""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hydraflow
3
- Version: 0.12.3
3
+ Version: 0.12.4
4
4
  Summary: Hydraflow integrates Hydra and MLflow to manage and track machine learning experiments.
5
5
  Project-URL: Documentation, https://daizutabi.github.io/hydraflow/
6
6
  Project-URL: Source, https://github.com/daizutabi/hydraflow
@@ -4,7 +4,7 @@ hydraflow/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  hydraflow/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  hydraflow/core/config.py,sha256=SJzjgsO_kzB78_whJ3lmy7GlZvTvwZONH1BJBn8zCuI,3817
6
6
  hydraflow/core/context.py,sha256=L4OygMLbITwlWzq17Lh8VoXKKtjOJ3DBEVsBddKPSJ8,4741
7
- hydraflow/core/io.py,sha256=7rVEcXus0tES2qZIckIOcBxc9Br-nSEdWzGGA7JedB0,6796
7
+ hydraflow/core/io.py,sha256=6ZQYqxPUkIinFYqSQXJPzTSnuhfP1KfFchTNeNn-g6A,7311
8
8
  hydraflow/core/main.py,sha256=dY8uUykS_AbzverrSWkXLyj98TjBPHAiMUf_l5met1U,5162
9
9
  hydraflow/core/mlflow.py,sha256=OQJ3f2wkHJRb11ZK__HF4R8FyBEje7-NOqObpoanGhU,5704
10
10
  hydraflow/core/param.py,sha256=LHU9j9_7oA99igasoOyKofKClVr9FmGA3UABJ-KmyS0,4538
@@ -17,8 +17,8 @@ hydraflow/executor/conf.py,sha256=2dv6_PlsynRmia-fGZlmBEVt8GopT0f32N13qY7tYnM,40
17
17
  hydraflow/executor/io.py,sha256=yZMcBVmAbPZZ82cAXhgiJfj9p8WvHmzOCMBg_vtEVek,1509
18
18
  hydraflow/executor/job.py,sha256=IL7ek0Vwa3Bl_gANq0wCbldNCUclo8YBckeEeO6W6xg,4852
19
19
  hydraflow/executor/parser.py,sha256=_Rfund3FDgrXitTt_znsTpgEtMDqZ_ICynaB_Zje14Q,14561
20
- hydraflow-0.12.3.dist-info/METADATA,sha256=Rlwy1HJ4yI5O7bKLSZhZ1JhKIz3tL8Z-TGsREPhfUpw,4549
21
- hydraflow-0.12.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
22
- hydraflow-0.12.3.dist-info/entry_points.txt,sha256=XI0khPbpCIUo9UPqkNEpgh-kqK3Jy8T7L2VCWOdkbSM,48
23
- hydraflow-0.12.3.dist-info/licenses/LICENSE,sha256=IGdDrBPqz1O0v_UwCW-NJlbX9Hy9b3uJ11t28y2srmY,1062
24
- hydraflow-0.12.3.dist-info/RECORD,,
20
+ hydraflow-0.12.4.dist-info/METADATA,sha256=CT9bb--1HhyO_tcahfCTzSUBH2nWt7i2lY2pS3Dac38,4549
21
+ hydraflow-0.12.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
22
+ hydraflow-0.12.4.dist-info/entry_points.txt,sha256=XI0khPbpCIUo9UPqkNEpgh-kqK3Jy8T7L2VCWOdkbSM,48
23
+ hydraflow-0.12.4.dist-info/licenses/LICENSE,sha256=IGdDrBPqz1O0v_UwCW-NJlbX9Hy9b3uJ11t28y2srmY,1062
24
+ hydraflow-0.12.4.dist-info/RECORD,,