hydraflow 0.18.2__py3-none-any.whl → 0.18.3__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/run.py CHANGED
@@ -40,7 +40,7 @@ if TYPE_CHECKING:
40
40
  from collections.abc import Iterator
41
41
  from typing import Any, Self
42
42
 
43
- from polars import Expr
43
+ from polars import DataFrame, Expr
44
44
  from polars._typing import PolarsDataType
45
45
 
46
46
  from .run_collection import RunCollection
@@ -341,6 +341,27 @@ class Run[C, I = None]:
341
341
  value = self.get(key, default)
342
342
  return pl.lit(value, dtype).alias(key)
343
343
 
344
+ def to_frame(
345
+ self,
346
+ func: Callable[[Self], DataFrame],
347
+ *keys: str | tuple[str, Any | Callable[[Self], Any]],
348
+ ) -> DataFrame:
349
+ """Convert the Run to a DataFrame.
350
+
351
+ Args:
352
+ func (Callable[[Run], DataFrame]): A function that takes a Run
353
+ instance and returns a DataFrame.
354
+ keys (str | tuple[str, Any | Callable[[Run], Any]]): The keys to
355
+ add to the DataFrame.
356
+
357
+ Returns:
358
+ DataFrame: A DataFrame representation of the Run.
359
+
360
+ """
361
+ return func(self).with_columns(
362
+ self.lit(k) if isinstance(k, str) else self.lit(k[0], k[1]) for k in keys
363
+ )
364
+
344
365
  def to_dict(self, flatten: bool = True) -> dict[str, Any]:
345
366
  """Convert the Run to a dictionary.
346
367
 
@@ -43,6 +43,8 @@ from __future__ import annotations
43
43
  from functools import cached_property
44
44
  from typing import TYPE_CHECKING, overload
45
45
 
46
+ import polars as pl
47
+
46
48
  from .collection import Collection
47
49
  from .run import Run
48
50
 
@@ -51,6 +53,8 @@ if TYPE_CHECKING:
51
53
  from pathlib import Path
52
54
  from typing import Any, Self
53
55
 
56
+ from polars import DataFrame
57
+
54
58
 
55
59
  class RunCollection[R: Run[Any, Any], I = None](Collection[R]):
56
60
  """A collection of Run instances that implements the Sequence protocol.
@@ -168,6 +172,28 @@ class RunCollection[R: Run[Any, Any], I = None](Collection[R]):
168
172
  for run in self:
169
173
  run.update(key, value, force=force)
170
174
 
175
+ def concat(
176
+ self,
177
+ func: Callable[[R], DataFrame],
178
+ *keys: str | tuple[str, Any | Callable[[R], Any]],
179
+ ) -> DataFrame:
180
+ """Concatenate the results of a function applied to all runs in the collection.
181
+
182
+ This method applies the provided function to each run in the collection
183
+ and concatenates the resulting DataFrames along the specified keys.
184
+
185
+ Args:
186
+ func (Callable[[R], DataFrame]): A function that takes a Run
187
+ instance and returns a DataFrame.
188
+ keys (str | tuple[str, Any | Callable[[R], Any]]): The keys to
189
+ add to the DataFrame.
190
+
191
+ Returns:
192
+ DataFrame: A DataFrame representation of the Run.
193
+
194
+ """
195
+ return pl.concat(run.to_frame(func, *keys) for run in self)
196
+
171
197
  @cached_property
172
198
  def impls(self) -> Collection[I]:
173
199
  """Get the implementation objects for all runs in the collection.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hydraflow
3
- Version: 0.18.2
3
+ Version: 0.18.3
4
4
  Summary: HydraFlow seamlessly integrates Hydra and MLflow to streamline ML experiment management, combining Hydra's configuration management with MLflow's tracking capabilities.
5
5
  Project-URL: Documentation, https://daizutabi.github.io/hydraflow/
6
6
  Project-URL: Source, https://github.com/daizutabi/hydraflow
@@ -7,8 +7,8 @@ hydraflow/core/context.py,sha256=6vpwe0Xfl6mzh2hHLE-4uB9Hjew-CK4pA0KFihQ80U8,416
7
7
  hydraflow/core/group_by.py,sha256=Pnw-oA5aXHeRG9lMLz-bKc8drqQ8LIRsWzvVn153iyQ,5488
8
8
  hydraflow/core/io.py,sha256=B3-jPuJWttRgpbIpy_XA-Z2qpXzNF1ATwyYEwA7Pv3w,5172
9
9
  hydraflow/core/main.py,sha256=6X58M-xpJPql7xqLR3gpa4XMePvZ6Q1diMSqTZf2Jrw,6542
10
- hydraflow/core/run.py,sha256=rt97EXJ72fdMsuh4AKL-dxRfnQQ4Yzo2ZpTocTR5Wr8,15034
11
- hydraflow/core/run_collection.py,sha256=JgCdu0_hvgAoeScdDuXQrEWKQhCzoL-v-g53cR9Sm_c,6759
10
+ hydraflow/core/run.py,sha256=QMPdQGTOJd45pVnSkLmnWv5mMRjnGKTRe-qW80q57RI,15730
11
+ hydraflow/core/run_collection.py,sha256=isyZblSWtXIDqxiLea6xkfQp7o5ip1KrrfaWqi4gtps,7621
12
12
  hydraflow/core/run_info.py,sha256=SMOTZXEa7OBV_XjTyctk5gJGrggmYwhePvRF8CLF1kU,1616
13
13
  hydraflow/executor/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
14
  hydraflow/executor/aio.py,sha256=xXsmBPIPdBlopv_1h0FdtOvoKUcuW7PQeKCV2d_lN9I,2122
@@ -18,8 +18,8 @@ hydraflow/executor/job.py,sha256=6QeJ18OMeocXeM04rCYL46GgArfX1SvZs9_4HTomTgE,543
18
18
  hydraflow/executor/parser.py,sha256=RxP8qpDaJ8VLqZ51VlPFyVitWctObhkE_3iPIsY66Cs,14610
19
19
  hydraflow/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
20
  hydraflow/utils/progress.py,sha256=a-CHvioyGCeiUKawqPcV8i1nhzunm5-r5AlLbzd5epw,3048
21
- hydraflow-0.18.2.dist-info/METADATA,sha256=ompvUz-MANwKrTj9N1TGktmS0FHpirfmMTREgoyTh6o,7433
22
- hydraflow-0.18.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
23
- hydraflow-0.18.2.dist-info/entry_points.txt,sha256=XI0khPbpCIUo9UPqkNEpgh-kqK3Jy8T7L2VCWOdkbSM,48
24
- hydraflow-0.18.2.dist-info/licenses/LICENSE,sha256=IGdDrBPqz1O0v_UwCW-NJlbX9Hy9b3uJ11t28y2srmY,1062
25
- hydraflow-0.18.2.dist-info/RECORD,,
21
+ hydraflow-0.18.3.dist-info/METADATA,sha256=aDozL50IRZi_dIWcL1NwfZPWKN3jU3YLs-ihM7gmde0,7433
22
+ hydraflow-0.18.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
23
+ hydraflow-0.18.3.dist-info/entry_points.txt,sha256=XI0khPbpCIUo9UPqkNEpgh-kqK3Jy8T7L2VCWOdkbSM,48
24
+ hydraflow-0.18.3.dist-info/licenses/LICENSE,sha256=IGdDrBPqz1O0v_UwCW-NJlbX9Hy9b3uJ11t28y2srmY,1062
25
+ hydraflow-0.18.3.dist-info/RECORD,,