Add 429-aware retry/backoff to Grain API client - #3
Draft
dplakon wants to merge 1 commit into
Draft
Conversation
The daily meeting fetch paginates through all recordings via list_all_recordings, but _get had no retry handling, so a single transient 429 (Too Many Requests) mid-pagination aborted the entire run. This made fetch_daily_meetings.py fail intermittently under Grain rate limits. Add _urlopen_with_retry with exponential backoff that honors the Retry-After header and retries on 429 and 5xx responses (and transient network errors). Route both _get and get_transcript_text through it. Retry counts and delays are tunable via GRAINIAC_MAX_RETRIES / GRAINIAC_RETRY_BASE_DELAY / GRAINIAC_RETRY_MAX_DELAY. Co-Authored-By: Oz <oz-agent@warp.dev>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
The daily Grain → Notion pipeline was failing intermittently because the Grain API client had no retry handling for transient rate limits.
fetch_daily_meetings.pypaginates through all recordings vialist_all_recordings, and a single429 Too Many Requestsmid-pagination aborted the entire run.Changes
_urlopen_with_retrytoscripts/grain_client.pywith exponential backoff that honors theRetry-Afterheader and retries on429and5xxresponses (plus transient network errors)._getandget_transcript_textthrough the retry helper.GRAINIAC_MAX_RETRIES,GRAINIAC_RETRY_BASE_DELAY, andGRAINIAC_RETRY_MAX_DELAYenv vars.Context
Discovered while running the grainiac-orchestrator daily pipeline: the fetch repeatedly failed with
HTTP Error 429until this retry logic was added, after which today's 3 meetings fetched successfully.Conversation: https://app.warp.dev/conversation/a5d08c69-0a16-4505-9a19-ff9c7f384e08
Run: https://oz.warp.dev/runs/019f71ae-483f-7a37-900c-b6dab7580270
This PR was generated with Oz.