Repository navigation
[data] Make iterate_with_retry more descriptive when throwing exceptions - #66033
Conversation
Signed-off-by: iamjustinhsu <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request introduces a helper function _annotate_exception_with_retry_context to append retry context and helpful S3 permission hints to exceptions raised during iterate_with_retry, along with corresponding unit tests. The review feedback is highly constructive and identifies several key improvements: correcting a bug where the attempt count is incorrectly reset to 1 on non-retryable errors, updating the test assertions accordingly, wrapping the modification of exc.args in a try...except block to prevent secondary exceptions from masking the original error, and pointing out that call_with_retry should also be annotated to fully satisfy the PR's objective for S3 write operations.
Signed-off-by: iamjustinhsu <[email protected]>
Signed-off-by: iamjustinhsu <[email protected]>
Signed-off-by: iamjustinhsu <[email protected]>
Signed-off-by: iamjustinhsu <[email protected]>
Signed-off-by: iamjustinhsu <[email protected]>
ayushk7102
left a comment
There was a problem hiding this comment.
Implementation looks good to me, but I had minor nits about if this warning is showing up when users have set retried_map_errors or not, and how we handle concatting the warning with the actual exception message
| def iterate_with_retry( | ||
| iterable_factory: Callable[[], Iterable], | ||
| description: str, | ||
| *, | ||
| match: Optional[List[str]] = None, | ||
| max_attempts: int = 10, | ||
| max_backoff_s: int = 32, | ||
| unwrap_cause: bool = False, | ||
| ) -> Any: |
There was a problem hiding this comment.
iterate_with_retry is called from _map_task only if retried_map_errors is truthy (it's false by default). If we want to advise users to configure retried_map_errors we will not be able to do so unless they actually set it to True or any retryable errors, which seems unintuitive. Is there a way for us warn users if they have NOT set this param?
| ) | ||
| try: | ||
| if exc.args and isinstance(exc.args[0], str): | ||
| exc.args = (f"{exc.args[0]}\n{suffix}",) + exc.args[1:] |
There was a problem hiding this comment.
Nit: this might lead to unexpected results when the specific exception type has some reserved order of the args tuple.
For example, from the BaseException docs section about args: OSError expects a certain number of arguments and assigns a special meaning to the elements of this tuple.
Signed-off-by: iamjustinhsu <[email protected]>
Signed-off-by: iamjustinhsu <[email protected]>
73c30a1 to
25e930e
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 25e930e. Configure here.
Signed-off-by: iamjustinhsu <[email protected]>
…-retry-error-message-thrown
Signed-off-by: iamjustinhsu <[email protected]>
Signed-off-by: iamjustinhsu <[email protected]>
…ons (ray-project#66033) ## Description Sometimes when writing to s3 using pyarrow file system, the error can be mysterious: "AWS Error ACCESS_DENIED during HeadBucket" So to make this more transparent, i decided to special case on ACCESS_DENIED so that we can inform the user how to handle this in `iterate_with_retry`. See unit test for example I avoided modifying `call_with_retry` because a) it's in a generic utility (so other libraries may want to handle it differently) b) there is no existing way to modify the # of retries with `call_with_retry` in Ray Data, but we can modify the # of retries with `iterate_with_retry` While i can circumvent a) and b), i don't think it's worth effort ## Related issues ## Additional information --------- Signed-off-by: iamjustinhsu <[email protected]>

Description
Sometimes when writing to s3 using pyarrow file system, the error can be mysterious:
"AWS Error ACCESS_DENIED during HeadBucket"
So to make this more transparent, i decided to special case on ACCESS_DENIED so that we can inform the user how to handle this in
iterate_with_retry. See unit test for exampleI avoided modifying
call_with_retrybecausea) it's in a generic utility (so other libraries may want to handle it differently)
b) there is no existing way to modify the # of retries with
call_with_retryin Ray Data, but we can modify the # of retries withiterate_with_retryWhile i can circumvent a) and b), i don't think it's worth effort
Related issues
Additional information