Strip notebook outputs and add nbstripout pre-commit hook#240
Merged
Conversation
Prevents large, noisy diffs from notebook output cells (execution counts, embedded plot JSON/images) getting committed on every re-run. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Applies the new nbstripout hook retroactively so existing notebooks match what pre-commit will now enforce going forward. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Copilot stopped reviewing on behalf of
zfergus due to an error
July 7, 2026 20:49
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR standardizes Jupyter notebooks by clearing execution artifacts (outputs/execution counts) and adds a pre-commit hook to keep notebooks stripped going forward.
Changes:
- Added
nbstripoutto pre-commit hooks. - Cleared notebook cell outputs and set
execution_counttonullacross multiple notebooks. - Removed some non-essential notebook metadata fields (e.g.,
orig_nbformat) and adjusted cell metadata/IDs in places.
Reviewed changes
Copilot reviewed 7 out of 14 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| notebooks/tangent_basis_grad.ipynb | Clears execution artifacts; also rewrites cell IDs to numeric strings. |
| notebooks/physical_barrier.ipynb | Clears outputs/execution counts; removes some cell metadata and notebook-level fields. |
| notebooks/ee_mollifier_shape_derivative.ipynb | Clears outputs/execution counts. |
| notebooks/distances.ipynb | Clears outputs/execution counts; removes orig_nbformat. |
| notebooks/closest_point_grad.ipynb | Clears outputs/execution counts; removes orig_nbformat. |
| notebooks/area_weights.ipynb | Clears outputs/execution counts; removes orig_nbformat. |
| notebooks/adhesion.ipynb | Clears outputs/execution counts and large embedded outputs. |
| .pre-commit-config.yaml | Adds nbstripout hook to enforce stripping notebooks on commit. |
Comments suppressed due to low confidence (1)
notebooks/physical_barrier.ipynb:1
- This change drops existing cell metadata (previously included
scrolled: true). If the goal is purely to strip execution artifacts, avoid removing UI/authoring metadata because it can change how the notebook is presented when opened. Consider adjusting the notebook-cleaning workflow (or nbstripout configuration) to only clear outputs and execution counts while preserving cell metadata fields.
{
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+5
to
+6
| "execution_count": null, | ||
| "id": "0", |
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.
Summary
nbstripoutpre-commit hook so notebook output cells (execution counts, embedded plot JSON/images) no longer get committed on every re-run.Output-heavy notebooks were bloating diffs and repo size for no rendering benefit — several embed Plotly figures (
application/vnd.plotly.v1+json) with noimage/png/text/htmlfallback, which GitHub's notebook viewer doesn't render anyway.Test plan
pre-commit run nbstripout --all-filesruns clean (no further changes) after this PRpre-commit installlocally so the hook applies to future commits🤖 Generated with Claude Code