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

Remove remaining references to Provider classes #1491

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
11 changes: 5 additions & 6 deletions qiskit_experiments/framework/experiment_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@
# `TYPE_CHECKING` means that the import will never be resolved by an actual
# interpreter, only static analysis.
from . import BaseExperiment
from qiskit.providers import Provider

LOG = logging.getLogger(__name__)

Expand Down Expand Up @@ -173,7 +172,7 @@ def __init__(
experiment: Optional["BaseExperiment"] = None,
backend: Optional[Backend] = None,
service: Optional[IBMExperimentService] = None,
provider: Optional[Provider] = None,
provider=None,
parent_id: Optional[str] = None,
job_ids: Optional[List[str]] = None,
child_data: Optional[List[ExperimentData]] = None,
Expand Down Expand Up @@ -261,7 +260,7 @@ def __init__(
self._set_backend(backend, recursive=False)
self.provider = provider
if provider is None and backend is not None:
self.provider = backend.provider
self.provider = getattr(backend, "provider", None)
self._service = service
if self._service is None and self.provider is not None:
self._service = self.get_service_from_provider(self.provider)
Expand Down Expand Up @@ -675,7 +674,7 @@ def service(self, service: IBMExperimentService) -> None:
self._set_service(service)

@property
def provider(self) -> Optional[Provider]:
def provider(self) -> Any:
"""Return the backend provider.

Returns:
Expand All @@ -684,7 +683,7 @@ def provider(self) -> Optional[Provider]:
return self._provider

@provider.setter
def provider(self, provider: Provider) -> None:
def provider(self, provider: Any) -> None:
"""Set the provider to be used for obtaining job data

Args:
Expand Down Expand Up @@ -2369,7 +2368,7 @@ def load(
cls,
experiment_id: str,
service: Optional[IBMExperimentService] = None,
provider: Optional[Provider] = None,
provider: Any = None,
) -> "ExperimentData":
"""Load a saved experiment data from a database service.

Expand Down
22 changes: 19 additions & 3 deletions qiskit_experiments/test/fake_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"""Fake backend class for tests."""
import uuid
from qiskit.circuit.library import Measure
from qiskit.providers import ProviderV1
from qiskit.exceptions import QiskitError
from qiskit.providers.backend import BackendV2
from qiskit.providers.options import Options
from qiskit.transpiler import Target
Expand All @@ -23,13 +23,29 @@
from qiskit_experiments.test.utils import FakeJob


class FakeProvider(ProviderV1):
class FakeProvider:
"""Fake provider with no backends for testing"""

def backends(self, name=None, **kwargs):
def backends(self, name=None, **kwargs): # pylint: disable=unused-argument
"""List of available backends. Empty in this case"""
return []

def get_backend(self, name=None, **kwargs):
"""Return a single backend matching the specified filtering.

Args:
name (str): name of the backend.
**kwargs: dict used for filtering.

Returns:
Backend: a backend matching the filtering.

Raises:
QiskitError: if no backend could be found or more than one backend
matches the filtering criteria.
"""
raise QiskitError("No backend matches the criteria")


class FakeBackend(BackendV2):
"""
Expand Down
4 changes: 2 additions & 2 deletions qiskit_experiments/test/mock_iq_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from qiskit import QuantumCircuit
from qiskit.circuit.library import XGate, SXGate
from qiskit.result import Result
from qiskit.providers import BackendV2, Provider, convert_to_target
from qiskit.providers import BackendV2, convert_to_target
from qiskit.providers.fake_provider import FakeOpenPulse2Q
from qiskit.qobj.utils import MeasLevel

Expand All @@ -40,7 +40,7 @@ class FakeOpenPulse2QV2(BackendV2):

def __init__(
self,
provider: Provider = None,
provider=None,
name: str = None,
description: str = None,
online_date: datetime.datetime = None,
Expand Down
11 changes: 11 additions & 0 deletions releasenotes/notes/provider-removal-a132799ce755773f.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
fixes:
- |
All references to ``qiskit.providers.Provider`` have been removed the code
base. The provider base classes were deprecated in Qiskit 1.1 with planned
removal in Qiskit 2.0. Qiskit Experiments has some support code for working
with providers to retrieve job data, but it takes the provider object as
input. The only explicit references to the provider classes were in type
annotations and test support code under ``qiskit_experiments.test``. The
type annotations have been removed and the test code now uses its own class
without a parent.