Skip to content

Examples for Downstream SDK Integration#67

Draft
lukedev45 wants to merge 5 commits into
ionq:mainfrom
lukedev45:add-downstream-sdk-examples
Draft

Examples for Downstream SDK Integration#67
lukedev45 wants to merge 5 commits into
ionq:mainfrom
lukedev45:add-downstream-sdk-examples

Conversation

@lukedev45
Copy link
Copy Markdown

Summary

Adds a top-level examples/ directory demonstrating how a downstream SDK
integrates with ionq-core through the extension API — the first runnable,
copy-pasteable examples in the repo. Closes #56.

  • examples/downstream_integration.py (sync) builds an IonQClient(extension=...)
    with a ClientExtension carrying a user_agent_token, default_headers, a
    request/response EventHook, and an error_mapper that wraps APIError /
    RateLimitError into SDK-defined error types. It submits a Bell-state circuit
    to the free simulator, waits for completion via wait_for_job, and prints
    the probabilities. A short guarded block also requests a nonexistent job so the
    error_mapper is shown converting a real NotFoundError, not just wired up.
  • examples/downstream_integration_async.py mirrors the flow on the async path
    with an AsyncEventHook and the asyncio endpoint variants.
  • examples/README.md documents setup (pip install ionq-core,
    export IONQ_API_KEY=...) and is linked from the top-level README.md.
  • Changelog entry under [Unreleased].

No changes to ionq_core/ and no new dependencies. Both scripts use only the
public API, carry SPDX headers, and use httpx with apiKey auth.

Test plan

Lint/type/compile (run in CI — no API key needed):

  • uv run ruff check — passed
  • uv run ruff format --check — passed
  • uv run ty check examples/ — passed
  • uv run python -m compileall -q examples — passed
  • uv run pytest — 242 passed, 100% coverage (examples are not collected and
    don't affect the coverage gate)

Offline smoke test (no network): both modules import, the Bell-state payload
round-trips through to_dict(), and map_error correctly maps
RateLimitError → DownstreamRateLimitError and NotFoundError → DownstreamSDKError.

End-to-end against the live simulator (requires IONQ_API_KEY) was not run in
this environment:

export IONQ_API_KEY=...
python examples/downstream_integration.py
python examples/downstream_integration_async.py

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.

Add an examples/ directory demonstrating downstream-SDK integration via the extension API

1 participant