-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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 ProviderV2 a second version of Provider abstract class #5629
Conversation
This commit adds a new version of the abstract interface for the Provider class, ProviderV2, to the providers interface. The only change over the early ProviderV1 version of the interface is that the new class enables attribute access to the Provider.backends attribute. This also means that tab completion in jedi (or similar) environments will work. Otherwise it's completely identical to ProvidersV1 (except for the version) ProviderV1 is not deprecated yet, because we need to wait for at least 3 release and 6 months per the version support policy. [1] Since the two versions are fully compatible this isn't a large burden. [1] https://qiskit.org/documentation/apidoc/providers.html#version-support-policy
"""Base class for a Backend Provider.""" | ||
version = 2 | ||
|
||
def get_backend(self, name=None, **kwargs): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think Jay wants to move away from getters and setters - e.g. use provider.backned()
for a single backend and provider.backends()
for multiple.
|
||
@abstractmethod | ||
@property | ||
def backends(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on the docstring, shouldn't this be backend
(without the s
)? ibmq also just changed from provider.backends.<backend_name>
to provider.backend.<backend_name>
.
""" | ||
self._backends = backends | ||
for backend in backends: | ||
setattr(self, backend.name(), backend) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really a risk right now, but it's possible the backend name doesn't conform to Python identifier standard. ibmq has an to_python_identifier
function to deal with that. If a user is using autocomplete, they should hopefully still recognize My@Backend
is the same as my_backend
.
Summary
This commit adds a new version of the abstract interface for the
Provider class, ProviderV2, to the providers interface. The only change
over the early ProviderV1 version of the interface is that the new class
enables attribute access to the Provider.backends attribute. This also
means that tab completion in jedi (or similar) environments will work.
Otherwise it's completely identical to ProvidersV1 (except for the
version)
ProviderV1 is not deprecated yet, because we need to wait for at least 3
release and 6 months per the version support policy. [1] Since the two
versions are fully compatible this isn't a large burden.
Details and comments
[1] https://qiskit.org/documentation/apidoc/providers.html#version-support-policy