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

Fix "Run in Colab" and "Download Notebook" links in tutorials #2268

Merged
merged 1 commit into from
Jul 4, 2024

Conversation

kurtamohler
Copy link
Contributor

Description

Fixes the links to run tutorials in Colab and to download notebooks.

Motivation and Context

close #2134

  • I have raised an issue to propose this change (required for new features and bug fixes)

Types of changes

What types of changes does your code introduce? Remove all that do not apply:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds core functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation (update in the documentation)
  • Example (update in the folder of examples)

Checklist

Go over all the following points, and put an x in all the boxes that apply.
If you are unsure about any of these, don't hesitate to ask. We are here to help!

  • I have read the CONTRIBUTION guide (required)
  • My change requires a change to the documentation.
  • I have updated the tests accordingly (required for a bug fix or a new feature).
  • I have updated the documentation accordingly.

Copy link

pytorch-bot bot commented Jul 3, 2024

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/rl/2268

Note: Links to docs will display an error until the docs builds have been completed.

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

❌ 3 New Failures, 11 Pending, 5 Unrelated Failures

As of commit 9b38cf6 with merge base ba6897d (image):

NEW FAILURES - The following jobs have failed:

FLAKY - The following jobs failed but were likely due to flakiness present on trunk:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jul 3, 2024
@@ -61,7 +61,7 @@
if (downloadNote.length >= 1) {
var tutorialUrl = $("#tutorial-type").text();
var githubLink = "https://github.com/pytorch/rl/blob/main/tutorials/sphinx-tutorials/" + tutorialUrl + ".py",
notebookLink = $(".reference.download")[1].href,
notebookLink = $(".reference.download")[0].href,
Copy link
Contributor Author

@kurtamohler kurtamohler Jul 3, 2024

Choose a reason for hiding this comment

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

The issue was that the ".reference.download" selects both the .py and .ipynb links, and the .ipynb one happens to appear first in the html that sphinx-gallery generates. But I'm not sure what determines the order of the links--maybe it could change between different versions of sphinx-gallery.

We could potentially do something like this instead:
$(".sphx-glr-download-jupyter").find(".download.reference")[0].href

That would only select the .ipynb, so the order of the links in the generated html wouldn't matter. However, I don't see anything about the "sphx-glr-download-jupyter" html class in the sphinx-gallery docs, so it could be unsafe to assume that that will always work. But then again, I don't know if the "download" and "reference" classes are meant for public use either.

I'm not sure what the sphinx-gallery docs say about how this is supposed to be done. I looked and was unable to find anything

Copy link
Contributor Author

@kurtamohler kurtamohler Jul 3, 2024

Choose a reason for hiding this comment

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

Ah, there is an issue/PR in sphinx-gallery where "sphx-glr-download-jupyter" was added for public use: sphinx-gallery/sphinx-gallery#622

So it seems like it should be safe to use it. I'll update this PR

Copy link
Contributor

@vmoens vmoens left a comment

Choose a reason for hiding this comment

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

Victory!! Thanks a million

@vmoens vmoens merged commit c4db149 into pytorch:main Jul 4, 2024
45 of 55 checks passed
@vmoens vmoens mentioned this pull request Jul 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] "Run in Colab" button in tutorials not working
3 participants