Skip to content

Commit

Permalink
Add try/except when creating backend obj (#2048)
Browse files Browse the repository at this point in the history
* Add try/except when creating backend obj

* test pydantic version

* Revert "test pydantic version"

This reverts commit c882317.

* add release note

---------

Co-authored-by: ptristan3 <[email protected]>
  • Loading branch information
kt474 and ptristan3 authored Dec 5, 2024
1 parent 62735e3 commit 5933153
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
16 changes: 11 additions & 5 deletions qiskit_ibm_runtime/qiskit_runtime_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -570,11 +570,17 @@ def _create_backend_obj(
Raises:
QiskitBackendNotFoundError: if the backend is not in the hgp passed in.
"""
if config := configuration_from_server_data(
raw_config=self._api_client.backend_configuration(backend_name),
instance=instance,
use_fractional_gates=use_fractional_gates,
):
try:
config = configuration_from_server_data(
raw_config=self._api_client.backend_configuration(backend_name),
instance=instance,
use_fractional_gates=use_fractional_gates,
)
except Exception as ex: # pylint: disable=broad-except
logger.warning("Unable to create retrieve configuration for %s. %s ", backend_name, ex)
return None

if config:
if self._channel == "ibm_quantum":
if not instance:
for hgp in list(self._hgps.values()):
Expand Down
2 changes: 2 additions & 0 deletions release-notes/unreleased/2048.bug.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Invalid or non-existing backend configurations on the server will no longer
prevent all backends from being retrieved with ``service.backends()``.

0 comments on commit 5933153

Please sign in to comment.