Skip to content

ci: swap aflc/pre-commit-jupyter for nbstripout#700

Open
FBumann wants to merge 1 commit into
masterfrom
ci/nbstripout
Open

ci: swap aflc/pre-commit-jupyter for nbstripout#700
FBumann wants to merge 1 commit into
masterfrom
ci/nbstripout

Conversation

@FBumann
Copy link
Copy Markdown
Collaborator

@FBumann FBumann commented May 19, 2026

Summary

The existing aflc/pre-commit-jupyter jupyter-notebook-cleanup hook was configured but wasn't stripping the per-cell ExecuteTime / execution timestamp 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.execution so the timestamps go too.

What changes

  • .pre-commit-config.yaml: swap the hook.
  • 14 notebooks (examples/*.ipynb + benchmark/notebooks/plot-benchmarks.py.ipynb): one-time pass of the new hook — strips stale outputs, execution counts, ExecuteTime blocks, and stray collapsed cell 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.
  • Idempotent: re-running the hook produces no changes.
  • nbsphinx rebuild on RTD (pre-merge preview): notebooks render with fresh outputs end-to-end.

🤖 Generated with Claude Code

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant