hydraflow 0.2.11__py3-none-any.whl → 0.2.12__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
hydraflow/mlflow.py CHANGED
@@ -22,6 +22,7 @@ from __future__ import annotations
22
22
  from pathlib import Path
23
23
  from typing import TYPE_CHECKING
24
24
 
25
+ import joblib
25
26
  import mlflow
26
27
  from hydra.core.hydra_config import HydraConfig
27
28
  from mlflow.entities import ViewType
@@ -146,7 +147,9 @@ def search_runs(
146
147
  return RunCollection(runs) # type: ignore
147
148
 
148
149
 
149
- def list_runs(experiment_names: list[str] | None = None) -> RunCollection:
150
+ def list_runs(
151
+ experiment_names: str | list[str] | None = None, *, n_jobs: int = 0
152
+ ) -> RunCollection:
150
153
  """
151
154
  List all runs for the specified experiments.
152
155
 
@@ -168,8 +171,30 @@ def list_runs(experiment_names: list[str] | None = None) -> RunCollection:
168
171
  Returns:
169
172
  A `RunCollection` object containing the runs for the specified experiments.
170
173
  """
171
- if experiment_names == []:
174
+ if isinstance(experiment_names, str):
175
+ experiment_names = [experiment_names]
176
+
177
+ elif experiment_names == []:
172
178
  experiments = mlflow.search_experiments()
173
179
  experiment_names = [e.name for e in experiments if e.name != "Default"]
174
180
 
175
- return search_runs(experiment_names=experiment_names)
181
+ if n_jobs == 0:
182
+ return search_runs(experiment_names=experiment_names)
183
+
184
+ if experiment_names is None:
185
+ raise NotImplementedError
186
+
187
+ run_ids = []
188
+
189
+ for name in experiment_names:
190
+ if experiment := mlflow.get_experiment_by_name(name):
191
+ loc = experiment.artifact_location
192
+
193
+ if isinstance(loc, str) and loc.startswith("file://"):
194
+ path = Path(mlflow.artifacts.download_artifacts(loc))
195
+ run_ids.extend(file.stem for file in path.iterdir() if file.is_dir())
196
+
197
+ it = (joblib.delayed(mlflow.get_run)(run_id) for run_id in run_ids)
198
+ runs = joblib.Parallel(n_jobs, prefer="threads")(it)
199
+ runs = sorted(runs, key=lambda run: run.info.start_time) # type: ignore
200
+ return RunCollection(runs) # type: ignore
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: hydraflow
3
- Version: 0.2.11
3
+ Version: 0.2.12
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
@@ -3,10 +3,10 @@ hydraflow/asyncio.py,sha256=jdXuEFC6f7L_Dq6beASFZPQSvCnGimVxU-PRFsNc5U0,6241
3
3
  hydraflow/config.py,sha256=6TCKNQZ3sSrIEvl245T2udwFuknejyN1dMcIVmOHdrQ,2102
4
4
  hydraflow/context.py,sha256=G7JMrG70sgBH2qILXl5nkGWNUoRggj518JWUq0ZiJ9E,7776
5
5
  hydraflow/info.py,sha256=Vj2sT66Ric63mmaq7Yu8nDFhsGQYO3MCHrxFpapDufc,3458
6
- hydraflow/mlflow.py,sha256=Q8RGijSURTjRkEDxzi_2Tk9KOx3QK__al5aArGQriHA,7249
6
+ hydraflow/mlflow.py,sha256=YWfq_d8qG6d3k7GC3hWJ7hYHGMiSZ4CnJEyr4vU8t6U,8118
7
7
  hydraflow/progress.py,sha256=uaxS9UnwsikOPB_Ho-5mXdBYz3Zedj-SL9FzT094wjY,6623
8
8
  hydraflow/run_collection.py,sha256=V5lGdGHYgsSpBOYGaVEL1mpKJvdiEshBL0KmmZ8qeZo,29161
9
- hydraflow-0.2.11.dist-info/METADATA,sha256=skZKh1wvBJWSLXE7iB6q2Gv_NsegcuJQjmmv8KgFg8s,4182
10
- hydraflow-0.2.11.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
11
- hydraflow-0.2.11.dist-info/licenses/LICENSE,sha256=IGdDrBPqz1O0v_UwCW-NJlbX9Hy9b3uJ11t28y2srmY,1062
12
- hydraflow-0.2.11.dist-info/RECORD,,
9
+ hydraflow-0.2.12.dist-info/METADATA,sha256=BIdR4v_bxeeQn4lYS7d4j331cz57HeOkkBtg6FK6YrQ,4182
10
+ hydraflow-0.2.12.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
11
+ hydraflow-0.2.12.dist-info/licenses/LICENSE,sha256=IGdDrBPqz1O0v_UwCW-NJlbX9Hy9b3uJ11t28y2srmY,1062
12
+ hydraflow-0.2.12.dist-info/RECORD,,