hydraflow 0.9.0__py3-none-any.whl → 0.9.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.
hydraflow/__init__.py CHANGED
@@ -5,6 +5,10 @@ from hydraflow.core.io import (
5
5
  get_artifact_dir,
6
6
  get_artifact_path,
7
7
  get_hydra_output_dir,
8
+ iter_artifact_paths,
9
+ iter_artifacts_dirs,
10
+ iter_experiment_dirs,
11
+ iter_run_dirs,
8
12
  load_config,
9
13
  remove_run,
10
14
  )
@@ -18,6 +22,10 @@ __all__ = [
18
22
  "get_artifact_dir",
19
23
  "get_artifact_path",
20
24
  "get_hydra_output_dir",
25
+ "iter_artifact_paths",
26
+ "iter_artifacts_dirs",
27
+ "iter_experiment_dirs",
28
+ "iter_run_dirs",
21
29
  "list_run_ids",
22
30
  "list_run_paths",
23
31
  "list_runs",
hydraflow/core/io.py CHANGED
@@ -15,7 +15,7 @@ from mlflow.entities import Run
15
15
  from omegaconf import DictConfig, ListConfig, OmegaConf
16
16
 
17
17
  if TYPE_CHECKING:
18
- from collections.abc import Iterable
18
+ from collections.abc import Iterable, Iterator
19
19
 
20
20
 
21
21
  def file_uri_to_path(uri: str) -> Path:
@@ -147,3 +147,74 @@ def remove_run(run: Run | Iterable[Run]) -> None:
147
147
  return
148
148
 
149
149
  shutil.rmtree(get_artifact_dir(run).parent)
150
+
151
+
152
+ def get_root_dir(uri: str | Path | None = None) -> Path:
153
+ """Get the root directory for the MLflow tracking server."""
154
+ if uri is not None:
155
+ return Path(uri).absolute()
156
+
157
+ uri = mlflow.get_tracking_uri()
158
+
159
+ if uri.startswith("file:"):
160
+ return file_uri_to_path(uri)
161
+
162
+ return Path(uri).absolute()
163
+
164
+
165
+ def get_experiment_name(path: Path) -> str | None:
166
+ """Get the experiment name from the meta file."""
167
+ metafile = path / "meta.yaml"
168
+ if not metafile.exists():
169
+ return None
170
+ lines = metafile.read_text().splitlines()
171
+ for line in lines:
172
+ if line.startswith("name:"):
173
+ return line.split(":")[1].strip()
174
+ return None
175
+
176
+
177
+ def iter_experiment_dirs(
178
+ experiment_names: str | list[str] | None = None,
179
+ root_dir: str | Path | None = None,
180
+ ) -> Iterator[Path]:
181
+ """Iterate over the experiment directories in the root directory."""
182
+ if isinstance(experiment_names, str):
183
+ experiment_names = [experiment_names]
184
+
185
+ root_dir = get_root_dir(root_dir)
186
+ for path in root_dir.iterdir():
187
+ if path.is_dir() and path.name not in [".trash", "0"]:
188
+ if name := get_experiment_name(path):
189
+ if experiment_names is None or name in experiment_names:
190
+ yield path
191
+
192
+
193
+ def iter_run_dirs(
194
+ experiment_names: str | list[str] | None = None,
195
+ root_dir: str | Path | None = None,
196
+ ) -> Iterator[Path]:
197
+ """Iterate over the run directories in the root directory."""
198
+ for experiment_dir in iter_experiment_dirs(experiment_names, root_dir):
199
+ for path in experiment_dir.iterdir():
200
+ if path.is_dir() and (path / "artifacts").exists():
201
+ yield path
202
+
203
+
204
+ def iter_artifacts_dirs(
205
+ experiment_names: str | list[str] | None = None,
206
+ root_dir: str | Path | None = None,
207
+ ) -> Iterator[Path]:
208
+ """Iterate over the artifacts directories in the root directory."""
209
+ for path in iter_run_dirs(experiment_names, root_dir):
210
+ yield path / "artifacts"
211
+
212
+
213
+ def iter_artifact_paths(
214
+ artifact_path: str | Path,
215
+ experiment_names: str | list[str] | None = None,
216
+ root_dir: str | Path | None = None,
217
+ ) -> Iterator[Path]:
218
+ """Iterate over the artifact paths in the root directory."""
219
+ for path in iter_artifacts_dirs(experiment_names, root_dir):
220
+ yield path / artifact_path
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hydraflow
3
- Version: 0.9.0
3
+ Version: 0.9.1
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
@@ -1,10 +1,10 @@
1
- hydraflow/__init__.py,sha256=WnReG-E2paQSMLJm42N-KaQyHYsfA4OX-WWcst610PI,738
1
+ hydraflow/__init__.py,sha256=f2KO2iF7um-nNmayNyEr7TWG4UICOXy7YAN1d3qu0OY,936
2
2
  hydraflow/cli.py,sha256=gbDPj49azP8CCGxkxU0rksh1-gCyjP0VkVYH34ktcsA,1338
3
3
  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=QPyPg1xrTlmhviKNn-0nDY9bXcVky1zInqRqPN-VNhc,4741
7
- hydraflow/core/io.py,sha256=T4ESiepEcqR-FZlo_m7VTBEFMwalrqPI8eFKPagvv3Q,4402
7
+ hydraflow/core/io.py,sha256=KK9_mkx4XnBgA63Ab-g833N5q9aCsSrJR-7pp6unEKw,6746
8
8
  hydraflow/core/main.py,sha256=gYb1OOVH0CL4385Dm-06Mqi1Mr9-24URwLUiW86pGNs,5018
9
9
  hydraflow/core/mlflow.py,sha256=M3MhiChnMzKnKRmjBl4h_SRGkAZKL7GAmFr3DdzwRuQ,5666
10
10
  hydraflow/core/param.py,sha256=LHU9j9_7oA99igasoOyKofKClVr9FmGA3UABJ-KmyS0,4538
@@ -17,8 +17,8 @@ hydraflow/executor/conf.py,sha256=q_FrPXQJCVGKS1FYnGRGqTUgMQeMBkaVPW2mtQc8oxk,38
17
17
  hydraflow/executor/io.py,sha256=4nafwge6vHanYFuEHxd0LRv_3ZLgMpV50qSbssZNe3Q,696
18
18
  hydraflow/executor/job.py,sha256=Vp2IZOuIC25Gqo9A_5MkllWl1T1QBfUnI5ksMvKwakg,4479
19
19
  hydraflow/executor/parser.py,sha256=y4C9wVdUnazJDxdWrT5y3yWFIo0zAGzO-cS9x1MTK_8,9486
20
- hydraflow-0.9.0.dist-info/METADATA,sha256=p8-vmPIYV-uU9BJbSB1roqrhNO7nK2HRdrpj8Tip1AA,4559
21
- hydraflow-0.9.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
22
- hydraflow-0.9.0.dist-info/entry_points.txt,sha256=XI0khPbpCIUo9UPqkNEpgh-kqK3Jy8T7L2VCWOdkbSM,48
23
- hydraflow-0.9.0.dist-info/licenses/LICENSE,sha256=IGdDrBPqz1O0v_UwCW-NJlbX9Hy9b3uJ11t28y2srmY,1062
24
- hydraflow-0.9.0.dist-info/RECORD,,
20
+ hydraflow-0.9.1.dist-info/METADATA,sha256=Lf2rS7gDBJ-4s4lPtsCg2-S8mSIlZoJoyVJarel_pQk,4559
21
+ hydraflow-0.9.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
22
+ hydraflow-0.9.1.dist-info/entry_points.txt,sha256=XI0khPbpCIUo9UPqkNEpgh-kqK3Jy8T7L2VCWOdkbSM,48
23
+ hydraflow-0.9.1.dist-info/licenses/LICENSE,sha256=IGdDrBPqz1O0v_UwCW-NJlbX9Hy9b3uJ11t28y2srmY,1062
24
+ hydraflow-0.9.1.dist-info/RECORD,,