Created
October 23, 2020 03:49
-
-
Save v-i-s-h/fe77eeadade02e915ac58c93bd69dada to your computer and use it in GitHub Desktop.
Jupyter notebook git tools
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
# prepare notebook folder for commit | |
# Does | |
# 1. Render all notebooks to HTML | |
# 2. Clear all cell outputs | |
# Make destination directory to store rendered html, if not exists | |
RENDER_DIR=rendered | |
mkdir -p rendered | |
# Get all files with Added, Modified, or untracked status from git | |
FILES_TO_RENDER=$(git status . --porcelain | sed -nr 's/^([AM]|\?\?) *.+\/(.*ipynb)/\2/p') | |
# Render to html | |
jupyter nbconvert $FILES_TO_RENDER --output-dir=$RENDER_DIR | |
# Clear outputs of all notebooks | |
jupyter nbconvert --ClearOutputPreprocessor.enabled=True --inplace $FILES_TO_RENDER |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment