-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bring back cleaning of notebooks (#203)
- Add local `pre-commit` hook that will ensure any notebooks added to the gallery won't contain any output cells - Fix `Checkerboard` notebook
- Loading branch information
Showing
6 changed files
with
62 additions
and
20 deletions.
There are no files selected for viewing
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/bin/bash | ||
|
||
# This ensures that all of te tutorial notebook files have no | ||
# content when committed. It does the following: | ||
# | ||
# 1. Take the MD5 hash of the original file. | ||
# 2. Strip out all the output cells from the file, saving to a temp file | ||
# 3. Take the MD5 hash of the converted file. | ||
# 4. If they are different, copy the file over the original and add it to the | ||
# list of modified | ||
|
||
for f in "$@" | ||
do | ||
md5Orig=$(md5sum "$f" | cut -f 1 -d \ ) | ||
|
||
outDir=$(dirname "$f") | ||
out="${outDir}/tmp.ipynb" | ||
|
||
jupyter nbconvert --log-level=ERROR \ | ||
--ClearOutputPreprocessor.enabled=True \ | ||
--to notebook \ | ||
--output="tmp" \ | ||
"$f" | ||
|
||
md5New=$(md5sum "$out" | cut -f 1 -d \ ) | ||
|
||
if [ "$md5New" == "$md5Orig" ]; then | ||
rm "$out" | ||
else | ||
echo "Cleaned: $f" | ||
mv "$out" "$f" | ||
fi | ||
|
||
done |
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