Feat: Add pre-commit hook that strips notebooks of metadata#1519
Feat: Add pre-commit hook that strips notebooks of metadata#1519haroon0x wants to merge 4 commits intogoogle-deepmind:mainfrom
Conversation
|
Thanks! Is there a way to do this without reformatting the notebooks? I think this PR reindents all notebook files. Can you squash to a single commit please? |
185ddaa to
bba8e59
Compare
|
@rdyro I’ve removed the notebook formatting and squashed the commit. |
|
@rdyro i don't see any other way to reformat the notebooks without including it any pr. |
|
Hmmm, I see this hook removes figures, we definitely want to keep those since they are part of the notebook examples when displayed in the docs. Can we do this hook without removing cell outputs themselves (just metadata)? |
|
@rdyro do you want me to include the reformatting of the notebooks in this pr ? |
|
I'm trying to review what this hook is actually suggesting. It's still trying to delete output images, I think? |
|
I'm looking at the CI, it seems the hook still wants to remove the images before passing. You're right that you're not modifying them now. |
|
Maybe I'm misreading this. That's a big diff it seems, but this PR is a good idea, so once the CI passes, I'll be happy to merge! |
|
@rdyro ci is passing now. |
|
@rdyro any changes ? |
Fixes #1372
Summary
This PR adds a pre-commit hook using nbstripout to automatically strip metadata from Jupyter notebooks before commits. This keeps diffs clean and readable by removing execution counts, cell outputs, and random cell IDs.
Changes Made
1. Pre-commit Configuration (
.pre-commit-config.yaml)nbstripouthook (v0.8.1) from https://github.com/kynan/nbstripout.ipynbfiles before commits2. Documentation (
docs/development.md)3. Cleaned Notebooks
What nbstripout Does
The hook automatically removes:
"execution_count": 1→"execution_count": null"GDUs0Q8gPYes"→ Sequential"0","1","2"...