Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add backend refresh() method #1955

Merged
merged 14 commits into from
Oct 24, 2024
12 changes: 12 additions & 0 deletions qiskit_ibm_runtime/ibm_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
from .utils.backend_decoder import (
defaults_from_server_data,
properties_from_server_data,
configuration_from_server_data,
)
from .utils.deprecation import issue_deprecation_msg
from .utils.options import QASM2Options, QASM3Options
Expand Down Expand Up @@ -357,6 +358,17 @@ def target_history(self, datetime: Optional[python_datetime] = None) -> Target:
self._convert_to_target(refresh=True)
return self._target

def refresh(self) -> None:
"""Retrieve the newest backend configuration and refresh the current backend target."""
if config := configuration_from_server_data(
raw_config=self._service._api_client.backend_configuration(self.name),
instance=self._instance,
):
self._configuration = config
self._get_properties(datetime=python_datetime.now())
self._get_defaults()
self._convert_to_target(refresh=True)

def properties(
self, refresh: bool = False, datetime: Optional[python_datetime] = None
) -> Optional[BackendProperties]:
Expand Down
2 changes: 2 additions & 0 deletions release-notes/unreleased/1955.feat.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Added a new method, ``backend.refresh()`` that refreshes the
current backend target with the latest updates from the server.