Skip to content
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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

NikitaZelenskis
Copy link

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

  • Extended RetryPolicy's retry_on parameter to accept dict[Type[Exception], Callable[[Any, Exception], None]]
  • Updated type hints and documentation
  • Added tutorial section explaining the new functionality

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.

@NikitaZelenskis
Copy link
Author

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

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.

1 participant