Deprecate auth parameter and add new channel parameter#226
Conversation
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
217b3eb to
b6d1f80
Compare
Pull Request Test Coverage Report for Build 2042278316Warning: 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 |
… with named channel accounts
daka1510
left a comment
There was a problem hiding this comment.
@rathishcholarajan carefully reviewed the changes and left a few comments. Let me know if you disagree or anything is unclear.
Co-authored-by: Daniel Kaulen <kaulen.daniel@gmail.com>
daka1510
left a comment
There was a problem hiding this comment.
LGTM - Thanks!! I find the new terminology much clearer.
| def migrate(cls) -> None: | ||
| """Migrate accounts on disk by removing `auth` and adding `channel`.""" | ||
| data = read_config(filename=_DEFAULT_ACCOUNT_CONFIG_JSON_FILE) | ||
| for key, value in data.items(): | ||
| if key == _DEFAULT_ACCOUNT_NAME_CLOUD: | ||
| value.pop("auth", None) | ||
| value.update(channel="ibm_cloud") | ||
| delete_config(filename=_DEFAULT_ACCOUNT_CONFIG_JSON_FILE, name=key) | ||
| save_config( | ||
| filename=_DEFAULT_ACCOUNT_CONFIG_JSON_FILE, | ||
| name=_DEFAULT_ACCOUNT_NAME_IBM_CLOUD, | ||
| config=value, | ||
| overwrite=False, | ||
| ) | ||
| elif key == _DEFAULT_ACCOUNT_NAME_LEGACY: | ||
| value.pop("auth", None) | ||
| value.update(channel="ibm_quantum") | ||
| delete_config(filename=_DEFAULT_ACCOUNT_CONFIG_JSON_FILE, name=key) | ||
| save_config( | ||
| filename=_DEFAULT_ACCOUNT_CONFIG_JSON_FILE, | ||
| name=_DEFAULT_ACCOUNT_NAME_IBM_QUANTUM, | ||
| config=value, | ||
| overwrite=False, | ||
| ) | ||
| else: | ||
| if hasattr(value, "auth"): | ||
| if value["auth"] == "cloud": | ||
| value.update(channel="ibm_cloud") | ||
| elif value["auth"] == "legacy": | ||
| value.update(channel="ibm_quantum") | ||
| value.pop("auth", None) | ||
| save_config( | ||
| filename=_DEFAULT_ACCOUNT_CONFIG_JSON_FILE, | ||
| name=key, | ||
| config=value, | ||
| overwrite=True, | ||
| ) |
There was a problem hiding this comment.
I find this a lot easier to understand than the previous approach, thanks for updating the PR accordingly!
Instead of persisting the changes for every stored account, we could also make all updates in-memory and overwrite the file with a single write operation. Given that this is temporary migration code and I don't expect users to have hundreds of account I'm personally fine with this. I don't think we have to optimize at this level of detail.
|
No objections from my side if the CI checks pass... |
* Add error handling of separate cregs * do not raise an error unless error mitigation is enabled * always check unused classical bits * revert a test name * avoid applying correction to classical bits not used for measurements * update an error messgage * isort * Update test/unit/test_sampler.py Co-authored-by: Mariana Bernagozzi <Mariana.Bernagozzi@ibm.com> * add MidcircuitMeasurementError Co-authored-by: Rathish Cholarajan <Rathish.C@ibm.com> Co-authored-by: JESSIE YU <jessieyu@us.ibm.com> Co-authored-by: Mariana Bernagozzi <Mariana.Bernagozzi@ibm.com>
Summary
Deprecate existing
authparameter to IBMRuntimeService and introduce newchannelparameter to better accommodate the different channels that may be available in the future.channel="ibm_quantum"
channel="ibm_cloud"
Details and comments
Fixes #217
TODO
channelparameter and replaceautheverywhere withchannelto makechannelwork (authgets broken at the end of this step)authparameter and fix code now to makeauthalso to work alongsidechannelsave_account)delete_account)saved_accounts)__init__)ibm-quantum-production,ibm-quantum-staging,ibm-cloud-productionandibm-cloud-staging.channeltests and make them work usingauthflowauthparameter and the tests related to it will be removed in a later release as per Qiskit deprecation policy.