-
Notifications
You must be signed in to change notification settings - Fork 97
feat: add max_retries parameter to Writer client initialization - AB-931 #1265
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
Conversation
📝 WalkthroughWalkthroughA single configuration change has been made to the Writer HTTP client initialization in the AI module. The Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| default_headers=custom_headers, | ||
| http_client=custom_httpx_client | ||
| http_client=custom_httpx_client, | ||
| max_retries=10, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to also adjust the MAX_RETRY_DELAY constant, which is capped at 8 seconds. Circuit breaker cooldowns last at minimum 30 seconds, so this alone won't help.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/writer/ai/__init__.py (1)
320-325: Consider making max_retries configurable rather than hardcoded.Issue AB-931 requests to "make it configurable via a parameter," but the current implementation hardcodes
max_retries=10. While 10 is a reasonable default, consider allowing configuration to support different use cases.Potential approach to make max_retries configurable
You could add an optional parameter to
WriterAIManager.__init__andacquire_client:class WriterAIManager: - def __init__(self, token: Optional[str] = None): + def __init__(self, token: Optional[str] = None, max_retries: int = 10): """ Initializes a WriterAIManager instance. :param token: Optional; the default token for API authentication used if WRITER_API_KEY environment variable is not set up. + :param max_retries: Maximum number of retry attempts for API requests. :raises RuntimeError: If an API key was not provided to initialize SDK client properly. """ self.token = token + self.max_retries = max_retriesThen use
instance.max_retriesinstead of the hardcoded value:client = Writer( api_key=instance.token, default_headers=custom_headers, http_client=custom_httpx_client, - max_retries=10, + max_retries=instance.max_retries, )
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Jira integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
src/writer/ai/__init__.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
- GitHub Check: build (3.9)
- GitHub Check: build (3.11)
- GitHub Check: build (3.13)
- GitHub Check: tests (webkit)
- GitHub Check: tests (chromium)
- GitHub Check: tests (firefox)
- GitHub Check: build (3.12)
- GitHub Check: build (3.10)
HackerOne Code Security Review🟢 Scan Complete: 1 Issue(s) Here's how the code changes were interpreted and info about the tools used for scanning. ℹ️ Issues DetectedNOTE: These may not require action! Below are unvalidated results from the Analysis Tools that ran during the latest scan for transparency. We investigate each of these for accuracy and relevance before surfacing them as a potential problem. How will I know if something is a problem?
🧰 Analysis tools
⏱️ Latest scan covered changes up to commit 0cb6564 (latest) |
|
✅ Graham C reviewed all the included code changes and associated automation findings and determined that there were no immediately actionable security flaws. Note that they will continue to be notified of any new commits or comments and follow up as needed throughout the duration of this pull request's lifecycle. Reviewed with ❤️ by PullRequest |
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.