Add nbstripout pre-commit hook, keeping notebook outputs (#1372) - #1729
Open
shubhangithub wants to merge 1 commit into
Open
Add nbstripout pre-commit hook, keeping notebook outputs (#1372)#1729shubhangithub wants to merge 1 commit into
shubhangithub wants to merge 1 commit into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
shubhangithub
force-pushed
the
fix/1372-nbstripout-hook
branch
from
July 20, 2026 14:57
b7dc8cc to
c597a92
Compare
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1372. Re-lands #1519, which had all 13 CI checks green (including
pre-commit run -a) and a review of "once the CI passes, I'll be happy to merge", but was closed by its author. The hook config here is byte-identical to that PR's final state..pre-commit-config.yaml: nbstripout 0.8.1 with--keep-output, so cell outputs and figures survive (they render in the docs).docs/andexamples/(one notebook was added since Feat: Add pre-commit hook that strips notebooks of metadata #1519).docs/development.md(corrected from Feat: Add pre-commit hook that strips notebooks of metadata #1519's version, which said outputs are stripped — with--keep-outputthey aren't).Keep-outputs verification, comparing parsed JSON before vs after for all 20 notebooks: cell sources identical, output payloads identical, image/png counts identical (e.g.
freezing_parameters.ipynb18 outputs / 12 images, unchanged). The normalization changes two things:execution_countset to null (112 cells, 5 execute_result outputs), and cell ids renumbered to sequential integers in the three notebooks that carry them (muon,rosenbrock_ademamix,linear_assignment_problem) — standard deterministic nbstripout behavior, same as #1519's config produced. The rest of the notebook diff is nbformat's standard reindentation.pre-commit run --all-files(idempotent on second run) andruff check .(pinned v0.9.10) pass clean locally.