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

Latex drawer tested using notebook in binder #6450

Closed

Conversation

TharrmashasthaPV
Copy link
Contributor

@TharrmashasthaPV TharrmashasthaPV commented May 21, 2021

Summary

Fixes #6371 .

Details and comments

Following #4544 , this PR enable testing Latex drawer using notebook in Binder. The flow of the testing follows exactly from #4544 . The binder of this PR can be accessed at https://mybinder.org/v2/gh/TharrmashasthaPV/qiskit-terra/binder_test_branch?filepath=test%2Fipynb%2Flatex_tester.ipynb. The release notes have been added.

Files added/modified

  • Renamed test/ipynb/mpl_tester.ipynb to test/iplynb/snapshot_tester.ipynb - The notebook that will run in Binder that includes tests for both mpl and latex drawers.
  • Added apt.txt - This file installs the required latex dependencies.
  • Modified postBuild - This file now also collect and installs the latex qcircuit.sty package.
  • Added test/ipynb/latex/references - This folder contains all the reference images.
  • Added test/ipynb/latex/test_circuit_latex_drawer.py - The file that contains all the latex tests.

@@ -3,35 +3,61 @@
{
"cell_type": "code",
"execution_count": null,
"id": "fc250437",
Copy link
Member

Choose a reason for hiding this comment

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

It is possible to "clean" the notebook with nb-clean. In this way, we can keep the minimum file in the repo.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, sure. I'll do that 😃

Copy link
Member

@1ucian0 1ucian0 left a comment

Choose a reason for hiding this comment

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

Awesome work.

For a following PR, would be possible to have a py version of snapshot_tester.ipynb? With #6427 , CI could run snapshot_tester.py. What do you think?

new tests where necessary. You can do this as follows:

1. Make sure you have pushed your latest changes to your remote branch.
2. Go to link: `https://mybinder.org/v2/gh/<github_user>/<repo>/<branch>?urlpath=apps/test/ipynb/mpl_tester.ipynb`. For example, if your GitHub username is `username`, your forked repo has the same name the original, and your branch is `my_awesome_new_feature`, you should visit https://mybinder.org/v2/gh/username/qiskit-terra/my_awesome_new_feature?urlpath=apps/test/ipynb/mpl_tester.ipynb.
2. Go to link: `https://mybinder.org/v2/gh/<github_user>/<repo>/<branch>?urlpath=apps/test/ipynb/snapshot_tester.ipynb`. For example, if your GitHub username is `username`, your forked repo has the same name the original, and your branch is `my_awesome_new_feature`, you should visit https://mybinder.org/v2/gh/username/qiskit-terra/my_awesome_new_feature?urlpath=apps/test/ipynb/snapshot_tester.ipynb
Copy link
Member

Choose a reason for hiding this comment

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

I was not able to run https://mybinder.org/v2/gh/TharrmashasthaPV/qiskit-terra/binder_test_branch?filepath=apps/test/ipynb/snapshot_tester.ipynb . Maybe binder is in a bad day? Maybe I'm doing something wrong?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There seems to be a small error in the link you tried. 😃 We use either ...filepath=test/ipynb/snapshot_tester.py or ...urlpath=apps/test/ipynb/snapshot_tester.py in the link. One correct link is https://mybinder.org/v2/gh/TharrmashasthaPV/qiskit-terra/binder_test_branch?urlpath=apps/test/ipynb/snapshot_tester.ipynb. This link seems to be working for me.

Copy link
Contributor

@javabster javabster Aug 6, 2021

Choose a reason for hiding this comment

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

I also was struggling to run them a few days ago. I did manage to run them in the end but they were very slow. Also wasn't sure if it was a binder issue, or maybe something to do with the changes here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just tested running branches with and without the change of this PR and I kind of found them both to take similar duration (around 3 mins) to open a server for the first time a branch is run after a commit. So, I think it is a binder issue.

@TharrmashasthaPV
Copy link
Contributor Author

Awesome work.

For a following PR, would be possible to have a py version of snapshot_tester.ipynb? With #6427 , CI could run snapshot_tester.py. What do you think?

Thanks! I think currently we are just saving the output images at
https://github.com/Qiskit/qiskit-terra/blob/0cdacec2ee3b26a96b1d7bbb0def6b7eb66ac5b4/azure-pipelines.yml#L255-L256
but not comparing them in CI. I think it certainly would be better to have comparison in CI and so I too feel we should have a snapshot_tester.py. I'll be sure to push it in a following PR.

javabster
javabster previously approved these changes Oct 18, 2021
Copy link
Contributor

@javabster javabster left a comment

Choose a reason for hiding this comment

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

LGTM thanks Tharrma! 🚀

@javabster javabster added the Changelog: New Feature Include in the "Added" section of the changelog label Oct 18, 2021
@1ucian0 1ucian0 added Changelog: None Do not include in changelog and removed Changelog: New Feature Include in the "Added" section of the changelog labels Oct 18, 2021
postBuild Outdated
@@ -11,6 +11,10 @@
pip install matplotlib pylatexenc pillow appmode seaborn
pip install .

# Install QCircuit for LaTeX drawer
mkdir -p $(kpsewhich -var-value=TEXMFHOME)/tex/latex/qcircuit/
wget https://mirrors.ctan.org/graphics/qcircuit/qcircuit.sty -P $(kpsewhich -var-value=TEXMFHOME)/tex/latex/qcircuit/
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
wget https://mirrors.ctan.org/graphics/qcircuit/qcircuit.sty -P $(kpsewhich -var-value=TEXMFHOME)/tex/latex/qcircuit/
tlmgr install qcircuit

@@ -10,7 +10,7 @@
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.

"""Image comparison test for MPL graph drawer.
"""Image comparison test for MPL drawer.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"""Image comparison test for MPL drawer.
"""Image comparison test for MPL circuit drawer.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think just MPL drawer is correct, as it tests both the graphs and the circuits, then each subfolder has it's own __init.py__ where it specifies if it's testing the graphs or circuits

Copy link
Member

Choose a reason for hiding this comment

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

In that case...

Suggested change
"""Image comparison test for MPL drawer.
"""Image comparison test for MPL drawers.

@coveralls
Copy link

coveralls commented Nov 17, 2021

Pull Request Test Coverage Report for Build 1493871580

  • 0 of 1 (0.0%) changed or added relevant line in 1 file are covered.
  • 667 unchanged lines in 34 files lost coverage.
  • Overall coverage decreased (-0.4%) to 82.099%

Changes Missing Coverage Covered Lines Changed/Added Lines %
qiskit/visualization/utils.py 0 1 0.0%
Files with Coverage Reduction New Missed Lines %
qiskit/dagcircuit/dagnode.py 1 76.35%
qiskit/pulse/utils.py 1 97.37%
qiskit/transpiler/passes/utils/check_map.py 1 95.24%
qiskit/visualization/qcstyle.py 1 34.62%
qiskit/circuit/quantumcircuit.py 2 94.19%
qiskit/pulse/library/waveform.py 2 95.74%
qiskit/transpiler/passes/layout/vf2_layout.py 2 98.08%
qiskit/transpiler/passes/routing/stochastic_swap.py 3 96.58%
qiskit/circuit/tools/pi_check.py 4 87.04%
qiskit/transpiler/passes/utils/gate_direction.py 4 80.0%
Totals Coverage Status
Change from base Build 1468573388: -0.4%
Covered Lines: 49421
Relevant Lines: 60197

💛 - Coveralls

@1ucian0 1ucian0 added the Community PR PRs from contributors that are not 'members' of the Qiskit repo label Jun 14, 2022
@1ucian0 1ucian0 self-assigned this Jun 14, 2022
@jakelishman
Copy link
Member

In principle, despite its age, this PR still looks mostly appropriate to me, and not too far off merging. I suspect that the conflicts are mostly a minor change in this PR conflicting with another minor styling change in the LaTeX output since this PR was opened.

@1ucian0 - you assigned yourself before. Can you finish off driving this over the line? If you write the small changes you think were required, I can do the final review.

@1ucian0
Copy link
Member

1ucian0 commented Apr 25, 2023

This can probably be closed as we are moving to CI visual testing in #9961

@1ucian0 1ucian0 closed this Apr 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: None Do not include in changelog Community PR PRs from contributors that are not 'members' of the Qiskit repo
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Testing Latex drawer using binder
6 participants