hydraflow 0.6.2__tar.gz → 0.7.0__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. {hydraflow-0.6.2 → hydraflow-0.7.0}/PKG-INFO +1 -1
  2. {hydraflow-0.6.2 → hydraflow-0.7.0}/pyproject.toml +1 -1
  3. {hydraflow-0.6.2 → hydraflow-0.7.0}/src/hydraflow/run_collection.py +18 -102
  4. {hydraflow-0.6.2 → hydraflow-0.7.0}/tests/context/preemption.py +3 -8
  5. {hydraflow-0.6.2 → hydraflow-0.7.0}/tests/context/rerun.py +1 -1
  6. {hydraflow-0.6.2 → hydraflow-0.7.0}/tests/run/test_collection.py +0 -38
  7. {hydraflow-0.6.2 → hydraflow-0.7.0}/.devcontainer/devcontainer.json +0 -0
  8. {hydraflow-0.6.2 → hydraflow-0.7.0}/.devcontainer/postCreate.sh +0 -0
  9. {hydraflow-0.6.2 → hydraflow-0.7.0}/.devcontainer/starship.toml +0 -0
  10. {hydraflow-0.6.2 → hydraflow-0.7.0}/.gitattributes +0 -0
  11. {hydraflow-0.6.2 → hydraflow-0.7.0}/.gitignore +0 -0
  12. {hydraflow-0.6.2 → hydraflow-0.7.0}/LICENSE +0 -0
  13. {hydraflow-0.6.2 → hydraflow-0.7.0}/README.md +0 -0
  14. {hydraflow-0.6.2 → hydraflow-0.7.0}/apps/quickstart.py +0 -0
  15. {hydraflow-0.6.2 → hydraflow-0.7.0}/mkdocs.yml +0 -0
  16. {hydraflow-0.6.2 → hydraflow-0.7.0}/src/hydraflow/__init__.py +0 -0
  17. {hydraflow-0.6.2 → hydraflow-0.7.0}/src/hydraflow/config.py +0 -0
  18. {hydraflow-0.6.2 → hydraflow-0.7.0}/src/hydraflow/context.py +0 -0
  19. {hydraflow-0.6.2 → hydraflow-0.7.0}/src/hydraflow/mlflow.py +0 -0
  20. {hydraflow-0.6.2 → hydraflow-0.7.0}/src/hydraflow/param.py +0 -0
  21. {hydraflow-0.6.2 → hydraflow-0.7.0}/src/hydraflow/py.typed +0 -0
  22. {hydraflow-0.6.2 → hydraflow-0.7.0}/src/hydraflow/run_data.py +0 -0
  23. {hydraflow-0.6.2 → hydraflow-0.7.0}/src/hydraflow/run_info.py +0 -0
  24. {hydraflow-0.6.2 → hydraflow-0.7.0}/src/hydraflow/utils.py +0 -0
  25. {hydraflow-0.6.2 → hydraflow-0.7.0}/tests/__init__.py +0 -0
  26. {hydraflow-0.6.2 → hydraflow-0.7.0}/tests/config/__init__.py +0 -0
  27. {hydraflow-0.6.2 → hydraflow-0.7.0}/tests/config/overrides.py +0 -0
  28. {hydraflow-0.6.2 → hydraflow-0.7.0}/tests/config/test_config.py +0 -0
  29. {hydraflow-0.6.2 → hydraflow-0.7.0}/tests/config/test_overrides.py +0 -0
  30. {hydraflow-0.6.2 → hydraflow-0.7.0}/tests/config/test_params.py +0 -0
  31. {hydraflow-0.6.2 → hydraflow-0.7.0}/tests/conftest.py +0 -0
  32. {hydraflow-0.6.2 → hydraflow-0.7.0}/tests/context/__init__.py +0 -0
  33. {hydraflow-0.6.2 → hydraflow-0.7.0}/tests/context/chdir.py +0 -0
  34. {hydraflow-0.6.2 → hydraflow-0.7.0}/tests/context/context.py +0 -0
  35. {hydraflow-0.6.2 → hydraflow-0.7.0}/tests/context/logging.py +0 -0
  36. {hydraflow-0.6.2 → hydraflow-0.7.0}/tests/context/test_chdir.py +0 -0
  37. {hydraflow-0.6.2 → hydraflow-0.7.0}/tests/context/test_context.py +0 -0
  38. {hydraflow-0.6.2 → hydraflow-0.7.0}/tests/context/test_logging.py +0 -0
  39. {hydraflow-0.6.2 → hydraflow-0.7.0}/tests/context/test_preemption.py +0 -0
  40. {hydraflow-0.6.2 → hydraflow-0.7.0}/tests/context/test_rerun.py +0 -0
  41. {hydraflow-0.6.2 → hydraflow-0.7.0}/tests/param/__init__.py +0 -0
  42. {hydraflow-0.6.2 → hydraflow-0.7.0}/tests/param/params.py +0 -0
  43. {hydraflow-0.6.2 → hydraflow-0.7.0}/tests/param/test_param.py +0 -0
  44. {hydraflow-0.6.2 → hydraflow-0.7.0}/tests/param/test_params.py +0 -0
  45. {hydraflow-0.6.2 → hydraflow-0.7.0}/tests/run/__init__.py +0 -0
  46. {hydraflow-0.6.2 → hydraflow-0.7.0}/tests/run/filter.py +0 -0
  47. {hydraflow-0.6.2 → hydraflow-0.7.0}/tests/run/run.py +0 -0
  48. {hydraflow-0.6.2 → hydraflow-0.7.0}/tests/run/test_data.py +0 -0
  49. {hydraflow-0.6.2 → hydraflow-0.7.0}/tests/run/test_filter.py +0 -0
  50. {hydraflow-0.6.2 → hydraflow-0.7.0}/tests/run/test_info.py +0 -0
  51. {hydraflow-0.6.2 → hydraflow-0.7.0}/tests/run/test_run.py +0 -0
  52. {hydraflow-0.6.2 → hydraflow-0.7.0}/tests/test_mlflow.py +0 -0
  53. {hydraflow-0.6.2 → hydraflow-0.7.0}/tests/utils/__init__.py +0 -0
  54. {hydraflow-0.6.2 → hydraflow-0.7.0}/tests/utils/test_run.py +0 -0
  55. {hydraflow-0.6.2 → hydraflow-0.7.0}/tests/utils/test_utils.py +0 -0
  56. {hydraflow-0.6.2 → hydraflow-0.7.0}/tests/utils/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hydraflow
3
- Version: 0.6.2
3
+ Version: 0.7.0
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,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "hydraflow"
7
- version = "0.6.2"
7
+ version = "0.7.0"
8
8
  description = "Hydraflow integrates Hydra and MLflow to manage and track machine learning experiments."
9
9
  readme = "README.md"
10
10
  license = { file = "LICENSE" }
@@ -286,105 +286,11 @@ class RunCollection:
286
286
  ),
287
287
  )
288
288
 
289
- def find(self, config: object | None = None, **kwargs) -> Run:
290
- """Find the first `Run` instance based on the provided configuration.
291
-
292
- This method filters the runs in the collection according to the
293
- specified configuration object and returns the first run that matches
294
- the provided parameters. If no run matches the criteria, a `ValueError`
295
- is raised.
296
-
297
- Args:
298
- config (object | None): The configuration object to identify the run.
299
- **kwargs: Additional key-value pairs to filter the runs.
300
-
301
- Returns:
302
- The first `Run` instance that matches the provided configuration.
303
-
304
- Raises:
305
- ValueError: If no run matches the criteria.
306
-
307
- See Also:
308
- `filter`: Perform the actual filtering logic.
309
-
310
- """
311
- try:
312
- return self.filter(config, **kwargs).first()
313
- except ValueError:
314
- raise ValueError("No run matches the provided configuration.")
315
-
316
- def try_find(self, config: object | None = None, **kwargs) -> Run | None:
317
- """Try to find the first `Run` instance based on the provided configuration.
318
-
319
- This method filters the runs in the collection according to the
320
- specified configuration object and returns the first run that matches
321
- the provided parameters. If no run matches the criteria, None is
322
- returned.
323
-
324
- Args:
325
- config (object | None): The configuration object to identify the run.
326
- **kwargs: Additional key-value pairs to filter the runs.
327
-
328
- Returns:
329
- The first `Run` instance that matches the provided configuration, or
330
- None if no runs match the criteria.
331
-
332
- See Also:
333
- `filter`: Perform the actual filtering logic.
334
-
335
- """
336
- return self.filter(config, **kwargs).try_first()
337
-
338
- def find_last(self, config: object | None = None, **kwargs) -> Run:
339
- """Find the last `Run` instance based on the provided configuration.
340
-
341
- This method filters the runs in the collection according to the
342
- specified configuration object and returns the last run that matches
343
- the provided parameters. If no run matches the criteria, a `ValueError`
344
- is raised.
345
-
346
- Args:
347
- config (object | None): The configuration object to identify the run.
348
- **kwargs: Additional key-value pairs to filter the runs.
349
-
350
- Returns:
351
- The last `Run` instance that matches the provided configuration.
352
-
353
- Raises:
354
- ValueError: If no run matches the criteria.
355
-
356
- See Also:
357
- `filter`: Perform the actual filtering logic.
358
-
359
- """
360
- try:
361
- return self.filter(config, **kwargs).last()
362
- except ValueError:
363
- raise ValueError("No run matches the provided configuration.")
364
-
365
- def try_find_last(self, config: object | None = None, **kwargs) -> Run | None:
366
- """Try to find the last `Run` instance based on the provided configuration.
367
-
368
- This method filters the runs in the collection according to the
369
- specified configuration object and returns the last run that matches
370
- the provided parameters. If no run matches the criteria, None is
371
- returned.
372
-
373
- Args:
374
- config (object | None): The configuration object to identify the run.
375
- **kwargs: Additional key-value pairs to filter the runs.
376
-
377
- Returns:
378
- The last `Run` instance that matches the provided configuration, or
379
- None if no runs match the criteria.
380
-
381
- See Also:
382
- `filter`: Perform the actual filtering logic.
383
-
384
- """
385
- return self.filter(config, **kwargs).try_last()
386
-
387
- def get(self, config: object | None = None, **kwargs) -> Run:
289
+ def get(
290
+ self,
291
+ config: object | Callable[[Run], bool] | None = None,
292
+ **kwargs,
293
+ ) -> Run:
388
294
  """Retrieve a specific `Run` instance based on the provided configuration.
389
295
 
390
296
  This method filters the runs in the collection according to the
@@ -393,7 +299,10 @@ class RunCollection:
393
299
  one run matches the criteria, a `ValueError` is raised.
394
300
 
395
301
  Args:
396
- config (object | None): The configuration object to identify the run.
302
+ config (object | Callable[[Run], bool] | None): The configuration object
303
+ to identify the run. This can be any object that provides key-value
304
+ pairs through the `iter_params` function, or a callable that
305
+ takes a `Run` object and returns a boolean value.
397
306
  **kwargs: Additional key-value pairs to filter the runs.
398
307
 
399
308
  Returns:
@@ -413,7 +322,11 @@ class RunCollection:
413
322
  msg = "The filtered collection does not contain exactly one run."
414
323
  raise ValueError(msg)
415
324
 
416
- def try_get(self, config: object | None = None, **kwargs) -> Run | None:
325
+ def try_get(
326
+ self,
327
+ config: object | Callable[[Run], bool] | None = None,
328
+ **kwargs,
329
+ ) -> Run | None:
417
330
  """Try to get a specific `Run` instance based on the provided configuration.
418
331
 
419
332
  This method filters the runs in the collection according to the
@@ -422,7 +335,10 @@ class RunCollection:
422
335
  If more than one run matches the criteria, a `ValueError` is raised.
423
336
 
424
337
  Args:
425
- config (object | None): The configuration object to identify the run.
338
+ config (object | Callable[[Run], bool] | None): The configuration object
339
+ to identify the run. This can be any object that provides key-value
340
+ pairs through the `iter_params` function, or a callable that
341
+ takes a `Run` object and returns a boolean value.
426
342
  **kwargs: Additional key-value pairs to filter the runs.
427
343
 
428
344
  Returns:
@@ -24,17 +24,12 @@ ConfigStore.instance().store(name="config", node=Config)
24
24
  def app(cfg: Config):
25
25
  hydraflow.set_experiment()
26
26
 
27
- rc = hydraflow.list_runs()
27
+ rc = hydraflow.list_runs().filter(cfg, override=True)
28
28
 
29
- if rc.filter(cfg, status="finished", override=True):
29
+ if rc.filter(status="finished"):
30
30
  return
31
31
 
32
- if run := rc.try_find(cfg, override=True):
33
- run_id = run.info.run_id
34
- else:
35
- run_id = None
36
-
37
- with hydraflow.start_run(cfg, run_id=run_id) as run:
32
+ with hydraflow.start_run(cfg, run=rc.try_one()) as run:
38
33
  log(hydraflow.get_artifact_dir(run))
39
34
 
40
35
 
@@ -24,7 +24,7 @@ ConfigStore.instance().store(name="config", node=Config)
24
24
  def app(cfg: Config):
25
25
  hydraflow.set_experiment()
26
26
 
27
- run = hydraflow.list_runs().try_find(cfg, override=True)
27
+ run = hydraflow.list_runs().try_get(cfg, override=True)
28
28
 
29
29
  with hydraflow.start_run(cfg, run=run) as run:
30
30
  log(hydraflow.get_artifact_dir(run))
@@ -332,44 +332,6 @@ def test_get_param_dict_drop_const(rc: RunCollection):
332
332
  assert "r" in params
333
333
 
334
334
 
335
- def test_find_dict(rc: RunCollection):
336
- run = rc.find({"r": 0})
337
- assert run.data.params["p"] == "0"
338
-
339
-
340
- def test_find_kwarg(rc: RunCollection):
341
- run = rc.find(r=2)
342
- assert run.data.params["p"] == "2"
343
-
344
-
345
- def test_find_none(rc: RunCollection):
346
- with pytest.raises(ValueError):
347
- rc.find({"r": 10})
348
-
349
-
350
- def test_try_find_none(rc: RunCollection):
351
- assert rc.try_find({"r": 10}) is None
352
-
353
-
354
- def test_find_last_dict(rc: RunCollection):
355
- run = rc.find_last({"r": 0})
356
- assert run.data.params["p"] == "3"
357
-
358
-
359
- def test_find_last_kwarg(rc: RunCollection):
360
- run = rc.find_last(r=2)
361
- assert run.data.params["p"] == "5"
362
-
363
-
364
- def test_find_last_none(rc: RunCollection):
365
- with pytest.raises(ValueError):
366
- rc.find_last({"p": 10})
367
-
368
-
369
- def test_try_find_last_none(rc: RunCollection):
370
- assert rc.try_find_last({"p": 10}) is None
371
-
372
-
373
335
  @pytest.mark.parametrize("n_jobs", [0, 1, 2])
374
336
  def test_list_runs(rc: RunCollection, n_jobs: int):
375
337
  assert len(list_runs(n_jobs=n_jobs)) == 6
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes