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 provider compatibility to the runtime service #419

Merged
merged 5 commits into from
Aug 9, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion qiskit_ibm_runtime/qiskit_runtime_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from typing import Dict, Callable, Optional, Union, List, Any, Type

from qiskit.providers.backend import BackendV1 as Backend
from qiskit.providers.provider import ProviderV1 as Provider
from qiskit.providers.exceptions import QiskitBackendNotFoundError
from qiskit.providers.providerutils import filter_backends

Expand Down Expand Up @@ -55,7 +56,7 @@
SERVICE_NAME = "runtime"


class QiskitRuntimeService:
class QiskitRuntimeService(Provider):
"""Class for interacting with the Qiskit Runtime service.

Qiskit Runtime is a new architecture offered by IBM Quantum that
Expand Down Expand Up @@ -488,6 +489,7 @@ def _discover_backends(self) -> None:
backend_name += "_"
setattr(self, backend_name, backend)

# pylint: disable=arguments-differ
def backends(
self,
name: Optional[str] = None,
Expand Down Expand Up @@ -685,6 +687,9 @@ def backend(
raise QiskitBackendNotFoundError("No backend matches the criteria")
return backends[0]

def get_backend(self, name: str = None, **kwargs: Any) -> Backend:
return self.backend(name, **kwargs)

def pprint_programs(
self,
refresh: bool = False,
Expand Down Expand Up @@ -1438,5 +1443,14 @@ def channel(self) -> str:
"""
return self._channel

@property
def runtime(self): # type:ignore
"""Return self for compatibility with IBMQ provider.

Returns:
self
"""
return self

def __repr__(self) -> str:
return "<{}>".format(self.__class__.__name__)