hydraflow 0.6.1__py3-none-any.whl → 0.6.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.
@@ -236,7 +236,7 @@ class RunCollection:
236
236
 
237
237
  def filter(
238
238
  self,
239
- config: object | None = None,
239
+ config: object | Callable[[Run], bool] | None = None,
240
240
  *,
241
241
  override: bool = False,
242
242
  select: list[str] | None = None,
@@ -257,11 +257,13 @@ class RunCollection:
257
257
  - Membership checks for lists of values.
258
258
  - Range checks for tuples of two values (inclusive of both the lower
259
259
  and upper bound).
260
+ - Callable that takes a `Run` object and returns a boolean value.
260
261
 
261
262
  Args:
262
- config (object | None): The configuration object to filter the runs.
263
- This can be any object that provides key-value pairs through
264
- the `iter_params` function.
263
+ config (object | Callable[[Run], bool] | None): The configuration object
264
+ to filter the runs. This can be any object that provides key-value
265
+ pairs through the `iter_params` function, or a callable that
266
+ takes a `Run` object and returns a boolean value.
265
267
  override (bool): If True, override the configuration object with the
266
268
  provided key-value pairs.
267
269
  select (list[str] | None): The list of parameters to select.
@@ -711,7 +713,7 @@ def _param_matches(run: Run, key: str, value: Any) -> bool:
711
713
 
712
714
  def filter_runs(
713
715
  runs: list[Run],
714
- config: object | None = None,
716
+ config: object | Callable[[Run], bool] | None = None,
715
717
  *,
716
718
  override: bool = False,
717
719
  select: list[str] | None = None,
@@ -735,9 +737,11 @@ def filter_runs(
735
737
 
736
738
  Args:
737
739
  runs (list[Run]): The list of runs to filter.
738
- config (object | None, optional): The configuration object to filter the
739
- runs. This can be any object that provides key-value pairs through
740
- the `iter_params` function. Defaults to None.
740
+ config (object | Callable[[Run], bool] | None, optional): The
741
+ configuration object to filter the runs. This can be any object
742
+ that provides key-value pairs through the `iter_params` function.
743
+ This can also be a callable that takes a `Run` object and returns
744
+ a boolean value. Defaults to None.
741
745
  override (bool, optional): If True, filter the runs based on
742
746
  the overrides. Defaults to False.
743
747
  select (list[str] | None, optional): The list of parameters to select.
@@ -750,15 +754,19 @@ def filter_runs(
750
754
  A list of runs that match the specified configuration and key-value pairs.
751
755
 
752
756
  """
753
- if override:
754
- config = select_overrides(config)
755
- elif select:
756
- config = select_config(config, select)
757
-
758
- for key, value in chain(iter_params(config), kwargs.items()):
759
- runs = [run for run in runs if _param_matches(run, key, value)]
760
- if not runs:
761
- return []
757
+ if callable(config):
758
+ runs = [run for run in runs if config(run)]
759
+
760
+ else:
761
+ if override:
762
+ config = select_overrides(config)
763
+ elif select:
764
+ config = select_config(config, select)
765
+
766
+ for key, value in chain(iter_params(config), kwargs.items()):
767
+ runs = [run for run in runs if _param_matches(run, key, value)]
768
+ if not runs:
769
+ return []
762
770
 
763
771
  if status is None:
764
772
  return runs
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hydraflow
3
- Version: 0.6.1
3
+ Version: 0.6.2
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
@@ -4,11 +4,11 @@ hydraflow/context.py,sha256=3xfKhMozkKFqtWeOp9Gie0A5o5URMta4US6iVD5TcLU,6002
4
4
  hydraflow/mlflow.py,sha256=imD3XL0RTlpnKrkyvO8FNy_Bv6hwSfLiOu1yJuL40ck,8773
5
5
  hydraflow/param.py,sha256=yu1aMNXRLegXGDL-68vwIkfeDF9CaU784WZENGLwl7Q,4572
6
6
  hydraflow/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
- hydraflow/run_collection.py,sha256=2GRVOy87_2SPjHuCzzUvRNugO_grtFUVjtTfhznwBAc,27444
7
+ hydraflow/run_collection.py,sha256=w_GZdc_6yviwzRWLndWDSWB4DKyGyA9di9d9UpkkLZo,27926
8
8
  hydraflow/run_data.py,sha256=dpyyfnuH9mCtIZeigMo1iFQo9bafMdEL4i4uI2l0UqY,1525
9
9
  hydraflow/run_info.py,sha256=Jf5wrIjRLIV1-k-obHDqwKHa6j_ZonrY8od-rXlbtMo,1024
10
10
  hydraflow/utils.py,sha256=a9i5PEJn8Ssowv9dqHadAihZXlsqtVjHZ9MZvkPq1bY,4747
11
- hydraflow-0.6.1.dist-info/METADATA,sha256=FzLPE3L9VlZdrYOicnzTda7BhHuLTU0-WRz02TLgt6c,4700
12
- hydraflow-0.6.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
13
- hydraflow-0.6.1.dist-info/licenses/LICENSE,sha256=IGdDrBPqz1O0v_UwCW-NJlbX9Hy9b3uJ11t28y2srmY,1062
14
- hydraflow-0.6.1.dist-info/RECORD,,
11
+ hydraflow-0.6.2.dist-info/METADATA,sha256=9a3blsQ91rNP1Ql4kFDc7tZxDMbdK5PzEAfP9ZyUY6A,4700
12
+ hydraflow-0.6.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
13
+ hydraflow-0.6.2.dist-info/licenses/LICENSE,sha256=IGdDrBPqz1O0v_UwCW-NJlbX9Hy9b3uJ11t28y2srmY,1062
14
+ hydraflow-0.6.2.dist-info/RECORD,,