Skip to content
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

Broken installation (both via PyPi and GitHub) #27

Open
vprusso opened this issue May 16, 2023 · 13 comments · May be fixed by #29
Open

Broken installation (both via PyPi and GitHub) #27

vprusso opened this issue May 16, 2023 · 13 comments · May be fixed by #29
Labels
bug Something isn't working

Comments

@vprusso
Copy link

vprusso commented May 16, 2023

I'm reopening #26 as I still believe this to not be completely resolved.

  • There still should be some update in the README file pertaining to using Honeywell over Quantinuum.
  • Using the Honeywell provider still does not work (more details below):

Regarding being able to use the package, I have a question about usage. I see that the .save_account method naturally points to the Honeywell page for user login. Naturally, I'd rather use the qapi.quantinuum.com/ URL instead. I see that one can configure this (in principle) in the proxies variable

    import os
    from qiskit.providers.honeywell import Honeywell
    USERNAME = os.environ.get("QUANTINUUM_USERNAME")
    PASSWORD = os.environ.get("QUANTINUUM_PASSWORD")
    Honeywell.save_account(USERNAME, 
                           proxies = { 'urls': {'http':
                           f'http://{USERNAME}:{PASSWORD}@qapi.quantinuum.com/',
                           'https':
                           f'http://{USERNAME}:{PASSWORD}@qapi.quantinuum.com/'
                           } })

    backends = Honeywell.backends()
    backend = Honeywell.get_backend(machine)

However, this seems to fail is appears to be pointing to the Honeywell login link despite the fact that (I thought) I was configuring it to login to a different URL. I'm most likely doing something wrong, but is it obvious what that might be? Thank you again for your help!

Here is the error output upon trying to call the associated save_account method:

/Users/vincent.russo/Library/Caches/pypoetry/virtualenvs/benchmark-Is--SOOG-py3.11/lib/python3.11/site-packages/qiskit/providers/honeywell/__init__.py:38: FutureWarning: This is the final release of qiskit-honeywell-provider. It will be replaced by the qiskit-quantinuum-provider package in the future.
  warnings.warn("This is the final release of qiskit-honeywell-provider. "
Enter your password: 
Traceback (most recent call last):
  File "/Users/vincent.russo/Projects/resarch/unitary_fund/metriq-api/benchmark/benchmark/QC-App-Oriented-Benchmarks/quantum-fourier-transform/qiskit/qft_benchmark.py", line 427, in <module>
    backends = Honeywell.backends()
               ^^^^^^^^^^^^^^^^^^^^
  File "/Users/vincent.russo/Library/Caches/pypoetry/virtualenvs/benchmark-Is--SOOG-py3.11/lib/python3.11/site-packages/qiskit/providers/honeywell/honeywellprovider.py", line 92, in backends
    if not self._api.has_token():
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/vincent.russo/Library/Caches/pypoetry/virtualenvs/benchmark-Is--SOOG-py3.11/lib/python3.11/site-packages/qiskit/providers/honeywell/api/honeywellclient.py", line 76, in has_token
    return bool(self.client_api.session.credentials.access_token)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/vincent.russo/Library/Caches/pypoetry/virtualenvs/benchmark-Is--SOOG-py3.11/lib/python3.11/site-packages/qiskit/providers/honeywell/api/session.py", line 96, in credentials
    self.update_auth()
  File "/Users/vincent.russo/Library/Caches/pypoetry/virtualenvs/benchmark-Is--SOOG-py3.11/lib/python3.11/site-packages/qiskit/providers/honeywell/api/session.py", line 89, in update_auth
    self.headers.update({'Authorization': self._credentials.access_token})
                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/vincent.russo/Library/Caches/pypoetry/virtualenvs/benchmark-Is--SOOG-py3.11/lib/python3.11/site-packages/qiskit/providers/honeywell/credentials/credentials.py", line 146, in access_token
    return self._login()
           ^^^^^^^^^^^^^
  File "/Users/vincent.russo/Library/Caches/pypoetry/virtualenvs/benchmark-Is--SOOG-py3.11/lib/python3.11/site-packages/qiskit/providers/honeywell/credentials/credentials.py", line 274, in _login
    self._authenticate()
  File "/Users/vincent.russo/Library/Caches/pypoetry/virtualenvs/benchmark-Is--SOOG-py3.11/lib/python3.11/site-packages/qiskit/providers/honeywell/credentials/credentials.py", line 205, in _authenticate
    status_code, message = self._request_tokens(body)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/vincent.russo/Library/Caches/pypoetry/virtualenvs/benchmark-Is--SOOG-py3.11/lib/python3.11/site-packages/qiskit/providers/honeywell/credentials/credentials.py", line 155, in _request_tokens
    response = sess.post(
               ^^^^^^^^^^
  File "/Users/vincent.russo/Library/Caches/pypoetry/virtualenvs/benchmark-Is--SOOG-py3.11/lib/python3.11/site-packages/requests/sessions.py", line 635, in post
    return self.request("POST", url, data=data, json=json, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/vincent.russo/Library/Caches/pypoetry/virtualenvs/benchmark-Is--SOOG-py3.11/lib/python3.11/site-packages/qiskit/providers/honeywell/api/session.py", line 170, in request
    raise RequestsApiError(ex, message) from None
qiskit.providers.honeywell.api.exceptions.RequestsApiError: HTTPSConnectionPool(host='qapi.honeywell.com', port=443): Max retries exceeded with url: /v1/login (Caused by ProxyError('Cannot connect to prox

fyi @1ucian0 @mtreinish @chris-theroux

@vprusso vprusso added the bug Something isn't working label May 16, 2023
@mtreinish
Copy link
Collaborator

I just merged #24 which changed some of the authentication bits, can you test with the current main branch and see if it's working. If it still doesn't work we'll need to get @chris-theroux or someone else at Quantinuum to take a look

@vprusso
Copy link
Author

vprusso commented May 29, 2023

Hi @mtreinish.

Thanks for taking a look at this. I gave this another go and it still seems to be giving some grief. It's possible I'm doing something silly, so allow me to explicitly write out what I am attempting to do:

  1. Since the project is not on the Pypi server, I am pip installing via Git:
pip install https://github.com/qiskit-community/qiskit-quantinuum-provider/archive/refs/heads/master.zip
  1. Once installed, I attempt to run the import command as specified in the README.md file. Namely:
from qiskit_quantinuum import Quantinuum

which fails with:

Traceback (most recent call last):
  File "/Users/vincent.russo/Projects/research/unitary_fund/metriq-api/benchmark/benchmark/QC-App-Oriented-Benchmarks/quantum-fourier-transform/qiskit/qft_benchmark.py", line 403, in <module>
    from qiskit_quantinuum import Quantinuum
ModuleNotFoundError: No module named 'qiskit_quantinuum'
  1. If I run with a pip list, I do indeed see the package installed:
>>> pip list

...
qiskit                     0.42.1
qiskit-aer                 0.12.0
qiskit-ibmq-provider       0.20.2
qiskit-quantinuum-provider 0.4.0
...
  1. Since the package name is qiskit-quantinuum-provider and not qiskit-quantinuum, I also tried doing:
from qiskit_quantinuum_provider import Quantinuum

which also fails.

Is it possible I am doing something incorrectly here?

@chris-theroux
Copy link
Collaborator

chris-theroux commented May 30, 2023

Hey @vprusso, taking a look at this. Will update soon

Update:
This should work:
from qiskit_quantinuum import Quantinuum
Ran into the same issue. Looking into why the import isn't working.

@mtreinish what do we need to do to get the package updated on pypi?

@vprusso
Copy link
Author

vprusso commented May 30, 2023

Hey @vprusso, taking a look at this. Will update soon

Update: This should work: from qiskit_quantinuum import Quantinuum Ran into the same issue. Looking into why the import isn't working.

@mtreinish what do we need to do to get the package updated on pypi?

For some reason GitHub doesn't notify me if a comment has been updated, so I just by luck saw that you updated this comment.

Regarding your update:

Update:
This should work:
from qiskit_quantinuum import Quantinuum
Ran into the same issue. Looking into why the import isn't working.

This still does not appear to work on my end. If you read the comment I made up above, I did indeed attempt this import pattern, but it fails.

Let me know if I can provide anything further that might be helpful in diagnosing this.

@chris-theroux
Copy link
Collaborator

Hey, sorry wasn't clear. I meant you had to correct import and it 'should' work but isn't.

@vprusso
Copy link
Author

vprusso commented May 30, 2023

Hey, sorry wasn't clear. I meant you had to correct import and it 'should' work but isn't.

Gotcha. We're on the same page then :)

Thanks for confirming, and do let me know if anything can be helpful from my end!

@chris-theroux
Copy link
Collaborator

Thanks for catching the issues!

I made a small fix that should hopefully clear up the import problem.
If it goes through I'll update here again.
#28

@vprusso
Copy link
Author

vprusso commented May 30, 2023

Thanks for catching the issues!

I made a small fix that should hopefully clear up the import problem. If it goes through I'll update here again. #28

Thanks for keeping me up-to-date! The fix you put in looks like a likely candidate for a fix. When it goes in, if you want to give me a ping, I'll give it a go! Thanks again, @chris-theroux

@1ucian0
Copy link

1ucian0 commented Jun 1, 2023

#28 merged. Please, reinstall from repository and let's check it.

@vprusso
Copy link
Author

vprusso commented Jun 2, 2023

Hi @1ucian0,

Thanks for following up on this.

Indeed, I can now confirm that I can install (via git):

pip install --upgrade https://github.com/qiskit-community/qiskit-quantinuum-provider/archive/refs/heads/master.zip

and then perform the import statement properly:

from qiskit_quantinuum import Quantinuum

I'm so close to being able to run something. Attempting to follow the README:

    import os
    from qiskit_quantinuum import Quantinuum
    from qiskit import *

    Quantinuum.save_account(os.environ.get("QUANTINUUM_USERNAME"))

    backends = Quantinuum.backends()
    backend = Quantinuum.get_backend("H1-2E")
    qc = QuantumCircuit(2, 2)
    qc.h(0)
    qc.cx(0, 1)
    qc.measure([0,1], [0,1])
    result = execute(qc, backend).result()
    print(result.get_counts(qc))

Most of this runs fine (I can import qiskit_quantinuum without issue, save my account, and log in with no problem).

However, the line:

print(result.get_counts(qc))

results in the following error:

Traceback (most recent call last):
  File "/Users/vincent.russo/Projects/research/unitary_fund/metriq-api/benchmark/benchmark/QC-App-Oriented-Benchmarks/quantum-fourier-transform/qiskit/qft_benchmark.py", line 416, in <module>
    print(result.get_counts(qc))
          ^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/qiskit/result/result.py", line 269, in get_counts
    exp = self._get_experiment(key)
          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/qiskit/result/result.py", line 380, in _get_experiment
    raise QiskitError('Data for experiment "%s" could not be found.' % key)
qiskit.exceptions.QiskitError: 'Data for experiment "circuit-119" could not be found.'

I imagine this is something that is most likely on the side of Quantinuum, but just putting here in case that's not right.

(Minor point):
If I may also suggest, it would be prudent I think to alter the README.md file to indicate that one still cannot install via pip from the PyPi server.

fyi @chris-theroux , @1ucian0

@nathanshammah
Copy link

nathanshammah commented Jun 2, 2023

According to this note in the docstrings of the result() method, maybe removing qc from get_counts() may get it to work?

        Notes:
            Currently when calling get_counts() on a result returned by a Quantinuum
            backend, since Quantinuum backends currently support only running one
            experiment per job, do not supply an argument to the get_counts() function.
            Doing so may raise an exception.

@vprusso can you have a try? Thanks all for the support, @1ucian0 @chris-theroux.

@vprusso
Copy link
Author

vprusso commented Jun 3, 2023

According to this note in the docstrings of the result() method, maybe removing qc from get_counts() may get it to work?

        Notes:
            Currently when calling get_counts() on a result returned by a Quantinuum
            backend, since Quantinuum backends currently support only running one
            experiment per job, do not supply an argument to the get_counts() function.
            Doing so may raise an exception.

@vprusso can you have a try? Thanks all for the support, @1ucian0 @chris-theroux.

Yes, that did the trick!

Thanks to @chris-theroux and @1ucian0 for all the back-and-forth and work on this. Thanks as well to @nathanshammah for catching that in the docstrings.

Before we close this issue out, might I make two minor suggestions (mostly for the benefit of any other users who might be planning on using this package):

I would suggest either:

  1. Updating the install line in the README to:
pip install https://github.com/qiskit-community/qiskit-quantinuum-provider/archive/refs/heads/master.zip

and removing the PyPi badge on the README or

  1. Putting the package up on the PyPi server so that the install line in the README is correct.

Granted, I think it's definitely worth putting on PyPi, so as an alternative, perhaps it's worthwhile to do that, but I'll leave that ball in your court as to what makes the most sense.

Additionally, I would make the following adaptation to the example in the README:

from qiskit import *
qc = QuantumCircuit(2, 2)
qc.h(0)
qc.cx(0, 1)
qc.measure([0,1], [0,1])
result = execute(qc, backend).result()
print(result.get_counts())

(Note that the qc object has been removed from the get_counts function.

Thanks again, @chris-theroux , @1ucian0 and @nathanshammah !

@chris-theroux
Copy link
Collaborator

I'll put up a fix to the README today.

We definitely want the project on pypi.
I'm not sure if I have the permissions to do a new release there.

@mtreinish can I handle this or do I need your help?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants