Skip to content

Commit f4ca04a

Browse files
authored
Fix: Compatibility with Qiskit's run_circuits and CircuitSampler utilities. (#19)
1 parent 3541cad commit f4ca04a

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

qiskit_rigetti/_qcs_job.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,14 @@ def cancel(self) -> None:
177177
raise NotImplementedError("Cancelling jobs is not supported")
178178

179179
def status(self) -> JobStatus:
180-
"""Get the current status of this Job"""
180+
"""Get the current status of this Job
181+
182+
If this job was RUNNING when you called it, this function will block until the job is complete.
183+
"""
184+
185+
if self._status == JobStatus.RUNNING:
186+
# Wait for results _now_ to finish running, otherwise consuming code might wait forever.
187+
self.result()
181188

182189
return self._status
183190

tests/test_qcs_backend.py

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ def test_run(backend: RigettiQCSBackend):
2727
job = execute(circuit, backend, shots=10)
2828

2929
assert job.backend() is backend
30-
assert job.status() == JobStatus.RUNNING
3130
result = job.result()
3231
assert job.status() == JobStatus.DONE
3332
assert result.backend_name == backend.configuration().backend_name

tests/test_qcs_job.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,14 @@ def test_init__circuit_with_barrier(backend: RigettiQCSBackend, mocker: MockerFi
171171

172172

173173
def test_result(job: RigettiQCSJob):
174+
assert job._status == JobStatus.RUNNING
175+
assert job.status() == JobStatus.DONE, "Checking status did not wait for completion"
176+
assert job._status == JobStatus.DONE
177+
174178
result = job.result()
175179

176180
assert result.date == job.result().date, "Result not cached"
177181

178-
assert job.status() == JobStatus.DONE
179-
180182
assert result.backend_name == "3q-qvm"
181183
assert result.job_id == job.job_id()
182184
assert result.success is True

0 commit comments

Comments
 (0)