Skip to content

Commit

Permalink
Fix: Compatibility with Qiskit's run_circuits and CircuitSampler
Browse files Browse the repository at this point in the history
…utilities. (#19)
  • Loading branch information
dbanty authored Aug 25, 2021
1 parent 3541cad commit f4ca04a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
9 changes: 8 additions & 1 deletion qiskit_rigetti/_qcs_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,14 @@ def cancel(self) -> None:
raise NotImplementedError("Cancelling jobs is not supported")

def status(self) -> JobStatus:
"""Get the current status of this Job"""
"""Get the current status of this Job
If this job was RUNNING when you called it, this function will block until the job is complete.
"""

if self._status == JobStatus.RUNNING:
# Wait for results _now_ to finish running, otherwise consuming code might wait forever.
self.result()

return self._status

Expand Down
1 change: 0 additions & 1 deletion tests/test_qcs_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ def test_run(backend: RigettiQCSBackend):
job = execute(circuit, backend, shots=10)

assert job.backend() is backend
assert job.status() == JobStatus.RUNNING
result = job.result()
assert job.status() == JobStatus.DONE
assert result.backend_name == backend.configuration().backend_name
Expand Down
6 changes: 4 additions & 2 deletions tests/test_qcs_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,14 @@ def test_init__circuit_with_barrier(backend: RigettiQCSBackend, mocker: MockerFi


def test_result(job: RigettiQCSJob):
assert job._status == JobStatus.RUNNING
assert job.status() == JobStatus.DONE, "Checking status did not wait for completion"
assert job._status == JobStatus.DONE

result = job.result()

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

assert job.status() == JobStatus.DONE

assert result.backend_name == "3q-qvm"
assert result.job_id == job.job_id()
assert result.success is True
Expand Down

0 comments on commit f4ca04a

Please sign in to comment.