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

Make test for 3rd party imports meaningful again #2270

Merged
merged 2 commits into from
Apr 8, 2024
Merged

Conversation

cosenal
Copy link
Contributor

@cosenal cosenal commented Apr 7, 2024

Description

(This fix is a prerequisite for working on #746.)

A test was created in #745 to double check that one can import mitiq without any 3rd party integration package installed. However, this was relying on pip install . not installing any integration packages, which is no longer the case, since cirq is in the main requirements.txt and in turn installs pyquil.

In other words, the scenario in which QPROGRAM collapses to the single Circuit type (and not an Union) was never hit. This PR addresses this.

A more elegant fix would imply to only have cirq-core in the main requirements, but that requires some deeper redesign of how we integrate 3rd parties packages.

Test

I tested this with the awesome act tool (note: it requires Docker) by running

act push --container-architecture linux/amd64 -j core

From the output (in the screenshot), one can see that pyquil is found and uninstalled.

Screenshot 2024-04-07 at 20 48 45

@@ -3,8 +3,7 @@
# module.
# Original authors: Cirq developers: Xiao Mi, Dave Bacon, Craig Gidney,
# Ping Yeh, Matthew Neely.
# Code URL = ('https://github.com/quantumlib/Cirq/blob/main/cirq-core/cirq/
# experiments/qubit_characterizations.py').
# Code URL = ('https://github.com/quantumlib/Cirq/blob/main/cirq-core/cirq/experiments/qubit_characterizations.py').
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated to the PR's scope; it just annoyed me that I couldn't Ctrl+Click on that link from my IDE 😄

@cosenal
Copy link
Contributor Author

cosenal commented Apr 7, 2024

The build failed because of an issue with codecov unrelated to the PR, see codecov/codecov-action#598

@nathanshammah
Copy link
Member

Great @cosenal. act seems very useful independent on #746: I advise opening an issue and related PR (with info on contributing to docs, etc.) for act.

Copy link

codecov bot commented Apr 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.28%. Comparing base (39579b2) to head (19ecf42).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2270   +/-   ##
=======================================
  Coverage   98.28%   98.28%           
=======================================
  Files          90       90           
  Lines        4263     4263           
=======================================
  Hits         4190     4190           
  Misses         73       73           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@cosenal
Copy link
Contributor Author

cosenal commented Apr 8, 2024

The codecov error in the build was fixed by #2271 but now linkcheck is erroring out 🤦

@natestemen
Copy link
Member

That'll happen, unfortunately. I usually check to ensure the links are not truly broken, and if they work, then just make a note of it being the reason for the red X and continue on.

Copy link
Member

@natestemen natestemen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

We should merge this, but it does make me wonder as something to consider for the future: can we remove cirq as our main dependency and use cirq-core instead?

Comment on lines -23 to +25
if isinstance(mitiq.QPROGRAM, ABCMeta):
pass # If only Cirq is installed, QPROGRAM is not a typing.Union.
else:
if get_origin(mitiq.QPROGRAM) is Union:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, this is an easier way to understand that the type of something is a Union!

@cosenal
Copy link
Contributor Author

cosenal commented Apr 8, 2024

Good catch!

We should merge this, but it does make me wonder as something to consider for the future: can we remove cirq as our main dependency and use cirq-core instead?

That's exactly what I wrote in the last sentence of the description 😬

@natestemen
Copy link
Member

You're right, sorry!

@cosenal
Copy link
Contributor Author

cosenal commented Apr 8, 2024

Docs build fails because of linkcheck getting 403 from iopscience. I inspected those links manually and they work, hence merging.

@cosenal cosenal merged commit 8ed0622 into main Apr 8, 2024
17 of 18 checks passed
@cosenal cosenal deleted the fix-test-import branch April 8, 2024 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants