From f847c86841f8d1f69423e83d9d429508daece672 Mon Sep 17 00:00:00 2001 From: Rathish Cholarajan Date: Fri, 10 Dec 2021 01:24:01 -0500 Subject: [PATCH 1/2] Add backend related functions in RuntimeClient --- qiskit_ibm_runtime/api/clients/runtime.py | 59 ++++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) diff --git a/qiskit_ibm_runtime/api/clients/runtime.py b/qiskit_ibm_runtime/api/clients/runtime.py index e99e31c00..0c06fd887 100644 --- a/qiskit_ibm_runtime/api/clients/runtime.py +++ b/qiskit_ibm_runtime/api/clients/runtime.py @@ -13,7 +13,7 @@ """Client for accessing IBM Quantum runtime service.""" import logging -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional from qiskit_ibm_runtime.credentials import Credentials from qiskit_ibm_runtime.api.session import RetrySession @@ -278,3 +278,60 @@ def job_logs(self, job_id: str) -> str: def logout(self) -> None: """Clear authorization cache.""" self.api.logout() + + # IBM Cloud only functions + + def list_backends(self, timeout: Optional[float] = None) -> List[Dict[str, Any]]: + """Return IBM Cloud backends available for this service instance. + + Args: + timeout: Number of seconds to wait for the request. + + Returns: + IBM Cloud backends available for this service instance. + """ + return self.api.backends(timeout=timeout) + + def backend_configuration(self, backend_name: str) -> Dict[str, Any]: + """Return the configuration of the IBM Cloud backend. + + Args: + backend_name: The name of the IBM Cloud backend. + + Returns: + Backend configuration. + """ + return self.api.backend(backend_name).configuration() + + def backend_status(self, backend_name: str) -> Dict[str, Any]: + """Return the status of the IBM Cloud backend. + + Args: + backend_name: The name of the IBM Cloud backend. + + Returns: + Backend status. + """ + return self.api.backend(backend_name).status() + + def backend_properties(self, backend_name: str) -> Dict[str, Any]: + """Return the properties of the IBM Cloud backend. + + Args: + backend_name: The name of the IBM Cloud backend. + + Returns: + Backend properties. + """ + return self.api.backend(backend_name).properties() + + def backend_pulse_defaults(self, backend_name: str) -> Dict: + """Return the pulse defaults of the IBM Cloud backend. + + Args: + backend_name: The name of the IBM Cloud backend. + + Returns: + Backend pulse defaults. + """ + return self.api.backend(backend_name).pulse_defaults() From 7fe4a93fcb9299be2cde7485651a98208a209f76 Mon Sep 17 00:00:00 2001 From: Rathish Cholarajan Date: Fri, 10 Dec 2021 12:10:17 -0500 Subject: [PATCH 2/2] Removing timeout since no longer needed The new API just returns the string of backends and not all the configuration at once, so we don't need to provide user with the option to specify a custom timeout since the get backends call won't take too long for IBM Cloud --- qiskit_ibm_runtime/api/clients/runtime.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/qiskit_ibm_runtime/api/clients/runtime.py b/qiskit_ibm_runtime/api/clients/runtime.py index 0c06fd887..b837d9858 100644 --- a/qiskit_ibm_runtime/api/clients/runtime.py +++ b/qiskit_ibm_runtime/api/clients/runtime.py @@ -281,16 +281,13 @@ def logout(self) -> None: # IBM Cloud only functions - def list_backends(self, timeout: Optional[float] = None) -> List[Dict[str, Any]]: + def list_backends(self) -> List[Dict[str, Any]]: """Return IBM Cloud backends available for this service instance. - Args: - timeout: Number of seconds to wait for the request. - Returns: IBM Cloud backends available for this service instance. """ - return self.api.backends(timeout=timeout) + return self.api.backends() def backend_configuration(self, backend_name: str) -> Dict[str, Any]: """Return the configuration of the IBM Cloud backend.