fix: Fix estimate, usage, and job-response parsing against the live v0.4 API - #93
fix: Fix estimate, usage, and job-response parsing against the live v0.4 API#93antalszava wants to merge 13 commits into
Conversation
hodgestar-ionq
left a comment
There was a problem hiding this comment.
Left some questions and comments. Thank you for all the fixes.
| # The spec's GetJobResponse component is an anyOf union, which the | ||
| # generator inlines instead of emitting as a model class. |
There was a problem hiding this comment.
| # The spec's GetJobResponse component is an anyOf union, which the | |
| # generator inlines instead of emitting as a model class. | |
| # The spec's GetJobResponse component is an anyOf union, which the | |
| # generator inlines instead of emitting as a model class, so we manual | |
| # construct an appropriate GetJobResponse type here: |
Does this mean this definition will need to be manually updated if the model is changed? Is there a unit test that would catch the mismatch if a change was made?
| key = os.environ.get("IONQ_API_URL") | ||
| if not key: | ||
| return DEFAULT_BASE_URL | ||
| return key |
There was a problem hiding this comment.
| key = os.environ.get("IONQ_API_URL") | |
| if not key: | |
| return DEFAULT_BASE_URL | |
| return key | |
| return os.environ.get("IONQ_API_URL", DEFAULT_BASE_URL) |
There was a problem hiding this comment.
Out of curiosity, what was the reason for allowing the base URL used by the tests to be overridden by IONQ_API_URL?
|
|
||
|
|
||
| @pytest.fixture(scope="session") | ||
| def completed_job_id(client): |
There was a problem hiding this comment.
Why did this fixture get moved?
I'm also confused about the scope. It looks like it could just be omitted? The scope of the client fixture is function.
|
|
||
|
|
||
| def test_get_usages(client): | ||
| @pytest.fixture |
There was a problem hiding this comment.
I'm wondering why these tests need to be skipped? Are they run against a live API somewhere?
Fixes three runtime failures against the live v0.4 API —
estimate_job_cost,get_usages, andget_jobparsing — by patching stale/incorrect schemas inopenapi-overlay.yamland regenerating the client. Also unblocks committing generated output (pre-commit was rewriting it) and fixes a pytest deprecation in the integration tests.Hand-written changes
Library
ionq_core/polling.py— the spec'sGetJobResponsecomponent became ananyOfunion, so the generator no longer emits a model class for it; replaced the dead import with aTYPE_CHECKING-only union alias over the four job types.Spec overlay (
openapi-overlay.yaml)GetJobEstimateResponsereplaced with the shape the API actually serves (estimate_context/rate_card/estimated_total_cost/estimated_unit) — was raisingKeyError: 'input_values'.organization_idno longerformat: uuid— real org ids are reverse-DNS strings; was raisingbadly formed hexadecimal UUID string.Usage.fromwideneddate→date-time— the API returns RFC 3339 date-times; was raisingInvalid isoformat string.ErrorMitigationOutput.debiasingwidened toanyOfboolean/object — the API servesfalsewhen debiasing is off; was surfacing as a misleadingUnexpected value 'ionq.circuit.v1'from theGetJobResponseunion parser.Tooling
.pre-commit-config.yaml— excluded generated files fromtrailing-whitespace/end-of-file-fixer; they were rewriting generator output at commit time and breaking thegenerated.ymlbyte-exact staleness check.CHANGELOG.md— "Fixed" entries for the estimate, org-id, andUsage.frombugs.Integration tests
conftest.py— new session-scopedbase_urlfixture (readsIONQ_API_URL, falls back to the default).test_async.py/test_backends.py— fixtures threadbase_urlthrough instead of hardcoding it.test_usage.py— neworg_idfixture (readsIONQ_ORG_ID, skips when unset); used instead of the literal"self".test_simulator_job.py—completed_job_idmoved from a class-scoped instance-method fixture to a module-level session fixture, fixingPytestRemovedIn10Warning: Class-scoped fixture defined as instance method is deprecated.test_sessions.py— accepts"created"as a valid initial session status.Generated changes
Everything under
ionq_core/api/andionq_core/models/(105 files: ~50 new models from the May-2026 upstream spec sync — theSingleCircuitJob/MultiCircuitJob/QaoaJob/QuantumFunctionJobfamilies, result formats, artifact descriptors, the newmove_jobandschemasendpoints — plus modifications from the overlay fixes above). Mechanicalopenapi-python-clientoutput; thegenerated.ymlstaleness check reproduces it byte-for-byte, so it doesn't need line-by-line review.openapi.jsonis the vendored upstream spec (1-line change).Testing
test_sessionsfailures (sessions not enabled for project, an account limitation).Note on AI usage