@@ -188,28 +188,11 @@ def _fetch_pytket_execution_result(
188188 """Get the results for an execute job item."""
189189 assert result_ref .result_type == ResultType .PYTKET , "Incorrect result type"
190190
191- res = get_nexus_client ().get (f"/api/results/v1beta3/partial/{ result_ref .id } " )
192-
191+ res = get_nexus_client ().get (f"/api/results/v1beta3/{ result_ref .id } " )
193192 if res .status_code != 200 :
194193 raise qnx_exc .ResourceFetchFailed (message = res .text , status_code = res .status_code )
195194
196195 res_dict = res .json ()
197- next_key = res_dict ["data" ]["attributes" ].get ("next_key" )
198- shots = res_dict ["data" ]["attributes" ].get ("shots" )
199-
200- while next_key is not None :
201- next_partial_res = get_nexus_client ().get (
202- f"/api/results/v1beta3/partial/{ result_ref .id } ?{ next_key } "
203- )
204- if next_partial_res .status_code != 200 :
205- raise qnx_exc .ResourceFetchFailed (
206- message = res .text , status_code = next_partial_res .status_code
207- )
208- next_shots = next_partial_res .json ()["data" ]["attributes" ].get ("shots" )
209- if shots is not None and next_shots is not None :
210- shots ["width" ] = max (shots ["width" ], next_shots ["width" ])
211- shots ["array" ].extend (next_shots ["array" ])
212- next_key = next_partial_res .json ()["data" ]["attributes" ].get ("next_key" )
213196 program_data = res_dict ["data" ]["relationships" ]["program" ]["data" ]
214197 program_id = program_data ["id" ]
215198 program_type = program_data ["type" ]
@@ -246,16 +229,19 @@ def _fetch_qsys_execution_result(
246229 """Get the results of a next-gen Qsys execute job."""
247230 assert result_ref .result_type == ResultType .QSYS , "Incorrect result type"
248231
249- params = {"version" : version .value }
232+ chunk_number = 0
233+ params = {"version" : version .value , "chunk" : chunk_number }
234+
250235 res = get_nexus_client ().get (
251- f"/api/qsys_results/v1beta /partial/{ result_ref .id } " , params = params
236+ f"/api/qsys_results/v1beta2 /partial/{ result_ref .id } " , params = params
252237 )
253- res_dict = res .json ()
254- next_key = res_dict ["data" ]["attributes" ].get ("next_key" )
255238
256239 if res .status_code != 200 :
257240 raise qnx_exc .ResourceFetchFailed (message = res .text , status_code = res .status_code )
258241
242+ # This is only needed to be set once, as subsequent calls will
243+ # return the same information for the relationships.
244+ res_dict = res .json ()
259245 input_program_id = res_dict ["data" ]["relationships" ]["program" ]["data" ]["id" ]
260246
261247 input_program : HUGRRef | QIRRef
@@ -277,11 +263,25 @@ def _fetch_qsys_execution_result(
277263 else :
278264 result = QsysResult (res_dict ["data" ]["attributes" ].get ("results" ))
279265
280- while next_key is not None :
281- params ["key" ] = next_key
266+ backend_info_data = next (
267+ data for data in res_dict ["included" ] if data ["type" ] == "backend_snapshot"
268+ )
269+ backend_info = to_pytket_backend_info (
270+ StoredBackendInfo (** backend_info_data ["attributes" ])
271+ )
272+
273+ # We shouldn't be doing infinite loops, but the API currently doesn't
274+ # provide a way to know how many chunks there are, so we loop until we
275+ # get all of them.
276+ while True :
277+ chunk_number += 1
278+ params ["chunk_number" ] = chunk_number
282279 partial = get_nexus_client ().get (
283- f"/api/qsys_results/v1beta /partial/{ result_ref .id } " , params = params
280+ f"/api/qsys_results/v1beta2 /partial/{ result_ref .id } " , params = params
284281 )
282+ if partial .status_code == 404 :
283+ # No more chunks. Stop here.
284+ break
285285 if partial .status_code != 200 :
286286 raise qnx_exc .ResourceFetchFailed (
287287 message = res .text , status_code = partial .status_code
@@ -308,13 +308,6 @@ def _fetch_qsys_execution_result(
308308 else :
309309 next_res = QsysResult (partial .json ()["data" ]["attributes" ]["results" ])
310310 result .results .extend (next_res .results )
311- next_key = partial .json ()["data" ]["attributes" ].get ("next_key" )
312- backend_info_data = next (
313- data for data in res_dict ["included" ] if data ["type" ] == "backend_snapshot"
314- )
315- backend_info = to_pytket_backend_info (
316- StoredBackendInfo (** backend_info_data ["attributes" ])
317- )
318311
319312 return (
320313 result ,
0 commit comments