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 download notebook link in docs #2363

Merged
merged 5 commits into from
May 14, 2024
Merged

Add download notebook link in docs #2363

merged 5 commits into from
May 14, 2024

Conversation

cosenal
Copy link
Contributor

@cosenal cosenal commented May 12, 2024

Copy link

codecov bot commented May 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.22%. Comparing base (2a41ad0) to head (7ea42ff).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2363   +/-   ##
=======================================
  Coverage   98.22%   98.22%           
=======================================
  Files          87       87           
  Lines        4059     4059           
=======================================
  Hits         3987     3987           
  Misses         72       72           

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

@cosenal cosenal marked this pull request as ready for review May 12, 2024 22:05
@cosenal cosenal changed the title Add download notebook link Add download notebook link in docs May 12, 2024
@jordandsullivan
Copy link
Contributor

jordandsullivan commented May 13, 2024

Nice! Thanks for implementing this. One thing I noticed is that it doesn't include the images referenced in the notebook, so for the example you link:

For a demo, see https://mitiq--2363.org.readthedocs.build/en/2363/examples/calibration-tutorial.html

The image at the top doesn't load. In this case it's no big deal since the image is basically just a thumbnail
Screen Shot 2024-05-13 at 10 42 44 AM
Screen Shot 2024-05-13 at 10 40 30 AM

However, in cases where there's a diagram or figure included, it might be confusing to not have it missing.

Looking through a handful of examples though, e.g. (layerwise folding, Pennylane, it seems like the vast majority of images that are included in these docs are generated by the code itself, e.g.
Screen Shot 2024-05-13 at 10 49 24 AM
from the PennyLane example, so I don't see this as a blocking issue.

@cosenal
Copy link
Contributor Author

cosenal commented May 13, 2024

@jordandsullivan I don't see any great solution for that. And in fact it's going to be the same in any implementation of the «Download notebook» if we want to export it as an .ipynb. Unless we overcomplicate it and package it as a zip with images included. Same problem with all implementations I saw around, for example see the notebook that you can download from Jupyter Book chapter: https://inferentialthinking.com/chapters/08/Functions_and_Tables.html

A solution could be to use absolute url for images, which are already in our repo. E.g. https://github.com/unitaryfund/mitiq/blob/main/docs/source/_thumbnails/calibration.png for your example.

@jordandsullivan
Copy link
Contributor

@cosenal Yeah like I said, I think it's fine given that it seems relatively rare the images contain anything crucial in our notebooks.

@andre-a-alves
Copy link
Contributor

andre-a-alves commented May 13, 2024

Not to complicate things, but if we want to keep the images, we can always embed them as data directly in an <img> tag. I had to do it in a personal project before to keep images in Jupyter notebooks. We would just need to also document the need to do so when adding notebooks.

@cosenal
Copy link
Contributor Author

cosenal commented May 13, 2024

@andre-a-alves that's an option too, but it will make the .md files more bulky and worse to review/edit.

Copy link
Contributor

@andre-a-alves andre-a-alves left a comment

Choose a reason for hiding this comment

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

LGTM. Nice job!

@cosenal cosenal merged commit d2925f3 into main May 14, 2024
30 checks passed
@cosenal cosenal deleted the download-notebook-link branch May 14, 2024 10:59
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.

Add download option button to tutorials in docs
3 participants