Simplify registration of error/output to status mappings #166
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
One of the responsibilities of the SDK is to categorize function outputs (return values or exceptions raised) into a
Status
, so that Dispatch knows a) whether to retry, and b) how to adjust the execution concurrency moving forwards.The SDK provides two functions for registering handler functions that map base error and output (return value) classes to a
Status
:For example usage, see https://github.com/dispatchrun/dispatch-py/blob/main/src/dispatch/integrations/openai.py
Sometimes the user simply wants to map a specific class to a specific status, and the handler function is unnecessary indirection.
This PR simplifies the interface so that users can either pass a
Status
directly, or (as before) a handler function that maps error/output classes to statuses. For example, the following is now accepted: