diff --git a/README.md b/README.md index 4bc71ed17..f2a5f14d9 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ pip install qiskit-ibm-runtime print(service.backends()) # get IBM's simulator backend - simulator_backend = service.get_backend('ibmq_qasm_simulator') + simulator_backend = service.backend('ibmq_qasm_simulator') ``` ### Load Account from Environment Variables diff --git a/qiskit_ibm_runtime/hub_group_project.py b/qiskit_ibm_runtime/hub_group_project.py index 08dcc561c..0cf12e209 100644 --- a/qiskit_ibm_runtime/hub_group_project.py +++ b/qiskit_ibm_runtime/hub_group_project.py @@ -90,7 +90,7 @@ def _discover_remote_backends(self) -> Dict[str, "ibm_backend.IBMBackend"]: ) return ret - def get_backend(self, name: str) -> Optional["ibm_backend.IBMBackend"]: + def backend(self, name: str) -> Optional["ibm_backend.IBMBackend"]: """Get backend by name.""" return self._backends.get(name, None) diff --git a/qiskit_ibm_runtime/ibm_runtime_service.py b/qiskit_ibm_runtime/ibm_runtime_service.py index 73bc8c055..0300098a7 100644 --- a/qiskit_ibm_runtime/ibm_runtime_service.py +++ b/qiskit_ibm_runtime/ibm_runtime_service.py @@ -430,7 +430,7 @@ def _get_hgp( f"Hub/group/project {instance} " "could not be found for this account." ) - if backend_name and not self._hgps[instance].get_backend(backend_name): + if backend_name and not self._hgps[instance].backend(backend_name): raise QiskitBackendNotFoundError( f"Backend {backend_name} cannot be found in " f"hub/group/project {instance}" @@ -441,7 +441,7 @@ def _get_hgp( return list(self._hgps.values())[0] for hgp in self._hgps.values(): - if hgp.get_backend(backend_name): + if hgp.backend(backend_name): return hgp raise QiskitBackendNotFoundError( @@ -590,7 +590,7 @@ def saved_accounts( ), ) - def get_backend( + def backend( self, name: str = None, instance: Optional[str] = None, @@ -810,12 +810,12 @@ def run( ) # Find the right hgp hgp = self._get_hgp(instance=instance, backend_name=backend_name) - backend = hgp.get_backend(backend_name) + backend = hgp.backend(backend_name) hgp_name = hgp.name else: # TODO Support instance for cloud # TODO Support optional backend name when fully supported by server - backend = self.get_backend(backend_name) + backend = self.backend(backend_name) result_decoder = result_decoder or ResultDecoder try: @@ -1216,7 +1216,7 @@ def _decode_job(self, raw_data: Dict) -> RuntimeJob: ) # Try to find the right backend try: - backend = self.get_backend(raw_data["backend"], instance=instance) + backend = self.backend(raw_data["backend"], instance=instance) except (IBMProviderError, QiskitBackendNotFoundError): backend = ibm_backend.IBMRetiredBackend.from_name( backend_name=raw_data["backend"], diff --git a/qiskit_ibm_runtime/jupyter/__init__.py b/qiskit_ibm_runtime/jupyter/__init__.py index b69082948..3c74fbc0b 100644 --- a/qiskit_ibm_runtime/jupyter/__init__.py +++ b/qiskit_ibm_runtime/jupyter/__init__.py @@ -42,7 +42,7 @@ import qiskit_ibm_runtime.jupyter service = IBMRuntimeService() - backend = service.get_backend('ibmq_vigo') + backend = service.backend('ibmq_vigo') .. jupyter-execute:: :hide-code: diff --git a/qiskit_ibm_runtime/test/ibm_provider_mock.py b/qiskit_ibm_runtime/test/ibm_provider_mock.py index ff6a3f863..14882a6cd 100644 --- a/qiskit_ibm_runtime/test/ibm_provider_mock.py +++ b/qiskit_ibm_runtime/test/ibm_provider_mock.py @@ -37,6 +37,6 @@ def mock_get_backend(backend): "The specified backend name is not a valid mock from qiskit.test.mock" ) fake_backend = getattr(backend_mocks, backend)() - mock_ibm_provider.get_backend.return_value = fake_backend + mock_ibm_provider.backend.return_value = fake_backend mock_ibm_provider.return_value = mock_ibm_provider qiskit_ibm_runtime.IBMRuntimeService = mock_ibm_provider diff --git a/qiskit_ibm_runtime/visualization/interactive/error_map.py b/qiskit_ibm_runtime/visualization/interactive/error_map.py index 4ca042056..5652dffbb 100644 --- a/qiskit_ibm_runtime/visualization/interactive/error_map.py +++ b/qiskit_ibm_runtime/visualization/interactive/error_map.py @@ -69,7 +69,7 @@ def iplot_error_map( from qiskit_ibm_runtime.visualization import iplot_error_map service = IBMRuntimeService() - backend = service.get_backend('ibmq_vigo') + backend = service.backend('ibmq_vigo') iplot_error_map(backend, as_widget=True) """ diff --git a/qiskit_ibm_runtime/visualization/interactive/gate_map.py b/qiskit_ibm_runtime/visualization/interactive/gate_map.py index 5561f6706..68c063a0c 100644 --- a/qiskit_ibm_runtime/visualization/interactive/gate_map.py +++ b/qiskit_ibm_runtime/visualization/interactive/gate_map.py @@ -73,7 +73,7 @@ def iplot_gate_map( from qiskit_ibm_runtime.visualization import iplot_gate_map service = IBMRuntimeService() - backend = service.get_backend('ibmq_vigo') + backend = service.backend('ibmq_vigo') iplot_gate_map(backend, as_widget=True) """ diff --git a/releasenotes/archive/0.12/backend-run-circuits-ad446ca9b56209b9.yaml b/releasenotes/archive/0.12/backend-run-circuits-ad446ca9b56209b9.yaml index c06a2e251..b76da4883 100644 --- a/releasenotes/archive/0.12/backend-run-circuits-ad446ca9b56209b9.yaml +++ b/releasenotes/archive/0.12/backend-run-circuits-ad446ca9b56209b9.yaml @@ -26,7 +26,7 @@ features: from qiskit.test.reference_circuits import ReferenceCircuits provider = IBMQ.load_account() - backend = provider.get_backend('ibmq_vigo') + backend = provider.backend('ibmq_vigo') circuits = transpile(ReferenceCircuits.bell(), backend=backend) default_shots = backend.options.shots # Returns the backend default of 1024 shots. backend.set_options(shots=2048) # All jobs will now have use 2048 shots. diff --git a/test/test_backend_retrieval.py b/test/test_backend_retrieval.py index 29f03bba4..26e9282ce 100644 --- a/test/test_backend_retrieval.py +++ b/test/test_backend_retrieval.py @@ -200,35 +200,35 @@ class TestGetBackend(IBMTestCase): def test_get_common_backend(self): """Test getting a backend that is in default and non-default hgp.""" service = FakeRuntimeService(auth="legacy", token="my_token") - backend = service.get_backend(FakeRuntimeService.DEFAULT_COMMON_BACKEND) + backend = service.backend(FakeRuntimeService.DEFAULT_COMMON_BACKEND) self.assertEqual(backend._api_client.hgp, list(service._hgps.keys())[0]) def test_get_unique_backend_default_hgp(self): """Test getting a backend in the default hgp.""" service = FakeRuntimeService(auth="legacy", token="my_token") backend_name = FakeRuntimeService.DEFAULT_UNIQUE_BACKEND_PREFIX + "0" - backend = service.get_backend(backend_name) + backend = service.backend(backend_name) self.assertEqual(backend._api_client.hgp, list(service._hgps.keys())[0]) def test_get_unique_backend_non_default_hgp(self): """Test getting a backend in the non default hgp.""" service = FakeRuntimeService(auth="legacy", token="my_token") backend_name = FakeRuntimeService.DEFAULT_UNIQUE_BACKEND_PREFIX + "1" - backend = service.get_backend(backend_name) + backend = service.backend(backend_name) self.assertEqual(backend._api_client.hgp, list(service._hgps.keys())[1]) def test_get_phantom_backend(self): """Test getting a phantom backend.""" service = FakeRuntimeService(auth="legacy", token="my_token") with self.assertRaises(QiskitBackendNotFoundError): - service.get_backend("phantom") + service.backend("phantom") def test_get_backend_by_hgp(self): """Test getting a backend by hgp.""" hgp = FakeRuntimeService.DEFAULT_HGPS[1] backend_name = FakeRuntimeService.DEFAULT_COMMON_BACKEND service = FakeRuntimeService(auth="legacy", token="my_token") - backend = service.get_backend(backend_name, instance=hgp) + backend = service.backend(backend_name, instance=hgp) self.assertEqual(backend._api_client.hgp, hgp) def test_get_backend_by_bad_hgp(self): @@ -237,4 +237,4 @@ def test_get_backend_by_bad_hgp(self): backend_name = FakeRuntimeService.DEFAULT_UNIQUE_BACKEND_PREFIX + "0" service = FakeRuntimeService(auth="legacy", token="my_token") with self.assertRaises(QiskitBackendNotFoundError): - _ = service.get_backend(backend_name, instance=hgp) + _ = service.backend(backend_name, instance=hgp) diff --git a/test/test_integration_backend.py b/test/test_integration_backend.py index adc6bacf9..4ae24451d 100644 --- a/test/test_integration_backend.py +++ b/test/test_integration_backend.py @@ -49,7 +49,7 @@ def test_backends(self, service): def test_get_backend(self, service): """Test getting a backend.""" backends = service.backends() - backend = service.get_backend(backends[0].name()) + backend = service.backend(backends[0].name()) self.assertTrue(backend)