FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix(colab): Add linter for malformed lists in generated notebooks by ribhuji · Pull Request #3947 · pytorch/tutorials · GitHub

Repository navigation

fix(colab): Add linter for malformed lists in generated notebooks - #3947

Open
ribhuji wants to merge 4 commits into
pytorch:mainfrom
ribhuji:fix-indentation
Open

ribhuji wants to merge 4 commits into
pytorch:mainfrom
ribhuji:fix-indentation

Conversation

ribhuji commented Aug 3, 2026 •
edited
Loading

Copy link
Copy Markdown
Contributor

Fixes #3946

Description

Some list structures in Sphinx-Gallery tutorial sources render correctly in the HTML documentation but become malformed after conversion to Markdown in the generated Google Colab notebooks.

This PR adds a repository-local TUTORIAL_MARKUP Lintrunner check that detects the two source patterns responsible for the problems documented in #3946:

  • indented lists that begin without a separating blank narrative line; and
  • list continuation lines that are not indented beneath their list item.

The checker only examines Sphinx-Gallery narrative content from module docstrings and gallery comment blocks. It accounts for valid nested lists, reStructuredText directives, and list tables to avoid reporting those as violations.

Validation strategy

This draft is being built in two commits so the Lintrunner behavior can be verified directly in GitHub Actions:

  1. Add and register the linter.
    The expected CI result is 14 diagnostics across exactly the 10 tutorials documented in [BUG] - Incorrect list rendering in Google Colab tutorials #3946, with no additional tutorial files reported.
  2. Fix the detected violations.
    The subsequent CI run should pass with no TUTORIAL_MARKUP diagnostics.

Local validation

python3 -m unittest discover -s tools/linter/tests -p 'test_*.py'
lintrunner --all-files --take TUTORIAL_MARKUP

The unit test suite currently passes all eight tests. The complete linter scan reports 14 diagnostics across the 10 affected tutorial files and reports no other tutorial files.

Checklist

  • The issue that is being fixed is referred in the description (see above "Fixes #ISSUE_NUMBER")
  • Only one issue is addressed in this pull request
  • Labels from the issue that this PR is fixing are added to this pull request
  • No unnecessary issues are included into this pull request.

pytorch-bot Bot commented Aug 3, 2026 •
edited
Loading

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/tutorials/3947

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

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

meta-cla Bot added the cla signed label Aug 3, 2026
ribhuji marked this pull request as draft August 3, 2026 10:22

ribhuji commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

@albanD, could you please approve the workflow run for this draft PR?

The current commit intentionally contains only the new Lintrunner check. The job is expected to fail with 14 diagnostics across the 10 tutorials documented in #3946, which will validate that the check detects the existing issues.

Once that run is recorded, I’ll push a second commit fixing those violations. This will preserve both the detection run and the final passing run in the PR history. Thank you!

ribhuji commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

Hey @albanD, bumping this up!

albanD commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Sorry, I don't really have a lot of time to review things here. What is this one about?

ribhuji commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

14 Colabs created from the tutorials have indentation problems, adding a Lintrunner check for that.

albanD commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Why is it not fixing these notebooks?

ribhuji commented Aug 11, 2026

Copy link
Copy Markdown
Contributor Author

I don't just want to fix these issues. But I also want to add a check that stops these issues from occurring in any new tutorials as well.

If we run the workflow now, the workflow job fails with 14 diagnostics across the 10 tutorials documented in #3946, which will validate that the Lintrunner detects the existing issues, and there is value in having the Lintrunner check being added to this repo.

After that I'll push a second commit to this PR fixing these issues, the lintrunner will pass then. This will preserve both the detection run and the final passing run in the PR history.

ribhuji commented Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

1. USB Semi-Supervised Learning

Tutorial: https://docs.pytorch.org/tutorials/advanced/usb_semisup_learn.html

Fixed content: the list of functions imported from semilearn in the Use USB to Train FreeMatch/SoftMatch on CIFAR-10 with only 40 labels section.

Colab - https://colab.research.google.com/drive/1pLl7Z1-vo22Z_d9wKxoBsPM6zv9pnpZz?usp=sharing

2. Automatic Differentiation with torch.autograd

Tutorial: https://docs.pytorch.org/tutorials/beginner/basics/autogradqs_tutorial.html

Fixed content:

  • the list in the note explaining gradient availability; and
  • the list of reasons for disabling gradient tracking.

Colab - https://colab.research.google.com/drive/106DTdB7xXC7ICHb4kv4cvY9GvPFooH3n?usp=sharing

3. Datasets & DataLoaders

Tutorial: https://docs.pytorch.org/tutorials/beginner/basics/data_tutorial.html

Fixed content: the FashionMNIST parameter list in the Loading a Dataset section.

Colab - https://colab.research.google.com/drive/1Ryu6JY2FgQJqdqwzn5UPSuqz5RoPi2mY?usp=sharing

4. Neural Networks

Tutorial: https://docs.pytorch.org/tutorials/beginner/blitz/neural_networks_tutorial.html

Fixed content: the lists under Recap, At this point, we covered, and Still Left.

Colab - https://colab.research.google.com/drive/1kOz58dE3EyV2BzFO_0bJZeh9-ZQ3S2VC?usp=sharing

5. What is torch.nn really?

Tutorial: https://docs.pytorch.org/tutorials/beginner/nn_tutorial.html

Fixed content: the list of assumptions in the Wrapping DataLoader section.

Colab - https://colab.research.google.com/drive/15YAO3JGZueMIJRPydokTHfpv8gNa0nDX?usp=sharing

6. Optimizer Step in Backward

Tutorial: https://docs.pytorch.org/tutorials/intermediate/optimizer_step_in_backward_tutorial.html

Fixed content: the numbered list following Several major observations.

Colab - https://colab.research.google.com/drive/1ZYB3KAJUllybwpv6XoYQgvi_DI1j-zDQ?usp=sharing

7. PyTorch Profiler

Tutorial: https://docs.pytorch.org/tutorials/recipes/recipes/profiler_recipe.html

Fixed content: the nested activity types under the activities profiler parameter in the Using profiler to analyze execution time section.

Colab - https://colab.research.google.com/drive/153edt0JVmGtAkl-C4_Mtbq8xFRlRwd4h?usp=sharing

8. Timer Quick Start

Tutorial: https://docs.pytorch.org/tutorials/recipes/recipes/timer_quick_start.html

Fixed content: the Contents list near the beginning of the tutorial.

Colab - https://colab.research.google.com/drive/1kjvktsPU5fUun1WURCT5nrOfCaAQ7Zdm?usp=sharing

9. Changing the Compilation Stance

Tutorial: https://docs.pytorch.org/tutorials/recipes/torch_compiler_set_stance_tutorial.html

Fixed content: the list following Other stances include.

Colab - https://colab.research.google.com/drive/1Qz2BziA-WoU5A511VkPTSfOnFKI-28zE?usp=sharing

10. GPU Direct Storage

Tutorial: https://docs.pytorch.org/tutorials/unstable/gpu_direct_storage.html

Fixed content: the list following The steps involved in the process are as follows.

Colab - https://colab.research.google.com/drive/1XZDmHG-fy7LhldeIFwIODijuT9fKRdrt?usp=sharing


Built all 10 with -

GALLERY_PATTERN='(?:^|/)(?:usb_semisup_learn|autogradqs_tutorial|data_tutorial|neural_networks_tutorial|nn_tutorial|optimizer_step_in_backward_tutorial|profiler_recipe|timer_quick_start|
  torch_compiler_set_stance_tutorial|gpu_direct_storage)\.py$' \
  sphinx-build -E -D plot_gallery=0 -b html . _build/html

ribhuji marked this pull request as ready for review August 13, 2026 09:18

ribhuji commented Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

@albanD the notebooks are fixed now, and the lintrunner will ensure this exact issue shouldn't re-occur.

Please run the workflows. Thanks!

ribhuji commented Aug 18, 2026

Copy link
Copy Markdown
Contributor Author

Hey @albanD, bumping this up!

ribhuji commented Aug 20, 2026

Copy link
Copy Markdown
Contributor Author

@albanD gentle reminder.

ribhuji commented Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

@albanD gentle bump!

albanD commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

Sorry I didn't have time to look at this.
I'm trying to find more maintainers to help here but it's hard.

ribhuji commented Sep 30, 2026

Copy link
Copy Markdown
Contributor Author

No worries @albanD . Can you run the workflow? Also I can help if you want. Not sure I am eligible with just 2 hanges though.

ribhuji commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

@albanD the linkChecker was failing for 2 unrelated links, have fixed them in the last commit. Can you rerun the workflow?

ribhuji commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

@albanD gentle reminder.

This branch has not been deployed

No deployments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] - Incorrect list rendering in Google Colab tutorials

2 participants


Back | FazBrowse Home | New Git URL