-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add state-modifying retry policies #2957
base: main
Are you sure you want to change the base?
Conversation
Also as I understand the State/task input can be any type? If that is not the case I would also appreciate some guidance on that |
Hello @nfcampos , |
elif isinstance(retry_policy.retry_on, dict): | ||
exception_handler = retry_policy.retry_on.get(type(exc), False) | ||
if callable(exception_handler): | ||
exception_handler(task.input, exc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing else branch here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @nfcampos,
Thank you for your review.
I fixed it and pushed the changes.
I apologize for this oversight.
Add state-modifying retry policies
Description
This PR adds support for state-modifying retry policies by allowing a dictionary mapping of exceptions to state-modifying functions in the RetryPolicy class. This enhancement enables users to modify the workflow state before retry attempts based on specific exceptions.
I think this feature can be very usefull as I am not the only one who needs it. See this discussion
Changes
RetryPolicy
'sretry_on
parameter to acceptdict[Type[Exception], Callable[[Any, Exception], None]]
Tests
I have not added a test for this feature as I did not find a a fitting file name for this case and did not want to make my own test file.
If needed I can add a test for this new feature, I would appreciate guidance on the preferred location for adding tests.
All existing tests pass.