Created
October 12, 2018 01:00
-
-
Save mi-lee/b0c347d50d50febe0df2b72cfb40040c to your computer and use it in GitHub Desktop.
Script to diff jupyter notebooks. For TA grading
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/bash | |
set -x | |
SOLN="solution.ipynb" | |
default() { | |
nbdiff-web ${SOLN} "$1"; | |
} | |
init() { | |
jupyter nbconvert --to script "$2" | |
SOLN=$(basename "$2" .ipynb).py | |
autopep8 --in-place --aggressive --aggressive ${SOLN} | |
} | |
v1() { | |
jupyter nbconvert --to script "$2" | |
STUDENT_FILE=$(basename "$2" .ipynb).py | |
autopep8 --in-place --aggressive --aggressive ${STUDENT_FILE} | |
git diff --no-index ${SOLN} ${STUDENT_FILE} | diff2html -i stdin --style=side | |
} | |
# v2() { | |
# jupyter nbconvert --to script "$2" | |
# STUDENT_FILE=$(basename "$2" .ipynb).py | |
# autopep8 --in-place --aggressive --aggressive ${STUDENT_FILE} | |
# icdiff ${SOLN} ${STUDENT_FILE} | |
# } | |
# v3() { | |
# jupyter nbconvert --to script "$2" | |
# STUDENT_FILE=$(basename "$2" .ipynb).py | |
# autopep8 --in-place --aggressive --aggressive ${STUDENT_FILE} | |
# diffchecker ${SOLN} ${STUDENT_FILE} --expires hour | |
# } | |
if [ "$1" = "v1" ]; then v1 "$@"; | |
# elif [ "$1" = "v2" ]; then v2 "$@"; | |
# elif [ "$1" = "v3" ]; then v3 "$@"; | |
elif [ "$1" = "init" ]; then init "$@"; | |
else | |
default "@"; | |
fi | |
echo "Done."; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment