#!/bin/bash
#NOTE: DO NOT EDIT THIS FILE-- MAY RESULT IN INCOMPLETE SUBMISSIONS

NOTEBOOKS="FullyConnectedNets.ipynb
BatchNormalization.ipynb
Dropout.ipynb
ConvolutionalNetworks.ipynb
PyTorch.ipynb
TensorFlow.ipynb"

CODE="cs231n/layers.py
cs231n/classifiers/fc_net.py
cs231n/optim.py
cs231n/classifiers/cnn.py"

REMOTE_DIR="cs231n-2019-assignment2"
ZIP_FILENAME="a2.zip"

FILES="${NOTEBOOKS} ${CODE}"
for FILE in ${FILES}
do
	if [ ! -f ${FILE} ]; then
		echo "Required file ${FILE} not found, Exiting."
		exit 0
	fi
done
if [ -d ${REMOTE_DIR} ]; then
	rm -r ${REMOTE_DIR}
fi
mkdir -p ${REMOTE_DIR}
cp ${FILES} ${REMOTE_DIR}

echo "### Zipping file ###"
zip -r ${REMOTE_DIR}/${ZIP_FILENAME} . -x "*.git*" "*cs231n/datasets*" "*.ipynb_checkpoints*" "*README.md" "collectSubmission.sh" "*requirements.txt" "*__pycache__*" ".env/*" > assignment_zip.log
echo ""

echo "### Submitting to myth ###"
echo "Type in your Stanford student ID (alphanumeric, *not* the 8-digit ID):"
read -p "Student ID: " SUID
echo ""

echo "### Copying to ${SUID}@myth.stanford.edu:${REMOTE_DIR} ###"
echo "Note: if myth is under heavy use, this may hang: If this happens, rerun the script."
scp -r ${REMOTE_DIR} ${SUID}@myth.stanford.edu:~/
echo ""

echo "### Running remote submission script from ${SUID}@myth.stanford.edu:${REMOTE_DIR} ###"
ssh ${SUID}@myth.stanford.edu "cd ${REMOTE_DIR} && /afs/ir/class/cs231n/grading/submit_a2 && exit"
