-
Notifications
You must be signed in to change notification settings - Fork 69
Conversation
Pull Request Test Coverage Report for Build 2335772639
💛 - Coveralls |
qiskit_ibm_provider/ibm_provider.py
Outdated
@@ -416,6 +416,9 @@ def active_account(self) -> Optional[Dict[str, str]]: | |||
Returns: | |||
A dictionary with information about the account currently in the session. | |||
""" | |||
if not self._account.instance: | |||
hgp = self._get_hgp() | |||
self._account.instance = f"{hgp._hub}/{hgp._group}/{hgp._project}" |
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.
self._account.instance
is never updated, even after a job is run - if a user wants to see the default hgp by calling active_account()
we can use _get_hgp()
which returns the default hgp
This doesn't seem like the cleanest solution but I couldn't find a better way
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.
First hgp in the list of hgps will always be the one that is selected by default.
We need to always return this no matter what is already in self._account.
So something like below should work, please test it:
hgps = self._get_hgps()
active_account_dict = self._account.to_saved_format()
active_account_dict.update({ "instance": hgps[0].name })
return active_account_dict
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.
Tested, works as intended
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.
@kt474 Could you please write some tests to see if the h/g/p set as instance
when saving account and initialzing IBMProvider or when initializing IBMProvider with instance
parameter is what is set as instance
value when calling active_account?
Test is failing here but passing locally - looking into it |
hgp = self.provider._get_hgp() | ||
IBMProvider.save_account( | ||
token=self.dependencies.token, instance=hgp.name, overwrite=True | ||
) |
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.
It would better not to save account on CI. Using something like a temporary account config file might help like here https://github.com/Qiskit/qiskit-ibm-provider/blob/main/test/unit/test_account.py#L174
test/unit/test_account.py
Outdated
token = uuid.uuid4().hex | ||
instance = "test-hub/test-group/test-project" | ||
with temporary_account_config_file(name=name, token=token, instance=instance): | ||
service = FakeProvider(name=name) |
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.
Here we are testing FakeProvider whereas we should be actually testing IBMProvider.
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.
LGTM!
Summary
Fixes #348
Details and comments