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 16 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.
| 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?
There was a problem hiding this comment.
To allow testing in a different environment other than what's live. 👍
|
|
||
|
|
||
| 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?
There was a problem hiding this comment.
yes, if IONQ_ORG_ID is configured as a live org ID then the test runs on production API
There was a problem hiding this comment.
I'm fine with this staying as it is, but if its not too much of a rabbit hole, I would make this flag more explicit by doing one of:
- naming the env variable something that makes it explicit that it is a switch for controlling which tests are run (e.g.
TEST_PRODUCTION_API_ORG=...) - using a pytest marker (e.g.
@pytest.mark.production_api) and registering it (https://docs.pytest.org/en/stable/deprecations.html#class-scoped-fixture-as-instance-method). This would be my preference.
A downside to the current approach is that a typo in the env name would cause tests to silently be skipped. It would be better if the tests were explicitly enabled and failed if they were enabled without providing an ORG_ID.
Co-authored-by: Simon Cross <simon.cross@ionq.co>
|
@hodgestar-ionq thank you for the questions! I've left answers to each. |
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