|
19 | 19 |
|
20 | 20 | from qio.core import ( |
21 | 21 | QuantumProgram, |
| 22 | + QuantumProgramSerializationFormat, |
22 | 23 | QuantumProgramResult, |
23 | 24 | QuantumComputationModel, |
24 | 25 | QuantumComputationParameters, |
@@ -174,7 +175,9 @@ def run_sweep( |
174 | 175 | for param_resolver in cirq.study.to_resolvers(params): |
175 | 176 | circuit = cirq.protocols.resolve_parameters(program, param_resolver) |
176 | 177 |
|
177 | | - program = QuantumProgram.from_cirq_circuit(circuit) |
| 178 | + program = QuantumProgram.from_cirq_circuit( |
| 179 | + circuit, QuantumProgramSerializationFormat.CIRQ_CIRCUIT_JSON_V1 |
| 180 | + ) |
178 | 181 |
|
179 | 182 | results = self._submit(program, repetitions, self.__id) |
180 | 183 | trial_results.append(results) |
@@ -209,15 +212,15 @@ def _wait_for_result( |
209 | 212 | elapsed = time.time() - start_time |
210 | 213 |
|
211 | 214 | if timeout is not None and elapsed >= timeout: |
212 | | - raise Exception("Timed out waiting for result") |
| 215 | + raise RuntimeError("Timed out waiting for result") |
213 | 216 |
|
214 | 217 | job = self.__client.get_job(job_id) |
215 | 218 |
|
216 | 219 | if job.status == "completed": |
217 | 220 | return self.__client.list_job_results(job_id) |
218 | 221 |
|
219 | 222 | if job.status in ["error", "unknown_status"]: |
220 | | - raise Exception("Job error") |
| 223 | + raise RuntimeError(f"Job failed: {job.progress_message}") |
221 | 224 |
|
222 | 225 | def _submit( |
223 | 226 | self, program: QuantumProgram, shots: int, session_id: str |
@@ -257,7 +260,7 @@ def _submit( |
257 | 260 | job_results = self._wait_for_result(job_id, 60 * 100, 2) |
258 | 261 |
|
259 | 262 | if len(job_results) != 1: |
260 | | - raise Exception("Expected a single result for Cirq job") |
| 263 | + raise RuntimeError("Expected a single result for Cirq job") |
261 | 264 |
|
262 | 265 | result = self._extract_payload_from_response(job_results[0]).to_cirq_result() |
263 | 266 |
|
|
0 commit comments