Skip to content

Instantly share code, notes, and snippets.

@mi-lee
Created October 12, 2018 01:00
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save mi-lee/b0c347d50d50febe0df2b72cfb40040c to your computer and use it in GitHub Desktop.
Script to diff jupyter notebooks. For TA grading
#!/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