Skip to content

feat: add progress callback to run_grid and Study.run#97

Merged
jc-macdonald merged 1 commit intomainfrom
feat/progress-callbacks
Apr 17, 2026
Merged

feat: add progress callback to run_grid and Study.run#97
jc-macdonald merged 1 commit intomainfrom
feat/progress-callbacks

Conversation

@jc-macdonald
Copy link
Copy Markdown
Contributor

Summary

Adds a progress callback parameter to run_grid() and Study.run() so users can monitor long-running sweeps (#77).

Changes

  • New callback: ProgressCallback | None = None parameter on run_grid()
    • Called after each trial with (trial_index, total_trials, trial_result)
    • In serial mode (n_jobs=1), fires immediately after each trial
    • In parallel mode, fires post-hoc after all trials complete
  • Study.run() forwards callback to all run_grid() calls
  • ProgressCallback type alias: Callable[[int, int, TrialResult], None]

Usage

from tqdm import tqdm
bar = tqdm(total=len(grid))
run_grid(..., callback=lambda i, n, r: bar.update(1))

Tests

  • 4 new tests (2 in test_runner.py, 2 in test_study.py)
  • 225 total tests passing, 99.53% coverage

Closes #77

- Add callback: ProgressCallback | None parameter to run_grid()
  Called after each trial with (trial_index, total_trials, result)
- In serial mode, callback fires immediately after each trial
- In parallel mode, callback fires post-hoc after all trials complete
- Forward callback from Study.run() to run_grid() for grid phases
- Add ProgressCallback type alias in runner module
- 4 new tests (2 in test_runner, 2 in test_study)

Closes #77
@jc-macdonald jc-macdonald merged commit 120f80e into main Apr 17, 2026
4 checks passed
@jc-macdonald jc-macdonald deleted the feat/progress-callbacks branch April 17, 2026 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Progress callbacks for run_grid and Study.run

1 participant