-
Notifications
You must be signed in to change notification settings - Fork 146
Fix issue #1554: Preserve custom thumbnails in gallery script #1649
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 issue #1554: Preserve custom thumbnails in gallery script #1649
Conversation
|
Seems to have worked for the AD nb. But I don't know what the create_thumbnail pic does, we're skipping that branch. Should we? |
|
|
|
Up to you then ;) |
|
@copilot run the |
Done! Modified the code to always call |
|
I checked the preview and the custom thumbnail looks way worse. Let me check if we're dumping resolution or was just an aspect ratio thing |
|
Edited: https://pytensor--1649.org.readthedocs.build/en/1649/_images/vector_jacobian_product.png It was not square, that's on me, but the resolution is pretty lame. Looks worse on my phone where each gallery item takes more space than on the PC. Also instead of cropping it should extend with white, which is I guess what the old behavior ended up doing naturally? Anyway fine to merge and open an issue, but it seems that for now not messing with customs would probably be better? |
|
@copilot I changed my mind. Revert the last commit, so that we do not use create_thumbnail when a thumbnail is provided |
Reverted! Custom thumbnails are now preserved as-is without processing through create_thumbnail. (commit: will be shown after push) |
|
pre-commit.ci autofix |
|
@copilot rebase the pr branch onto main |
Rebased the PR branch onto main. The rebase was clean with no conflicts. |
Modified scripts/generate_gallery.py to check if a thumbnail file already exists before extracting from notebooks. This prevents the script from overwriting manually-placed custom thumbnails in the _thumbnails directory. The gen_previews() method now: 1. Checks if self.png_path exists 2. If yes, logs info message and returns early (preserving custom thumbnail) 3. If no, proceeds with extraction from notebook or uses default logo Fixes #1554
0093fdf to
45de52a
Compare
Summary
Fixes #1554 by preventing the gallery script from overwriting manually-placed custom thumbnails during documentation builds.
Problem
The
scripts/generate_gallery.pyscript was unconditionally extracting thumbnails from gallery notebooks and saving them todoc/_thumbnails/, which meant any custom thumbnails manually placed in that directory would be overwritten every time the documentation was built.Solution
Modified the
NotebookGenerator.gen_previews()method to:create_thumbnail()for newly extracted or default thumbnailsIf no thumbnail exists, the script proceeds as before:
Changes
scripts/generate_gallery.pyNotebookGenerator.gen_previews()Testing
This ensures custom thumbnails retain their original quality and resolution while still providing consistent sizing for auto-generated thumbnails. Custom thumbnails are not processed through
create_thumbnail()to avoid loss of quality.This pull request was created as a result of the following prompt from Copilot chat.
Original prompt
This pull request was created as a result of the following prompt from Copilot chat.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.