Skip to content

UN-3230 [FEAT] Implement back-off retry mechanism for API deployment client#12

Merged
jaseemjaskp merged 7 commits intomainfrom
feat/UN-3230-FEAT_implement_backoff_retry_mechanism
Feb 16, 2026
Merged

UN-3230 [FEAT] Implement back-off retry mechanism for API deployment client#12
jaseemjaskp merged 7 commits intomainfrom
feat/UN-3230-FEAT_implement_backoff_retry_mechanism

Conversation

@muhammad-ali-e
Copy link
Contributor

@muhammad-ali-e muhammad-ali-e commented Feb 11, 2026

What

  • Added exponential back-off retry mechanism with full jitter to APIDeploymentsClient
  • New constructor params: max_retries, initial_delay, max_delay, backoff_factor
  • Migrated build tooling from PDM to uv (hatchling backend)

Why

  • Transient server errors (5xx) and rate limits (429) can cause unnecessary failures
  • Automatic retries with exponential backoff improve reliability without manual intervention
  • Full jitter prevents thundering herd when multiple clients retry simultaneously
  • uv is significantly faster than PDM for dependency resolution and installs, and aligns with the broader ecosystem trend

How

  • Custom retry logic in _request_with_retry() wrapping all HTTP calls
  • Exponential backoff: min(initial_delay * backoff_factor^attempt, max_delay) with full jitter
  • Respects Retry-After header for 429 responses
  • Async mode (timeout=0) retries POST requests; sync mode skips POST retries to avoid duplicates
  • File objects are rewound (seek(0)) before each retry attempt
  • Comprehensive test suite with 40+ test cases covering all retry scenarios
  • Replaced PDM build backend with hatchling in pyproject.toml
  • Replaced pdm.lock with uv.lock
  • Updated CI workflow (.github/workflows/main.yml) to use uv instead of PDM
  • Updated .pre-commit-config.yaml to use uv-lock hook instead of pdm-lock-check
  • Updated .gitignore with uv-specific entries

Can this PR break any existing features. If yes, please list possible items. If no, please explain why.

  • No. All retry parameters have sensible defaults matching previous behavior. Setting max_retries=0 disables retries entirely. The PDM→uv migration is a build tooling change only; the published package remains identical.

Database Migrations

  • None

Env Config

  • None

Relevant Docs

Related Issues or PRs

Dependencies Versions

  • No new runtime dependencies (uses only stdlib random, time, and existing requests)
  • Build tooling: PDM → uv (hatchling backend)

Notes on Testing

  • 40+ unit tests in tests/test_retry.py covering: 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 behavior
  • CI pipeline updated to run with uv

Screenshots

N/A

Checklist

I have read and understood the Contribution Guidelines.

muhammad-ali-e and others added 2 commits February 11, 2026 10:11
…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>
muhammad-ali-e and others added 3 commits February 11, 2026 12:18
- 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>
Copy link
Contributor

@jaseemjaskp jaseemjaskp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Replace black, flake8, isort, pycln with ruff for linting and formatting
- Bump pre-commit hooks: ruff-pre-commit v0.15.1, uv-pre-commit 0.10.2,
  docformatter v1.7.7
- Fix deprecated default_stages: 'commit' -> 'pre-commit'
- Bump deps: ruff>=0.15.0, pre-commit>=4.0.0 (dropping autopep8, black,
  flake8, flake8-pyproject, isort)
- Update CI: astral-sh/setup-uv@v7, remove separate setup-python step
- Apply ruff formatting to source and tests

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jaseemjaskp jaseemjaskp self-requested a review February 16, 2026 10:12
@jaseemjaskp jaseemjaskp merged commit 1ff97e6 into main Feb 16, 2026
@jaseemjaskp jaseemjaskp deleted the feat/UN-3230-FEAT_implement_backoff_retry_mechanism branch February 16, 2026 10:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants