Examples for Downstream SDK Integration#67
Draft
lukedev45 wants to merge 5 commits into
Draft
Conversation
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds a top-level
examples/directory demonstrating how a downstream SDKintegrates with
ionq-corethrough the extension API — the first runnable,copy-pasteable examples in the repo. Closes #56.
examples/downstream_integration.py(sync) builds anIonQClient(extension=...)with a
ClientExtensioncarrying auser_agent_token,default_headers, arequest/response
EventHook, and anerror_mapperthat wrapsAPIError/RateLimitErrorinto SDK-defined error types. It submits a Bell-state circuitto the free
simulator, waits for completion viawait_for_job, and printsthe probabilities. A short guarded block also requests a nonexistent job so the
error_mapperis shown converting a realNotFoundError, not just wired up.examples/downstream_integration_async.pymirrors the flow on the async pathwith an
AsyncEventHookand theasyncioendpoint variants.examples/README.mddocuments setup (pip install ionq-core,export IONQ_API_KEY=...) and is linked from the top-levelREADME.md.[Unreleased].No changes to
ionq_core/and no new dependencies. Both scripts use only thepublic API, carry SPDX headers, and use
httpxwithapiKeyauth.Test plan
Lint/type/compile (run in CI — no API key needed):
uv run ruff check— passeduv run ruff format --check— passeduv run ty check examples/— passeduv run python -m compileall -q examples— passeduv run pytest— 242 passed, 100% coverage (examples are not collected anddon't affect the coverage gate)
Offline smoke test (no network): both modules import, the Bell-state payload
round-trips through
to_dict(), andmap_errorcorrectly mapsRateLimitError → DownstreamRateLimitErrorandNotFoundError → DownstreamSDKError.End-to-end against the live
simulator(requiresIONQ_API_KEY) was not run inthis environment:
export IONQ_API_KEY=... python examples/downstream_integration.py python examples/downstream_integration_async.py