Skip to content

Add nbstripout pre-commit hook to strip notebook outputs - #52

Merged
e-koch merged 3 commits into
radio-astro-tools:masterfrom
e-koch:add-nbstripout-pre-commit
Sep 2, 2026
Merged

e-koch merged 3 commits into
radio-astro-tools:masterfrom
e-koch:add-nbstripout-pre-commit

Conversation

@e-koch

@e-koch e-koch commented Sep 2, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Adds a .pre-commit-config.yaml running the nbstripout hook, and a pre-commit GitHub Actions workflow that fails CI if a notebook with outputs is pushed — the same setup already used in radio-astro-tools/uvcombine.
  • Documents local setup in the README (pip install pre-commit nbstripout && pre-commit install).

All notebooks currently tracked on master that are part of the published site are already output-free, so this only adds enforcement going forward (it does not touch SpectralCube_Examples.ipynb, which is not part of the built site and does carry outputs).

Test plan

  • Verified locally with pre-commit run --files <notebook-with-outputs> that the hook strips cell outputs and execution counts as expected.
  • Confirm the new pre-commit CI workflow runs successfully once merged.

Uses the same setup as radio-astro-tools/uvcombine: an nbstripout
pre-commit hook plus a CI job that fails if a notebook with outputs
is pushed.
This notebook still had outputs committed, which the new nbstripout
pre-commit check correctly flags. Strip it so the whole repo is
consistent and CI passes.
These notebooks predate nbformat's cell "id" requirement, so several
cells had no id at all. nbformat's validator auto-assigns sequential
ids on write in that case, which nbstripout's CI check then flags as
a diff. Run the same pinned nbstripout hook locally so the committed
files already match what CI expects. No cell content changed.
@e-koch
e-koch merged commit b172fe4 into radio-astro-tools:master Sep 2, 2026
3 checks passed
@e-koch
e-koch deleted the add-nbstripout-pre-commit branch September 2, 2026 20:42
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