Skip to content

Conversation

@yannrichet
Copy link
Member

No description provided.

Implements a flexible callback system that allows users to monitor fzr execution
progress programmatically. This is useful for building UIs, dashboards, and
custom progress displays on top of fz.

Features:
- on_start: Called when fzr begins execution
- on_case_start: Called when each case starts
- on_case_complete: Called when each case finishes (success or failure)
- on_progress: Called periodically with ETA estimates
- on_complete: Called when all cases finish

Implementation details:
- Callbacks are optional (backwards compatible)
- Callbacks are validated at call time
- Errors in callbacks are caught and logged but don't crash execution
- Thread-safe callback invocation in parallel execution mode
- Comprehensive test suite covering all callback scenarios

Changes:
- fz/core.py: Added callbacks parameter to fzr(), validation, and on_start/on_complete calls
- fz/helpers.py: Pass callbacks through execution chain, call on_case_start, on_case_complete, and on_progress
- tests/test_callbacks.py: Comprehensive test suite with 6 test cases covering all functionality

Tested:
- All callback types fire correctly
- Error handling prevents callback failures from crashing execution
- Single case edge case
- Thread safety with parallel execution
- Input validation
- Backwards compatibility (callbacks are optional)
@yannrichet yannrichet merged commit 0c93550 into main Nov 23, 2025
31 checks passed
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.

3 participants