tket icon indicating copy to clipboard operation
tket copied to clipboard

'MemoryCredentialStorage' object has no attribute '_save_login_credential'

Open balewski opened this issue 2 years ago • 1 comments

Hi, I'm using Quantinuum user name & password to activate api = QuantinuumAPI(token_store = cred_storage). It stopped working recently. Can you tell me how to change the code below so it works again? Thanks Jan

api=activate_qtuum_api()
backend = QuantinuumBackend(device_name='H1-1E', api_handler=api)

#...!...!....................
def activate_qtuum_api():
    from pytket.extensions.quantinuum.backends.credential_storage import  MemoryCredentialStorage
    from pytket.extensions.quantinuum.backends.api_wrappers import QuantinuumAPI
    import os

    MY_QTUUM_NAME=os.environ.get('MY_QTUUM_NAME')
    MY_QTUUM_PASS=os.environ.get('MY_QTUUM_PASS')
    print('credentials MY_QTUUM_NAME=',MY_QTUUM_NAME)
    cred_storage = MemoryCredentialStorage()
    cred_storage._save_login_credential(user_name=MY_QTUUM_NAME, password=MY_QTUUM_PASS)
    api = QuantinuumAPI(token_store = cred_storage)
    return api

My software

core@78b07dfc0a79:~/toolbox$ pip3 list |grep tket  
pytket                    1.22.0
pytket-qiskit             0.46.0
pytket-quantinuum         0.26.0
core@78b07dfc0a79:~/toolbox$ pip3 list |grep qiskit
pytket-qiskit             0.46.0
qiskit                    0.45.1
qiskit-aer                0.13.3
qiskit-algorithms         0.2.1
qiskit-dynamics           0.4.2
qiskit-experiments        0.5.4
qiskit-ibm-experiment     0.3.5
qiskit-ibm-provider       0.7.2
qiskit-ibm-runtime        0.17.0
qiskit-ionq               0.4.7
qiskit-qasm3-import       0.4.1
qiskit-terra              0.45.1

Python 3.10.12
>>> import jwt
>>> jwt.__version__
'2.8.0'

balewski avatar Feb 15 '24 17:02 balewski

Hi Jan, sorry for the late response. We removed that function in a previous release. The following change should make your code work:

cred_storage = MemoryCredentialStorage()
cred_storage._user_name = MY_QTUUM_NAME
cred_storage._password = MY_QTUUM_PASS

However, this workaround might not be stable and is subject to change in the future. I think it might be worth having a stable alternative to _save_login_credential.

yao-cqc avatar Mar 06 '24 09:03 yao-cqc

Closed because the proposed workaround should work. Also worth mentioning that one should consider using QuantinuumConfigCredentialStorage for more persistent credential storage. More detailed documentation will be available with the next pytket-quantinuum release.

yao-cqc avatar May 14 '24 20:05 yao-cqc