UN-3230 [FEAT] Implement back-off retry mechanism for API deployment client#12
UN-3230 [FEAT] Implement back-off retry mechanism for API deployment client#12muhammad-ali-e wants to merge 6 commits intomainfrom
Conversation
…client Add exponential back-off retry with full jitter to APIDeploymentsClient for improved reliability against transient 5xx errors and 429 rate limits. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Version updates are handled separately during the release process. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add python-dotenv to both PDM and uv dev dependencies so tests/client_test.py can run standalone without ModuleNotFoundError - Fix pre-commit default Python version from python3.9 to python3 - Refine structure_file pending detection: only set pending=True on 2xx responses (POST 422 indicates setup errors, not queued work) - Fix trailing newlines in utils.py and sample.env - Update tests to match new 422 pending behavior and fix docstring formatting Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
pyproject.toml
Outdated
| requires = ["pdm-backend"] | ||
| build-backend = "pdm.backend" | ||
|
|
||
| [dependency-groups] |
There was a problem hiding this comment.
@muhammad-ali-e Why "python-dotenv added in both places?
There was a problem hiding this comment.
it's dev dependancy for test
| ] | ||
|
|
||
| [tool.pdm.dev-dependencies] | ||
| test = [ |
There was a problem hiding this comment.
@muhammad-ali-e it looks like this project is not migrated into uv yet. so please migrate it into UV first. no need to keep both pdm and uv in one place
There was a problem hiding this comment.
We can do that as another task
jaseemjaskp
left a comment
There was a problem hiding this comment.
Migrate this project entirely into uv . it looks like you already added the lock file and some of the pyproject.toml file changed into UV
| sdist = { url = "https://files.pythonhosted.org/packages/e0/2d/a891ca51311197f6ad14a7ef42e2399f36cf2f9bd44752b3dc4eab60fdc5/certifi-2026.1.4.tar.gz", hash = "sha256:ac726dd470482006e014ad384921ed6438c457018f4b3d204aea4281258b2120", size = 154268, upload-time = "2026-01-04T02:42:41.825Z" } | ||
| wheels = [ | ||
| { url = "https://files.pythonhosted.org/packages/e6/ad/3cc14f097111b4de0040c83a525973216457bbeeb63739ef1ed275c1c021/certifi-2026.1.4-py3-none-any.whl", hash = "sha256:9943707519e4add1115f44c2bc244f782c0249876bf51b6599fee1ffbedd685c", size = 152900, upload-time = "2026-01-04T02:42:40.15Z" }, | ||
| ] |
There was a problem hiding this comment.
@muhammad-ali-e better to migrate into UV. because you already added uv.lock. Refere llmwhisperer python client if any doubts and make sure all pdm related mentions removed from pyproject.toml and remove pdm.lock
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
| with: | ||
| python-version: 3.11 | ||
| version: 2.10.0 | ||
| python-version: "3.12" |
There was a problem hiding this comment.
@muhammad-ali-e you can pin the python version here https://github.com/astral-sh/setup-uv. no need to setup python separately
What
APIDeploymentsClientmax_retries,initial_delay,max_delay,backoff_factorWhy
How
_request_with_retry()wrapping all HTTP callsmin(initial_delay * backoff_factor^attempt, max_delay)with full jitterRetry-Afterheader for 429 responsesseek(0)) before each retry attemptpyproject.tomlpdm.lockwithuv.lock.github/workflows/main.yml) to use uv instead of PDM.pre-commit-config.yamlto useuv-lockhook instead ofpdm-lock-check.gitignorewith uv-specific entriesCan this PR break any existing features. If yes, please list possible items. If no, please explain why.
max_retries=0disables retries entirely. The PDM→uv migration is a build tooling change only; the published package remains identical.Database Migrations
Env Config
Relevant Docs
Related Issues or PRs
Dependencies Versions
random,time, and existingrequests)Notes on Testing
tests/test_retry.pycovering: defaults, retryable status codes, delay calculation, connection errors, retry exhaustion, non-retryable codes, Retry-After header, file seek on retry, disabled retry, async vs sync mode behaviorScreenshots
N/A
Checklist
I have read and understood the Contribution Guidelines.