From d0a1ab5b23fca2b82042c57be2dd63305cf2ff22 Mon Sep 17 00:00:00 2001 From: Kevin Tian Date: Thu, 7 Dec 2023 11:33:01 -0500 Subject: [PATCH 1/2] Revert "Don't block for the first job in a session (#1170)" This reverts commit f2e24e49829360af4381cb0ffc46f62e343054fa. --- qiskit_ibm_runtime/session.py | 6 +----- .../backend-blocking-job-70ebcf44855cbdfd.yaml | 8 -------- test/integration/test_session.py | 13 ------------- 3 files changed, 1 insertion(+), 26 deletions(-) delete mode 100644 releasenotes/notes/backend-blocking-job-70ebcf44855cbdfd.yaml diff --git a/qiskit_ibm_runtime/session.py b/qiskit_ibm_runtime/session.py index 52c2f9a38c..179b61886d 100644 --- a/qiskit_ibm_runtime/session.py +++ b/qiskit_ibm_runtime/session.py @@ -23,7 +23,6 @@ from .runtime_job import RuntimeJob from .utils.result_decoder import ResultDecoder from .ibm_backend import IBMBackend -from .exceptions import RuntimeJobTimeoutError from .utils.default_session import set_cm_session from .utils.deprecation import deprecate_arguments @@ -181,10 +180,7 @@ def run( self._setup_lock.release() if self._backend is None: - try: - self._backend = job.backend(0).name - except RuntimeJobTimeoutError: - self._backend = None + self._backend = job.backend().name return job diff --git a/releasenotes/notes/backend-blocking-job-70ebcf44855cbdfd.yaml b/releasenotes/notes/backend-blocking-job-70ebcf44855cbdfd.yaml deleted file mode 100644 index c9cf202fbc..0000000000 --- a/releasenotes/notes/backend-blocking-job-70ebcf44855cbdfd.yaml +++ /dev/null @@ -1,8 +0,0 @@ ---- -fixes: - - | - Fixed an issue where the first job in a cloud channel session without a backend passed - in would block other jobs from starting. This would happen because the first job would - attempt to retrieve the backend from the job which required the job to be in a - completed state. - diff --git a/test/integration/test_session.py b/test/integration/test_session.py index 4af012f8a6..b8c086a590 100644 --- a/test/integration/test_session.py +++ b/test/integration/test_session.py @@ -101,19 +101,6 @@ def test_session_from_id(self, service): job = sampler.run(ReferenceCircuits.bell(), shots=400) self.assertEqual(session_id, job.session_id) - @run_integration_test - def test_session_no_backend(self, service): - """Test session without passing in backend.""" - if self.dependencies.channel == "ibm_quantum": - self.skipTest("Not supported on ibm_quantum") - with Session(service) as session: - sampler = Sampler(session=session) - job1 = sampler.run(ReferenceCircuits.bell(), shots=400) - job2 = sampler.run(ReferenceCircuits.bell(), shots=400) - self.assertTrue(job1.backend()) - self.assertTrue(job2.backend()) - self.assertEqual(job1.backend().name, job2.backend().name) - class TestBackendRunInSession(IBMIntegrationTestCase): """Integration tests for Backend.run in Session.""" From 941abb38c7de0572b9ea17bebe1158e6e809728b Mon Sep 17 00:00:00 2001 From: kevin-tian Date: Thu, 7 Dec 2023 18:57:16 -0500 Subject: [PATCH 2/2] keep test --- test/integration/test_session.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/integration/test_session.py b/test/integration/test_session.py index b8c086a590..4af012f8a6 100644 --- a/test/integration/test_session.py +++ b/test/integration/test_session.py @@ -101,6 +101,19 @@ def test_session_from_id(self, service): job = sampler.run(ReferenceCircuits.bell(), shots=400) self.assertEqual(session_id, job.session_id) + @run_integration_test + def test_session_no_backend(self, service): + """Test session without passing in backend.""" + if self.dependencies.channel == "ibm_quantum": + self.skipTest("Not supported on ibm_quantum") + with Session(service) as session: + sampler = Sampler(session=session) + job1 = sampler.run(ReferenceCircuits.bell(), shots=400) + job2 = sampler.run(ReferenceCircuits.bell(), shots=400) + self.assertTrue(job1.backend()) + self.assertTrue(job2.backend()) + self.assertEqual(job1.backend().name, job2.backend().name) + class TestBackendRunInSession(IBMIntegrationTestCase): """Integration tests for Backend.run in Session."""