Skip to content

Instantly share code, notes, and snippets.

@tylerneylon
Last active October 12, 2022 08:25
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tylerneylon/697065ca5906c185ec6dd3093b237164 to your computer and use it in GitHub Desktop.
Save tylerneylon/697065ca5906c185ec6dd3093b237164 to your computer and use it in GitHub Desktop.
git pre-commit hook to help support github-based code reviews of Jupyter notebooks in Python.
#!/bin/bash
#
# Convert all new Jupyter notebooks to straight Python files for easier code
# reviews.
#
for file in $(git diff --cached --name-only); do
if [[ $file == *.ipynb ]]; then
jupyter nbconvert --to script $file
git add ${file%.*}.py
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment