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

Add a function in Mitiq that returns the versions of supported frontends as extracted from dev_requirements.txt #1478

Closed
andreamari opened this issue Sep 2, 2022 · 5 comments
Labels
feature-request A request for a feature, tool, or workflow in Mitiq. infrastructure For issues related to building, packaging, and continuous integration. non-quantum Requires no knowledge of quantum physics to fix / work on. priority/low A non-urgent issue to fix or idea to discuss.

Comments

@andreamari
Copy link
Member

Issue Description

This is a simplified version of the stale issue #1201.

The versions of frontends that are tested with Mitiq are those in dev_requirements.txt. Apart from Cirq which is in requirements.txt.

It would be helpful to have a function that returns those versions. E.g.

>>> mitiq.supported_frontend_versions()
["cirq~=1.0.0", "qiskit~=0.37.2", ...]

Important note: this is very tricky task since requirement files are present in the master branch but are not present in the "stable" Mitiq packages that are released on mypy.

Proposed Solution

A solution could be to:

  • Detect the version of Mitiq.
  • From this information, download from the GitHub repository (from internet) the corresponding dev_requirement.txt and requirement.txt file.
  • Extract the versions from the content of dev_requirement.txt and requirement.txt.

For the moment, I would not call the new function within mitiq.about() since, if there are problems (e.g. internet not working), the call to mitiq.about() would fail and this is not nice.

Drawbacks

This function requires an internet connection. This is not optimal but I don't see a valid alternative.

Details and code

A potential stub of code for getting the requirement files from internet is the following. But there could be much better ways.

import requests

try:
    url_rep = "https://raw.githubusercontent.com/unitaryfund/mitiq/"
    url_req = url_rep + "v" + mitiq_version + "/requirements.txt"
    url_dev_req = (
        url_rep + "v" + mitiq_version + "/dev_requirements.txt"
    )
    _requirements = requests.get(url_req).text
    _dev_requirements = requests.get(url_dev_req).text
except requests.exceptions.ConnectionError:
    raise FailedToGetMitiqRequirements()

if not _requirements or not _dev_requirements:
    raise FailedToGetMitiqRequirements()

if _requirements[:3] == "404" or _dev_requirements[3] == "404":
    raise FailedToGetMitiqRequirements()

@andreamari andreamari added infrastructure For issues related to building, packaging, and continuous integration. non-quantum Requires no knowledge of quantum physics to fix / work on. priority/low A non-urgent issue to fix or idea to discuss. feature-request A request for a feature, tool, or workflow in Mitiq. labels Sep 2, 2022
@rmlarose
Copy link
Contributor

Isn't this just mitiq.SUPPORTED_PROGRAM_TYPES? How much value does version information really add?

@andreamari
Copy link
Member Author

Sometimes it happens that Mitiq is not compatible with the latest versions of supported frontends.
Users are typically not aware of this fact and they often report error messages that are due to this problem.

This function may help users to know what versions of frontends are more appropriate for the installed version of Mitiq. It doesn't mean that they are forced to install those versions, but at least they now that those versions have been tested.

@rmlarose
Copy link
Contributor

Thanks Andrea. I of course leave it to you but, FWIW, my semi-detached perspective is that this seems like over engineering. Unless there's many messages per day about this, I would do nothing. Even if there are many messages, I would still probably do nothing. It's user error if they're not using the supported version.

But if there's a really strong urge to do something, I would go minimal and add a URL to the error message, maybe to mitiq.about, like "See https://github.com/unitaryfund/mitiq/blob/master/dev_requirements.txt for supported versions."

@natestemen
Copy link
Member

I agree with Ryan in that I'm not sure this worth our time to add. I think the assumed happy path is something like

  1. user hits an error caused by a version incompatibility
  2. user has the wherewithal to run mitiq.supported_frontend_versions()
  3. user sees an installed frontend is not supported by mitiq
  4. user installs correct version of frontend

I don't feel as though having the function mitiq.supported_frontend_versions() is going to ensure the user knows to run it before opening an issue or messaging on discord.

A secondary concern is that adding HTTP requests seems strange to learn about a local install of mitiq. I'm not very familiar with python packaging, but can mitiq (installed with pip) access requirements.txt and dev_requirements.txt locally? Or are those not bundled in the wheel? They've got to be, as how else does pip know how to resolve dependencies?

@andreamari
Copy link
Member Author

Based on the feedback, we can close this issue.

Side comment: the message "See https://github.com/unitaryfund/mitiq/blob/master/dev_requirements.txt for supported versions." can be a good compromise. But, if we ever decide to do this, the correct link is something like "https://github.com/unitaryfund/mitiq/blob/v" + "installed_version" + "/dev_requirements.txt".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request A request for a feature, tool, or workflow in Mitiq. infrastructure For issues related to building, packaging, and continuous integration. non-quantum Requires no knowledge of quantum physics to fix / work on. priority/low A non-urgent issue to fix or idea to discuss.
Projects
None yet
Development

No branches or pull requests

3 participants