Add ProviderV2 a second version of Provider abstract class#5629
Closed
mtreinish wants to merge 1 commit into
Closed
Add ProviderV2 a second version of Provider abstract class#5629mtreinish wants to merge 1 commit into
mtreinish wants to merge 1 commit into
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
jyu00
requested changes
Jan 15, 2021
| """Base class for a Backend Provider.""" | ||
| version = 2 | ||
|
|
||
| def get_backend(self, name=None, **kwargs): |
Contributor
There was a problem hiding this comment.
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): |
Contributor
There was a problem hiding this comment.
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) |
Contributor
There was a problem hiding this comment.
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.
This was referenced Mar 31, 2021
Closed
9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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