Skip to content

Commit 250fb97

Browse files
authored
Sync OpenAPI spec with upstream fixes, remove overlay (#9)
* Sync OpenAPI spec with ionq/api#1146 and minimize overlay Vendor the updated spec from the ionq/api sync PR which includes Xiaoyun's upstream fixes: enum restrictions removed, gate schema field names corrected (type->gate), expanded Job required fields, results/probabilities endpoint added natively, and three new variant result endpoints. The overlay shrinks from 155 lines (22 actions) to 111 lines (25 actions), now covering only nullable field mismatches that remain in the upstream spec: - JsonObject, Failure, JobMetadata schemas: nullable - Job/BaseJobSummary: 10 nullable primitive fields each - GetCircuitJobResponse: settings/stats allOf+nullable - Backend.degraded: removed from required (not all backends return it) Generator config updated for renamed Gate schemas (Gate_QisGate_ -> Gate_QisGate) and removed overrides for deleted Optional_* schemas. Test fixtures updated to include newly-required nullable fields. Verified end-to-end against production API. * Fix overlay: remove unnecessary nullable patches Remove JsonObject nullable (output/settings/stats are always {}, never null) and GetCircuitJobResponse settings/stats nullable. Only results, failure, and metadata are actually null in the API. Test fixtures corrected to match real API: output/settings/stats use {} instead of null. * Fix JobMetadata nullable: per-property, not schema-level JobMetadata is used in creation payloads where null is invalid. Move the nullable treatment to allOf+nullable on the response properties (Job.metadata, BaseJobSummary.metadata) instead of making the schema itself nullable. * Sync spec with cloud-job-manager#980, overlay down to 1 action Incorporate Xiaoyun's nullable fixes from CJM PR #980 which adds proper nullable annotations to BaseJob fields using tsoa @nullable jsdoc instead of Omit/Pick utility types. The overlay now contains only Backend.degraded (ion-queue#1410). - Job and Pick_BaseJob schemas replaced by BaseJob - Optional_string_ removed (inline nullable used instead) - project_id, parent_job_id, session_id, name: nullable in spec - metadata, failure, results: allOf+nullable in spec - started_at, completed_at: Optional_IsoTimestamp_ ref - predicted/execution durations: Optional_number_ ref - Generator config: removed Pick_BaseJob and Optional_string_ overrides * Sync with final CJM#980 spec: remove Optional_ wrappers Xiaoyun replaced Optional_IsoTimestamp_ and Optional_number_ with inline allOf+nullable and nullable integer annotations directly on the fields. Generator config simplified to just gate class overrides. * Remove overlay: production spec now matches API behavior All upstream fixes have landed in production (api.ionq.co/v0.4): - CJM#980: nullable fields on BaseJob/GetCircuitJobResponse - ion-queue#1406: enum restrictions removed - ion-queue#1410: Backend.degraded optional - ionq/api#1148: spec synced from GCS The overlay file is no longer needed. Client regenerated directly from the production spec without any patches.
1 parent 0227e85 commit 250fb97

31 files changed

Lines changed: 1499 additions & 1836 deletions

ionq_core/_pagination.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
if TYPE_CHECKING:
1414
from .client import AuthenticatedClient
15-
from .models.job import Job
15+
from .models.base_job import BaseJob as Job
1616
from .models.job_status import JobStatus
1717

1818
logger = logging.getLogger("ionq_core")

ionq_core/api/default/estimate_job_cost.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ def sync_detailed(
113113
) -> Response[Any | GetJobEstimateResponse]:
114114
"""
115115
Args:
116-
backend (str):
116+
backend (str): Available options: `simulator`, `qpu.aria-1`, `qpu.aria-2`, `qpu.forte-1`,
117+
`qpu.forte-enterprise-1`
117118
type_ (str | Unset): Default: 'ionq.circuit.v1'.
118119
qubits (int | Unset): Default: 25.
119120
shots (int | Unset): Default: 1000.
@@ -161,7 +162,8 @@ def sync(
161162
) -> Any | GetJobEstimateResponse | None:
162163
"""
163164
Args:
164-
backend (str):
165+
backend (str): Available options: `simulator`, `qpu.aria-1`, `qpu.aria-2`, `qpu.forte-1`,
166+
`qpu.forte-enterprise-1`
165167
type_ (str | Unset): Default: 'ionq.circuit.v1'.
166168
qubits (int | Unset): Default: 25.
167169
shots (int | Unset): Default: 1000.
@@ -204,7 +206,8 @@ async def asyncio_detailed(
204206
) -> Response[Any | GetJobEstimateResponse]:
205207
"""
206208
Args:
207-
backend (str):
209+
backend (str): Available options: `simulator`, `qpu.aria-1`, `qpu.aria-2`, `qpu.forte-1`,
210+
`qpu.forte-enterprise-1`
208211
type_ (str | Unset): Default: 'ionq.circuit.v1'.
209212
qubits (int | Unset): Default: 25.
210213
shots (int | Unset): Default: 1000.
@@ -252,7 +255,8 @@ async def asyncio(
252255
) -> Any | GetJobEstimateResponse | None:
253256
"""
254257
Args:
255-
backend (str):
258+
backend (str): Available options: `simulator`, `qpu.aria-1`, `qpu.aria-2`, `qpu.forte-1`,
259+
`qpu.forte-enterprise-1`
256260
type_ (str | Unset): Default: 'ionq.circuit.v1'.
257261
qubits (int | Unset): Default: 25.
258262
shots (int | Unset): Default: 1000.

ionq_core/api/default/get_job_probabilities.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from ...types import Response, UNSET
99
from ... import errors
1010

11-
from ...models.get_job_probabilities_response_200 import GetJobProbabilitiesResponse200
11+
from ...models.get_results_response import GetResultsResponse
1212
from ...types import UNSET, Unset
1313
from typing import cast
1414

@@ -43,9 +43,9 @@ def _get_kwargs(
4343

4444

4545

46-
def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Any | GetJobProbabilitiesResponse200 | None:
46+
def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Any | GetResultsResponse | None:
4747
if response.status_code == 200:
48-
response_200 = GetJobProbabilitiesResponse200.from_dict(response.json())
48+
response_200 = GetResultsResponse.from_dict(response.json())
4949

5050

5151

@@ -61,7 +61,7 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res
6161
return None
6262

6363

64-
def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any | GetJobProbabilitiesResponse200]:
64+
def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any | GetResultsResponse]:
6565
return Response(
6666
status_code=HTTPStatus(response.status_code),
6767
content=response.content,
@@ -76,7 +76,7 @@ def sync_detailed(
7676
client: AuthenticatedClient,
7777
sharpen: bool | Unset = UNSET,
7878

79-
) -> Response[Any | GetJobProbabilitiesResponse200]:
79+
) -> Response[Any | GetResultsResponse]:
8080
""" Fetch the probability distribution for a completed job.
8181
8282
Args:
@@ -88,7 +88,7 @@ def sync_detailed(
8888
httpx.TimeoutException: If the request takes longer than Client.timeout.
8989
9090
Returns:
91-
Response[Any | GetJobProbabilitiesResponse200]
91+
Response[Any | GetResultsResponse]
9292
"""
9393

9494

@@ -110,7 +110,7 @@ def sync(
110110
client: AuthenticatedClient,
111111
sharpen: bool | Unset = UNSET,
112112

113-
) -> Any | GetJobProbabilitiesResponse200 | None:
113+
) -> Any | GetResultsResponse | None:
114114
""" Fetch the probability distribution for a completed job.
115115
116116
Args:
@@ -122,7 +122,7 @@ def sync(
122122
httpx.TimeoutException: If the request takes longer than Client.timeout.
123123
124124
Returns:
125-
Any | GetJobProbabilitiesResponse200
125+
Any | GetResultsResponse
126126
"""
127127

128128

@@ -139,7 +139,7 @@ async def asyncio_detailed(
139139
client: AuthenticatedClient,
140140
sharpen: bool | Unset = UNSET,
141141

142-
) -> Response[Any | GetJobProbabilitiesResponse200]:
142+
) -> Response[Any | GetResultsResponse]:
143143
""" Fetch the probability distribution for a completed job.
144144
145145
Args:
@@ -151,7 +151,7 @@ async def asyncio_detailed(
151151
httpx.TimeoutException: If the request takes longer than Client.timeout.
152152
153153
Returns:
154-
Response[Any | GetJobProbabilitiesResponse200]
154+
Response[Any | GetResultsResponse]
155155
"""
156156

157157

@@ -173,7 +173,7 @@ async def asyncio(
173173
client: AuthenticatedClient,
174174
sharpen: bool | Unset = UNSET,
175175

176-
) -> Any | GetJobProbabilitiesResponse200 | None:
176+
) -> Any | GetResultsResponse | None:
177177
""" Fetch the probability distribution for a completed job.
178178
179179
Args:
@@ -185,7 +185,7 @@ async def asyncio(
185185
httpx.TimeoutException: If the request takes longer than Client.timeout.
186186
187187
Returns:
188-
Any | GetJobProbabilitiesResponse200
188+
Any | GetResultsResponse
189189
"""
190190

191191

Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
from http import HTTPStatus
2+
from typing import Any, cast
3+
from urllib.parse import quote
4+
5+
import httpx
6+
7+
from ...client import AuthenticatedClient, Client
8+
from ...types import Response, UNSET
9+
from ... import errors
10+
11+
from ...models.get_variant_results_response import GetVariantResultsResponse
12+
from typing import cast
13+
14+
15+
16+
def _get_kwargs(
17+
uuid: str,
18+
variant_id: str,
19+
20+
) -> dict[str, Any]:
21+
22+
23+
24+
25+
26+
27+
_kwargs: dict[str, Any] = {
28+
"method": "get",
29+
"url": "/jobs/{uuid}/variants/{variant_id}/results/histogram".format(uuid=quote(str(uuid), safe=""),variant_id=quote(str(variant_id), safe=""),),
30+
}
31+
32+
33+
return _kwargs
34+
35+
36+
37+
def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Any | GetVariantResultsResponse | None:
38+
if response.status_code == 200:
39+
response_200 = GetVariantResultsResponse.from_dict(response.json())
40+
41+
42+
43+
return response_200
44+
45+
if response.status_code == 404:
46+
response_404 = cast(Any, None)
47+
return response_404
48+
49+
if client.raise_on_unexpected_status:
50+
raise errors.UnexpectedStatus(response.status_code, response.content)
51+
else:
52+
return None
53+
54+
55+
def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any | GetVariantResultsResponse]:
56+
return Response(
57+
status_code=HTTPStatus(response.status_code),
58+
content=response.content,
59+
headers=response.headers,
60+
parsed=_parse_response(client=client, response=response),
61+
)
62+
63+
64+
def sync_detailed(
65+
uuid: str,
66+
variant_id: str,
67+
*,
68+
client: AuthenticatedClient,
69+
70+
) -> Response[Any | GetVariantResultsResponse]:
71+
"""
72+
Args:
73+
uuid (str):
74+
variant_id (str):
75+
76+
Raises:
77+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
78+
httpx.TimeoutException: If the request takes longer than Client.timeout.
79+
80+
Returns:
81+
Response[Any | GetVariantResultsResponse]
82+
"""
83+
84+
85+
kwargs = _get_kwargs(
86+
uuid=uuid,
87+
variant_id=variant_id,
88+
89+
)
90+
91+
response = client.get_httpx_client().request(
92+
**kwargs,
93+
)
94+
95+
return _build_response(client=client, response=response)
96+
97+
def sync(
98+
uuid: str,
99+
variant_id: str,
100+
*,
101+
client: AuthenticatedClient,
102+
103+
) -> Any | GetVariantResultsResponse | None:
104+
"""
105+
Args:
106+
uuid (str):
107+
variant_id (str):
108+
109+
Raises:
110+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
111+
httpx.TimeoutException: If the request takes longer than Client.timeout.
112+
113+
Returns:
114+
Any | GetVariantResultsResponse
115+
"""
116+
117+
118+
return sync_detailed(
119+
uuid=uuid,
120+
variant_id=variant_id,
121+
client=client,
122+
123+
).parsed
124+
125+
async def asyncio_detailed(
126+
uuid: str,
127+
variant_id: str,
128+
*,
129+
client: AuthenticatedClient,
130+
131+
) -> Response[Any | GetVariantResultsResponse]:
132+
"""
133+
Args:
134+
uuid (str):
135+
variant_id (str):
136+
137+
Raises:
138+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
139+
httpx.TimeoutException: If the request takes longer than Client.timeout.
140+
141+
Returns:
142+
Response[Any | GetVariantResultsResponse]
143+
"""
144+
145+
146+
kwargs = _get_kwargs(
147+
uuid=uuid,
148+
variant_id=variant_id,
149+
150+
)
151+
152+
response = await client.get_async_httpx_client().request(
153+
**kwargs
154+
)
155+
156+
return _build_response(client=client, response=response)
157+
158+
async def asyncio(
159+
uuid: str,
160+
variant_id: str,
161+
*,
162+
client: AuthenticatedClient,
163+
164+
) -> Any | GetVariantResultsResponse | None:
165+
"""
166+
Args:
167+
uuid (str):
168+
variant_id (str):
169+
170+
Raises:
171+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
172+
httpx.TimeoutException: If the request takes longer than Client.timeout.
173+
174+
Returns:
175+
Any | GetVariantResultsResponse
176+
"""
177+
178+
179+
return (await asyncio_detailed(
180+
uuid=uuid,
181+
variant_id=variant_id,
182+
client=client,
183+
184+
)).parsed

0 commit comments

Comments
 (0)