-
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
Fix hard-coded sleep in run_circuits #7793
Fix hard-coded sleep in run_circuits #7793
Conversation
Fixes Qiskit#7792 Since all the places where the `_safe_get_job_status` happen in a context where the intended wait/sleep time is available, we can add the argument with the value to remove the hard-coded 5 seconds.
4f68140
to
0b51020
Compare
Pull Request Test Coverage Report for Build 2078260187
💛 - 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 pushing this up. You need to run black to fix the lint failures tox -eblack
will do this for you. See: https://github.com/Qiskit/qiskit-terra/blob/main/CONTRIBUTING.md#style-and-lint for more details.
While I think having a quick test to cover setting the wait value is respected would be useful, but the QuantumInstance
code isn't that well tested (which is why there are a lot of bugs like this in my experience). So to do it you'd either have to play a lot of games with mock to force the run_circuits
code to do what you want to verify we're waiting the correct duration. Or just run a algorithm tweak the wait
value on the QuantumInstance
constructor and assume if the result is correct your wait parameter was respected. You would need to do this on aer
as a backend since the other available backend in ci from BasicAer
is not async and nothing will wait for it to return. So I think just manually testing that this works is probably sufficient in this case (mostly out of apathy).
As for documentation, a quick release note probably in the fixes
section would be good to just say that the QuantumInstance
used at the core of algorithms in qiskit.algorithms
now respects the wait parameter for sleeps while waiting for submitted jobs to return. The process for release notes is documented here: https://github.com/Qiskit/qiskit-terra/blob/main/CONTRIBUTING.md#release-notes
Shouldn't we also decrease the |
Because 5 seconds might still be a more sensible default if you are running the QuantumInstance from outside the Qiskit Runtime environment. In which case checking the job status is a different process that goes through an Internet API each time. In the Qiskit Runtime environment, that might be just checking a value in memory. |
@mtreinish thanks. added the reno note. |
@Cryoris thanks for the lint run 👍 |
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 tested it manually and it works, thanks @renier!
releasenotes/notes/fix-hard-coded-sleep-run-circuits-a1588164e61d5336.yaml
Outdated
Show resolved
Hide resolved
* Fix hard-coded sleep in run_circuits Fixes #7792 Since all the places where the `_safe_get_job_status` happen in a context where the intended wait/sleep time is available, we can add the argument with the value to remove the hard-coded 5 seconds. * run black * add reno fix note * grammar * revising note accuracy * Update releasenotes/notes/fix-hard-coded-sleep-run-circuits-a1588164e61d5336.yaml Co-authored-by: Julien Gacon <gaconju@gmail.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> (cherry picked from commit 51d1139)
* Fix hard-coded sleep in run_circuits Fixes #7792 Since all the places where the `_safe_get_job_status` happen in a context where the intended wait/sleep time is available, we can add the argument with the value to remove the hard-coded 5 seconds. * run black * add reno fix note * grammar * revising note accuracy * Update releasenotes/notes/fix-hard-coded-sleep-run-circuits-a1588164e61d5336.yaml Co-authored-by: Julien Gacon <gaconju@gmail.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> (cherry picked from commit 51d1139) Co-authored-by: Renier Morales <renier@users.noreply.github.com>
* Fix hard-coded sleep in run_circuits Fixes Qiskit/qiskit#7792 Since all the places where the `_safe_get_job_status` happen in a context where the intended wait/sleep time is available, we can add the argument with the value to remove the hard-coded 5 seconds. * run black * add reno fix note * grammar * revising note accuracy * Update releasenotes/notes/fix-hard-coded-sleep-run-circuits-a1588164e61d5336.yaml Co-authored-by: Julien Gacon <gaconju@gmail.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Summary
Fixes #7792
Since all the places where the
_safe_get_job_status
happen ina context where the intended wait/sleep time is available, we can
add the argument with the value to remove the hard-coded 5 seconds.
Details and comments
This is my first time with a PR in this area. Let me know about any doc udpates
and test updates I need to do.