ci: swap aflc/pre-commit-jupyter for nbstripout#700
Merged
Conversation
The old hook (`aflc/pre-commit-jupyter` `jupyter-notebook-cleanup`) was in place but wasn't stripping the per-cell `ExecuteTime` / `execution` timestamps that PyCharm and Jupyter add on every run. Those fields bloated notebook diffs (~180 lines on a recent PR) without adding review value. Swap to `kynan/nbstripout`, configured to also strip `cell.metadata.ExecuteTime` and `cell.metadata.execution`. Default nbstripout behavior (clear outputs + execution counts) is fine here because notebooks are executed in CI by nbsphinx (`nbsphinx_execute = "auto"` in doc/conf.py), so outputs are regenerated for the rendered docs. `examples/solve-on-remote.ipynb` keeps its existing exclusion (its outputs document the remote-handler interaction and can't be regenerated by docs CI without an SSH setup). One-time cleanup applied to all non-excluded notebooks. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
FabianHofmann
approved these changes
May 20, 2026
Collaborator
FabianHofmann
left a comment
There was a problem hiding this comment.
nice! happy to pull in as soon as RTD successfully builds
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
The existing
aflc/pre-commit-jupyterjupyter-notebook-cleanuphook was configured but wasn't stripping the per-cellExecuteTime/executiontimestamp metadata that PyCharm and Jupyter add on every run. Those fields bloated notebook diffs without adding review value (~180 lines on PR #685 alone).Swap to
kynan/nbstripout, configured with--extra-keys=cell.metadata.ExecuteTime cell.metadata.executionso the timestamps go too.What changes
.pre-commit-config.yaml: swap the hook.examples/*.ipynb+benchmark/notebooks/plot-benchmarks.py.ipynb): one-time pass of the new hook — strips stale outputs, execution counts,ExecuteTimeblocks, and straycollapsedcell metadata. Idempotent on a second run.examples/solve-on-remote.ipynb: keeps its existing exclusion (its outputs document SSH-handler interaction and can't be regenerated by docs CI without an SSH setup).Test plan
pre-commit run nbstripout --all-files— passes after the one-time cleanup pass.nbsphinxrebuild on RTD (pre-merge preview): notebooks render with fresh outputs end-to-end.🤖 Generated with Claude Code