Skip to content

Commit

Permalink
Add backend related functions in RuntimeClient (#55)
Browse files Browse the repository at this point in the history
* Add backend related functions in RuntimeClient

* 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
  • Loading branch information
rathishcholarajan authored Dec 13, 2021
1 parent 6f1001f commit 89b9fdd
Showing 1 changed file with 55 additions and 1 deletion.
56 changes: 55 additions & 1 deletion qiskit_ibm_runtime/api/clients/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -278,3 +278,57 @@ 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) -> List[Dict[str, Any]]:
"""Return IBM Cloud backends available for this service instance.
Returns:
IBM Cloud backends available for this service instance.
"""
return self.api.backends()

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()

0 comments on commit 89b9fdd

Please sign in to comment.