Last active
April 4, 2024 10:56
-
-
Save kjaanson/215f0c7f2c4758397104ee265d4f393d to your computer and use it in GitHub Desktop.
Useful git hooks for working with Jupyter notebooks/Data analysis
This file contains 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
#!/bin/sh | |
# | |
# Pre-commit hook for clearing output cells from commited analysis Jupyter notebooks. | |
# | |
echo "Running pre-commit hook to clear output from deliver/*.ipynb notebooks." | |
for notebook in git diff --cached --name-only -- 'deliver/*.ipynb' | |
do | |
echo "Clearing output from $notebook" | |
jupyter nbconvert --ClearOutputPreprocessor.enabled=True --ClearOutputPreprocessor.remove_metadata_fields=[] --to notebook --inplace $notebook | |
git add $notebook | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment