-
Notifications
You must be signed in to change notification settings - Fork 6
feat: exponential retry decorator #88
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
base: main
Are you sure you want to change the base?
Conversation
… normalize dict items in utils
…and configuration details
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.
Pull Request Overview
This PR introduces a robust retry decorator with exponential backoff and rate-limit handling for both synchronous and asynchronous functions, enabling configurable retry behavior through environment variables and Kubernetes configuration.
- Implements a configurable retry decorator with exponential backoff, jitter, and rate-limit awareness
- Integrates retry settings into infrastructure configuration via Helm values and ConfigMaps
- Adds comprehensive test coverage for retry scenarios including rate-limit handling
Reviewed Changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
retry_decorator_test.py | Comprehensive test suite covering sync/async retry scenarios and rate-limit handling |
utils.py | Utility functions for parsing rate-limit headers and extracting exception metadata |
retry_decorator.py | Core retry decorator implementation with exponential backoff and rate-limit awareness |
retry_decorator_settings.py | Pydantic settings model for configuring retry behavior via environment variables |
pyproject.toml | Adds pytest-asyncio dependency for async test support |
README.md | Documentation for retry decorator usage and configuration |
values.yaml | Default retry configuration values for Helm deployment |
configmap.yaml | ConfigMap template for retry decorator environment variables |
deployment.yaml files | Integration of retry decorator ConfigMap into backend deployments |
_helpers.tpl | Helm template helper for retry decorator ConfigMap naming |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
libs/rag-core-lib/src/rag_core_lib/impl/settings/retry_decorator_settings.py
Outdated
Show resolved
Hide resolved
libs/rag-core-lib/src/rag_core_lib/impl/utils/retry_decorator.py
Outdated
Show resolved
Hide resolved
…ecorator_settings.py Co-authored-by: Copilot <[email protected]>
…orator.py Co-authored-by: Copilot <[email protected]>
…cloud/rag-template into feat/exponential-retry-decorator
This pull request introduces a robust, configurable retry decorator with exponential backoff and rate-limit handling for both synchronous and asynchronous functions. It also integrates the retry decorator settings into the infrastructure configuration, making them easily adjustable via environment variables and Kubernetes ConfigMaps. Comprehensive tests have been added to ensure correct behavior. The main changes are grouped below:
Retry Decorator Implementation and Utilities
retry_with_backoff
decorator inlibs/rag-core-lib/src/rag_core_lib/impl/utils/retry_decorator.py
, supporting configurable retries, exponential backoff, jitter, and rate-limit awareness for sync/async functions.libs/rag-core-lib/src/rag_core_lib/impl/utils/utils.py
for parsing rate-limit headers, normalizing dictionaries, and extracting status codes/headers from exceptions.Configuration and Infrastructure Integration
RetryDecoratorSettings
inlibs/rag-core-lib/src/rag_core_lib/impl/settings/retry_decorator_settings.py
using Pydantic, allowing environment-based configuration of retry logic parameters.retryDecorator
configuration block toinfrastructure/rag/values.yaml
for setting retry parameters via Helm values.infrastructure/rag/templates/configmap.yaml
to expose retry decorator settings to Kubernetes deployments.admin-backend/deployment.yaml
,backend/deployment.yaml
) to mount the new retry decorator ConfigMap. [1] [2]_helpers.tpl
.Testing
libs/rag-core-lib/tests/retry_decorator_test.py
to validate retry logic, rate-limit handling, and configuration.This PR covers the following feature request
#87