-
Notifications
You must be signed in to change notification settings - Fork 184
Fix account instance logic #2359
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
Conversation
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.
can confirm that after applying this patch I can create sessions again -- thanks for the quick fix !!
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 a lot for the fix, it LGTM and the tests look reasonable. I just found a couple of tiny tipos in the comments/reno.
Co-authored-by: Elena Peña Tapia <57907331+ElePT@users.noreply.github.com>
Co-authored-by: Elena Peña Tapia <57907331+ElePT@users.noreply.github.com>
* Fix least_busy edge cases * add release note * add test * update test * update test and reno * Update release-notes/unreleased/2359.bug.rst Co-authored-by: Elena Peña Tapia <57907331+ElePT@users.noreply.github.com> * Update test/integration/test_backend.py Co-authored-by: Elena Peña Tapia <57907331+ElePT@users.noreply.github.com> --------- Co-authored-by: Elena Peña Tapia <57907331+ElePT@users.noreply.github.com>
Summary
Currently on
0.41.0
, if there is a default saved instance, retrieving a backend and then attempting to create a session/batch will result in a "No API client found" error. In #2296, we added "instance" as a parameter when creating a backend. This made it so when creating a session,_get_api_client
would look in the saved api clients which would be empty, instead of using_active_api_client
. This only worked before because we weren't passing an instance to_get_api_client
so the current active client was used.qiskit-ibm-runtime/qiskit_ibm_runtime/qiskit_runtime_service.py
Lines 179 to 187 in 80837df
This code here is the main culprit:
The first issue is that if an instance name is passed in at initialization, the name instead of the crn will be the object key in
self._api_clients
which causes errors later because_get_api_client
won't be able to find a client.This logic is also flawed when an instance (name or crn) is saved in a account -
_get_or_create_cloud_client()
only adds the client toself._api_clients
if the instance does not match the current active client instance. Sinceself._active_api_client
is initialized a couple lines above (with the saved account instance),self._api_clients
will remain empty which then also results in the no API client error.I also realized that in the case where there are no instances and the service looks at all instances available,
least_busy()
was only using the current active instance. Theinstance
parameter also would not have worked correctly.Details and comments
Fixes #2358