-
Notifications
You must be signed in to change notification settings - Fork 7
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
Merged
Merged
Changes from 7 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
1db3fe7
feat: implement retry decorator with exponential backoff and rate lim…
a-klos cbdd287
refactor: improve retry decorator by separating async and sync logic;…
a-klos 815ca87
test: add comprehensive tests for retry decorator with async and sync…
a-klos cdb5445
feat: add retry decorator configuration and update deployment templates
a-klos 72e2480
docs: add documentation for retry decorator with exponential backoff …
a-klos bde7a8c
feat: add pytest-asyncio dependency for improved async testing support
a-klos b65c696
Merge branch 'main' into feat/exponential-retry-decorator
a-klos 657715c
docs: Update libs/rag-core-lib/src/rag_core_lib/impl/settings/retry_d…
a-klos f94ab4e
chore: Update libs/rag-core-lib/src/rag_core_lib/impl/utils/retry_dec…
a-klos 2dd24a0
chore: merge main
a-klos ae1f8e1
Merge branch 'feat/exponential-retry-decorator' of github.com:stackit…
a-klos 8acf200
refactor: equip the langchain summarizer with a retry decorator. (#90)
a-klos 2866593
refactor: remove redundant validation checks in RetryDecoratorSettings
a-klos 210c241
refactor: equip the stackit embedder with a retry decorator. (#91)
a-klos f87d9a0
chore: merge main
a-klos ba120c1
refactor: clean up import statements and streamline retry decorator s…
a-klos 63b9eae
refactor: improve readability of settings initialization in create_re…
a-klos c317897
refactor: enhance settings initialization and validation in Summarize…
a-klos b4f291b
refactor: add validation for jitter_min and jitter_max in Summarizer …
a-klos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
83 changes: 83 additions & 0 deletions
83
libs/rag-core-lib/src/rag_core_lib/impl/settings/retry_decorator_settings.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| """Module contains settings regarding the STACKIT vLLM.""" | ||
|
|
||
| from pydantic import Field, PositiveInt, model_validator | ||
| from pydantic_settings import BaseSettings, SettingsConfigDict | ||
|
|
||
|
|
||
| class RetryDecoratorSettings(BaseSettings): | ||
| """ | ||
| Contains settings regarding the retry decorator. | ||
|
|
||
| Attributes | ||
| ---------- | ||
| max_retries : int (> 0) | ||
| Total retries (not counting the first attempt). | ||
| retry_base_delay : float (>= 0) | ||
| Base delay in seconds for the first retry. | ||
| retry_max_delay : float (> 0) | ||
| Maximum delay cap for any single wait. | ||
| backoff_factor : float (>= 1) | ||
| Exponential backoff factor. | ||
| attempt_cap : int (>= 0) | ||
| Cap for exponent growth (backoff_factor ** attempt_cap). | ||
| jitter_min : float (>= 0) | ||
| Minimum jitter to add to wait times. | ||
| jitter_max : float (>= jitter_min) | ||
| Maximum jitter to add to wait times. | ||
| """ | ||
|
|
||
| model_config = SettingsConfigDict(env_prefix="RETRY_DECORATOR_", case_sensitive=False) | ||
|
|
||
| max_retries: PositiveInt = Field( | ||
| default=5, | ||
| title="Max Retries", | ||
| description="Total retries, not counting the initial attempt.", | ||
| ) | ||
| retry_base_delay: float = Field( | ||
| default=0.5, | ||
| ge=0, | ||
| title="Retry Base Delay", | ||
| description="Base delay in seconds for the first retry.", | ||
| ) | ||
| retry_max_delay: float = Field( | ||
| default=600.0, | ||
| gt=0, | ||
| title="Retry Max Delay", | ||
| description="Maximum delay cap in seconds for any single wait.", | ||
| ) | ||
| backoff_factor: float = Field( | ||
| default=2.0, | ||
| ge=1.0, | ||
| title="Backoff Factor", | ||
| description="Exponential backoff factor (>= 1).", | ||
| ) | ||
| attempt_cap: int = Field( | ||
| default=6, | ||
| ge=0, | ||
| title="Attempt Cap", | ||
| description="Cap for exponent growth (backoff_factor ** attempt_cap).", | ||
| ) | ||
| jitter_min: float = Field( | ||
| default=0.05, | ||
| ge=0.0, | ||
| title="Jitter Min (s)", | ||
| description="Minimum jitter in seconds.", | ||
| ) | ||
| jitter_max: float = Field( | ||
| default=0.25, | ||
| ge=0.0, | ||
| title="Jitter Max (s)", | ||
| description="Maximum jitter in seconds.", | ||
| ) | ||
|
|
||
| @model_validator(mode="after") | ||
| def _check_relations(self) -> "RetryDecoratorSettings": | ||
| # Ensure jitter_max >= jitter_min | ||
| if self.jitter_max < self.jitter_min: | ||
| raise ValueError("jitter_max must be >= jitter_min") | ||
| # Ensure retry_max_delay is meaningful vs base | ||
| if self.retry_max_delay <= 0: | ||
| raise ValueError("retry_max_delay must be > 0") | ||
| if self.backoff_factor < 1: | ||
| raise ValueError("backoff_factor must be >= 1") | ||
a-klos marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| return self | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.