Skip to content

Add ProviderV2 a second version of Provider abstract class#5629

Closed
mtreinish wants to merge 1 commit into
Qiskit:mainfrom
mtreinish:providersv2-class
Closed

Add ProviderV2 a second version of Provider abstract class#5629
mtreinish wants to merge 1 commit into
Qiskit:mainfrom
mtreinish:providersv2-class

Conversation

@mtreinish
Copy link
Copy Markdown
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: Added Add an "Added" entry in the GitHub Release changelog. label Jan 14, 2021
@mtreinish mtreinish added this to the 0.17 milestone Jan 14, 2021
@mtreinish mtreinish requested review from a team, chriseclectic and jyu00 as code owners January 14, 2021 21:07
"""Base class for a Backend Provider."""
version = 2

def get_backend(self, name=None, **kwargs):
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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: Added Add an "Added" entry in the GitHub Release changelog.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants