hydraflow 0.5.1__py3-none-any.whl → 0.5.3__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
hydraflow/__init__.py CHANGED
@@ -6,6 +6,7 @@ from .mlflow import list_runs, search_runs, set_experiment
6
6
  from .run_collection import RunCollection
7
7
  from .utils import (
8
8
  get_artifact_dir,
9
+ get_artifact_path,
9
10
  get_hydra_output_dir,
10
11
  get_overrides,
11
12
  load_config,
@@ -18,6 +19,7 @@ __all__ = [
18
19
  "chdir_artifact",
19
20
  "chdir_hydra_output",
20
21
  "get_artifact_dir",
22
+ "get_artifact_path",
21
23
  "get_hydra_output_dir",
22
24
  "get_overrides",
23
25
  "list_runs",
hydraflow/mlflow.py CHANGED
@@ -37,6 +37,7 @@ def set_experiment(
37
37
  prefix: str = "",
38
38
  suffix: str = "",
39
39
  uri: str | Path | None = None,
40
+ name: str | None = None,
40
41
  ) -> Experiment:
41
42
  """Set the experiment name and tracking URI optionally.
42
43
 
@@ -48,6 +49,7 @@ def set_experiment(
48
49
  prefix (str): The prefix to prepend to the experiment name.
49
50
  suffix (str): The suffix to append to the experiment name.
50
51
  uri (str | Path | None): The tracking URI to use. Defaults to None.
52
+ name (str | None): The name of the experiment. Defaults to None.
51
53
 
52
54
  Returns:
53
55
  Experiment: An instance of `mlflow.entities.Experiment` representing
@@ -57,6 +59,9 @@ def set_experiment(
57
59
  if uri is not None:
58
60
  mlflow.set_tracking_uri(uri)
59
61
 
62
+ if name is not None:
63
+ return mlflow.set_experiment(name)
64
+
60
65
  hc = HydraConfig.get()
61
66
  name = f"{prefix}{hc.job.name}{suffix}"
62
67
  return mlflow.set_experiment(name)
@@ -209,12 +214,12 @@ def _list_runs(
209
214
  loc = experiment.artifact_location
210
215
 
211
216
  if isinstance(loc, str):
212
- if loc.startswith("file://"):
217
+ if loc.startswith("file:"):
213
218
  path = Path(mlflow.artifacts.download_artifacts(loc))
214
219
  elif Path(loc).is_dir():
215
220
  path = Path(loc)
216
221
  else:
217
- continue
222
+ continue # no cov
218
223
 
219
224
  run_ids.extend(file.stem for file in path.iterdir() if file.is_dir())
220
225
 
hydraflow/run_info.py CHANGED
@@ -15,6 +15,8 @@ if TYPE_CHECKING:
15
15
  class RunCollectionInfo:
16
16
  """Provide information about a `RunCollection` instance."""
17
17
 
18
+ _runs: RunCollection
19
+
18
20
  def __init__(self, runs: RunCollection) -> None:
19
21
  self._runs = runs
20
22
 
hydraflow/utils.py CHANGED
@@ -30,10 +30,32 @@ def get_artifact_dir(run: Run | None = None) -> Path:
30
30
  """
31
31
  uri = mlflow.get_artifact_uri() if run is None else run.info.artifact_uri
32
32
 
33
- if not (isinstance(uri, str) and uri.startswith("file://")):
33
+ if not isinstance(uri, str):
34
34
  raise NotImplementedError
35
35
 
36
- return Path(mlflow.artifacts.download_artifacts(uri))
36
+ if uri.startswith("file:"):
37
+ return Path(mlflow.artifacts.download_artifacts(uri))
38
+
39
+ if Path(uri).is_dir():
40
+ return Path(uri)
41
+
42
+ raise NotImplementedError
43
+
44
+
45
+ def get_artifact_path(run: Run | None, path: str) -> Path:
46
+ """Retrieve the artifact path for the given run and path.
47
+
48
+ This function uses MLflow to get the artifact path for the given run and path.
49
+
50
+ Args:
51
+ run (Run | None): The run object. Defaults to None.
52
+ path (str): The path to the artifact.
53
+
54
+ Returns:
55
+ The local path to the artifact.
56
+
57
+ """
58
+ return get_artifact_dir(run) / path
37
59
 
38
60
 
39
61
  def get_hydra_output_dir(run: Run | None = None) -> Path:
@@ -1,8 +1,8 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hydraflow
3
- Version: 0.5.1
3
+ Version: 0.5.3
4
4
  Summary: Hydraflow integrates Hydra and MLflow to manage and track machine learning experiments.
5
- Project-URL: Documentation, https://github.com/daizutabi/hydraflow
5
+ Project-URL: Documentation, https://daizutabi.github.io/hydraflow/
6
6
  Project-URL: Source, https://github.com/daizutabi/hydraflow
7
7
  Project-URL: Issues, https://github.com/daizutabi/hydraflow/issues
8
8
  Author-email: daizutabi <daizutabi@gmail.com>
@@ -0,0 +1,14 @@
1
+ hydraflow/__init__.py,sha256=9XO9FD3uiTTPN6X6UAC9FtkJjEqUQZNqpoAmSrjUHfI,855
2
+ hydraflow/config.py,sha256=MNX9da5bPVDcjnpji7Cm9ndK6ura92pt361m4PRh6_E,4326
3
+ hydraflow/context.py,sha256=3g7OQXWcFvK6PVVbXpQg7Hr8nsJkF9pLFrXNi_3aV5A,5524
4
+ hydraflow/mlflow.py,sha256=h2S_A2wElr_1lAq0D1wkoEfdtDZpPuWFNRcO8mV_VrA,8932
5
+ hydraflow/param.py,sha256=c5sc6NwD6DKwZzVwprXzZD5FSi6qRgSHkc6TXBKQEdg,4502
6
+ hydraflow/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
+ hydraflow/run_collection.py,sha256=zPrlKwLuzqePj57pXbgKWrE03S_kjxTaxY9trItf6Gc,26772
8
+ hydraflow/run_data.py,sha256=dpyyfnuH9mCtIZeigMo1iFQo9bafMdEL4i4uI2l0UqY,1525
9
+ hydraflow/run_info.py,sha256=Jf5wrIjRLIV1-k-obHDqwKHa6j_ZonrY8od-rXlbtMo,1024
10
+ hydraflow/utils.py,sha256=oXjcyfQBbPzJNTh3_CbZfl23zgJS-mbNM9GAWBwsn8c,4349
11
+ hydraflow-0.5.3.dist-info/METADATA,sha256=8grWqDq2SBXtVljA72NnKJPJjwaWmjOOXIvGSOP5kqM,4700
12
+ hydraflow-0.5.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
13
+ hydraflow-0.5.3.dist-info/licenses/LICENSE,sha256=IGdDrBPqz1O0v_UwCW-NJlbX9Hy9b3uJ11t28y2srmY,1062
14
+ hydraflow-0.5.3.dist-info/RECORD,,
@@ -1,14 +0,0 @@
1
- hydraflow/__init__.py,sha256=DKtFjTXHTgceX7rpWHiKqhcpG5xtGIseFvN28f7iwYo,807
2
- hydraflow/config.py,sha256=MNX9da5bPVDcjnpji7Cm9ndK6ura92pt361m4PRh6_E,4326
3
- hydraflow/context.py,sha256=3g7OQXWcFvK6PVVbXpQg7Hr8nsJkF9pLFrXNi_3aV5A,5524
4
- hydraflow/mlflow.py,sha256=kWVK_Xw2hkRnTg33jSP3VW13UZF6_hBGhN52mPmLgvk,8753
5
- hydraflow/param.py,sha256=c5sc6NwD6DKwZzVwprXzZD5FSi6qRgSHkc6TXBKQEdg,4502
6
- hydraflow/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
- hydraflow/run_collection.py,sha256=zPrlKwLuzqePj57pXbgKWrE03S_kjxTaxY9trItf6Gc,26772
8
- hydraflow/run_data.py,sha256=dpyyfnuH9mCtIZeigMo1iFQo9bafMdEL4i4uI2l0UqY,1525
9
- hydraflow/run_info.py,sha256=sMXOo20ClaRIommMEzuAbO_OrcXx7M1Yt4FMV7spxz0,998
10
- hydraflow/utils.py,sha256=jbNrbtIfMqxE4LrdTNd1g7sF68XgAvydGqW5iAZ6n-c,3834
11
- hydraflow-0.5.1.dist-info/METADATA,sha256=ZRMGo-8y9JiUSCijXQMeVkG9Gw0edDRgBdkptMDK0IU,4700
12
- hydraflow-0.5.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
13
- hydraflow-0.5.1.dist-info/licenses/LICENSE,sha256=IGdDrBPqz1O0v_UwCW-NJlbX9Hy9b3uJ11t28y2srmY,1062
14
- hydraflow-0.5.1.dist-info/RECORD,,