hydraflow 0.5.0__py3-none-any.whl → 0.5.2__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
@@ -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)
@@ -214,7 +219,7 @@ def _list_runs(
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
 
@@ -609,8 +609,8 @@ class RunCollection:
609
609
 
610
610
  def sort(
611
611
  self,
612
- key: Callable[[Run], Any] | None = None,
613
612
  *,
613
+ key: Callable[[Run], Any] | None = None,
614
614
  reverse: bool = False,
615
615
  ) -> None:
616
616
  """Sort the runs in the collection.
@@ -652,7 +652,7 @@ class RunCollection:
652
652
 
653
653
  return [v[0] for v in values]
654
654
 
655
- def sort_by(
655
+ def sorted(
656
656
  self,
657
657
  names: str | list[str],
658
658
  *,
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,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hydraflow
3
- Version: 0.5.0
3
+ Version: 0.5.2
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
@@ -111,7 +111,7 @@ def my_app(cfg: MySQLConfig) -> None:
111
111
  hydraflow.set_experiment()
112
112
 
113
113
  # Automatically log Hydra config as params.
114
- with hydraflow.start_run():
114
+ with hydraflow.start_run(cfg):
115
115
  # Your app code below.
116
116
 
117
117
 
@@ -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=vor1w8twfBQx9kmlAkvmJ4q7n_GrNyqGXBP1xwTAGD0,8934
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=32dCP7rmkB7_dyGJgY6auy8162jotd5JSaVi-qB9vnU,4351
11
+ hydraflow-0.5.2.dist-info/METADATA,sha256=ou8nVe6VIYi52Prp26VZcoxixJItFmojKaINgG1DWQo,4700
12
+ hydraflow-0.5.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
13
+ hydraflow-0.5.2.dist-info/licenses/LICENSE,sha256=IGdDrBPqz1O0v_UwCW-NJlbX9Hy9b3uJ11t28y2srmY,1062
14
+ hydraflow-0.5.2.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=RQRN50k5m_bDWn4vzOProbnjzVejI5hsr5WSd4owbhQ,26773
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.0.dist-info/METADATA,sha256=pv7eNdU5mT05N936AWyuLzZfzYSgVrsGZ5d354bD_-8,4697
12
- hydraflow-0.5.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
13
- hydraflow-0.5.0.dist-info/licenses/LICENSE,sha256=IGdDrBPqz1O0v_UwCW-NJlbX9Hy9b3uJ11t28y2srmY,1062
14
- hydraflow-0.5.0.dist-info/RECORD,,