Skip to content

Add Python SDK (draft) - #1

Merged
clarivo-dev merged 3 commits into
mainfrom
feat/sdk-v0
Oct 27, 2026
Merged

clarivo-dev merged 3 commits into
mainfrom
feat/sdk-v0

Conversation

@ernestova

@ernestova ernestova commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

First import of the Python SDK (pre-release, Private :: Do Not Upload classifier, nothing is published).

  • Pydantic v2 models generated from the OpenAPI 3.1 spec with datamodel-code-generator (scripts/generate.py; CI fails on drift).
  • Thin hand-written httpx client, sync and async: retries with Retry-After, one Idempotency-Key per call reused by retries, RFC 9457 typed errors, cursor pagination, warm_runs.wait().
  • https-only base URL, no redirects, the key never appears in repr or errors.

Tested: 29 tests, mypy strict.

Ported review findings

Ported from the Go SDK review: a keyed POST retries a 409 conflict (never idempotency-key-reused); certificate/TLS verification, unknown-host and malformed-request errors are not retried; Retry-After is floored at the retry base with up to +25% jitter (above the cap it is still raised); a 2xx body that is not JSON raises SiteWarmDecodeError(status); the User-Agent carries version and URL and an empty one keeps the default. Tests: tests/test_lows.py (59 pass, mypy strict clean).

Deviations: the version is 0.1.0 (what the package declares), so the UA is sitewarm-python/0.1.0 (+https://github.com/sitewarm/sdk-python). The base path already keeps percent-encoding (urlsplit().path), so only a regression test was added. DNS "not found" means EAI_NONAME/EAI_NODATA; a temporary failure (EAI_AGAIN) is still retried. Ids stay opaque; key validation and error sentinels are out of scope.

🤖 Generated with Claude Code

ernestova and others added 3 commits October 26, 2026 23:53
…y-After floor, decode error, User-Agent

- Retry a 409 conflict on keyed POSTs only; never idempotency-key-reused.
- Do not retry certificate, unknown-host or malformed-request errors.
- Retry-After floor at the retry base, with jitter; longer than the cap is surfaced.
- Typed decode error (with status) for a 2xx body that is not JSON.
- User-Agent carries version and URL; an empty custom one keeps the default.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y4ijWAJZzDChcsSYmgTYcD
@clarivo-dev
clarivo-dev marked this pull request as ready for review October 27, 2026 20:02
@clarivo-dev
clarivo-dev merged commit 1402af4 into main Oct 27, 2026
2 checks passed
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.

2 participants