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 ProviderV2 a second version of Provider abstract class #5629

Closed
wants to merge 1 commit into from

Conversation

mtreinish
Copy link
Member

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

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
@mtreinish mtreinish added the Changelog: New Feature Include in the "Added" section of the changelog label Jan 14, 2021
@mtreinish mtreinish added this to the 0.17 milestone Jan 14, 2021
"""Base class for a Backend Provider."""
version = 2

def get_backend(self, name=None, **kwargs):
Copy link
Contributor

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):
Copy link
Contributor

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)
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: New Feature Include in the "Added" section of the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants