-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Extended the from_backend
method of InstructionDurations
to support both BackendV1
and BackendV2
#12941
Conversation
…rt `GenericBackendV2`
Thank you for opening a new pull request. Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient. While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone. One or more of the following people are relevant to this code:
|
Pull Request Test Coverage Report for Build 10428323140Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
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.
Thanks for the contribution! However I think there's a simpler way of solving this, see the comments below 🙂 Also, yes, this would need a releasenote (under fixes
) and a test (for which you could use the example from #12760)
@@ -62,7 +63,7 @@ def __str__(self): | |||
return string | |||
|
|||
@classmethod | |||
def from_backend(cls, backend: Backend): | |||
def from_backend(cls, backend: Backend | BackendV2): |
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.
Backend
includes BackendV2
so we don't need an extra type here 🙂
@@ -62,7 +63,7 @@ def __str__(self): | |||
return string | |||
|
|||
@classmethod | |||
def from_backend(cls, backend: Backend): | |||
def from_backend(cls, backend: Backend | BackendV2): |
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 we could just solve this as
def from_backend(cls, backend):
if isinstance(backend, BackendV2):
return backend.target.durations()
# old code goes here as it is
…d a test and a releasenote.
Hi @Cryoris, thanks for reviewing the PR. I have incorporated the changes that you requested. Let me know if I need to make any more edits. Thanks |
--- | ||
fixes: | ||
- | | ||
The `from_backend` method of :class:`.InstructionDurations` now allows extracting instruction durations from both `BackendV1` and `BackendV2`. |
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.
The `from_backend` method of :class:`.InstructionDurations` now allows extracting instruction durations from both `BackendV1` and `BackendV2`. | |
Fixed a bug where :meth:`.InstructionDurations.from_backend` did not work for :class:`.BackendV2` backends. | |
Fixed `#12760 <https://github.com/Qiskit/qiskit/issues/12760>`__. |
Hi @Cryoris, I have edited the releasenote as per your comment. |
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.
The fix looks good to me, and it looks like you applied all of @Cryoris's suggestions, thanks @shravanpatel30! We can probably backport it to 1.2 too, I'll add the stable backport label.
Hi @ElePT, I received an email that this pull request was removed from merge queue. Do I need to make any changes to this pull request? Thanks |
This was probably due to unrelated status check issues, I'll re-queue and keep an eye on the PR. No action needed @shravanpatel30 :) |
…rt both `BackendV1` and `BackendV2` (#12941) * Extended the `from_backend` method of `InstructionDurations` to support `GenericBackendV2` * Simplified the `from_backend` method to allow using `BackendV2`. Added a test and a releasenote. * Made changes to the releasenote. (cherry picked from commit 6107799)
…rt both `BackendV1` and `BackendV2` (#12941) (#13009) * Extended the `from_backend` method of `InstructionDurations` to support `GenericBackendV2` * Simplified the `from_backend` method to allow using `BackendV2`. Added a test and a releasenote. * Made changes to the releasenote. (cherry picked from commit 6107799) Co-authored-by: Shravan Patel <[email protected]>
Summary
This PR fixes #12760
I have extended the
from_backend
method ofInstructionDurations
so that it supports bothBackendV1
andBackendV2
(alsoGenericBackendV2
). To get the instruction durations from theBackendV2
, I have used the attributetarget
. Also, inGenericBackendV2
, the(duration, error)
fordelay
andreset
is set to(None, None)
and thisNone
value raises an error in theupdate()
method ofInstructionDurations
. So, I am skipping the instructions which haveNone
as the duration (let me know if this is not what we want).@1ucian0, please review this and let me know if this is acceptable. If you want I can also add tests and/or new release notes for the changes I have made.
Thanks
Details and comments