Fix DC API wrapper retry attempt counting (raise after final attempt)#1862
Fix DC API wrapper retry attempt counting (raise after final attempt)#1862rohitkumarbhagat wants to merge 3 commits intodatacommonsorg:masterfrom
Conversation
Summary of ChangesHello @rohitkumarbhagat, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request refines the retry mechanism within the DataCommons API wrapper. The primary goal is to ensure that API calls facing transient errors (like rate limits or server errors) adhere strictly to the configured maximum number of retry attempts. It also guarantees that once these attempts are exhausted, the original exception is raised, preventing silent failures and providing clearer feedback on API issues. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
The pull request refactors the retry mechanism in dc_api_wrapper.py to use max_attempts instead of retries, clarifying that the count includes the initial attempt. This change is consistently applied across the function's logic and logging. Additionally, new unit tests have been added to dc_api_wrapper_test.py to validate the updated retry behavior, ensuring that the API wrapper correctly handles the specified number of attempts and stops retrying upon successful execution. The changes improve the clarity and robustness of the retry logic.
This PR fixes the retry/attempt logic in
util/dc_api_wrapper.pyso retryable DC API failures (e.g. 429/5xx/timeouts) stop retrying after the configured maximum attempts and surface the underlying exception instead of silently falling through and returningNone.