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

NOTEBOOKS="RNN_Captioning.ipynb
    LSTM_Captioning.ipynb
    NetworkVisualization-PyTorch.ipynb
    StyleTransfer-PyTorch.ipynb
    Generative_Adversarial_Networks_PyTorch.ipynb"

CODE=cs231n/"classifiers/rnn.py
    cs231n/rnn_layers.py"

REMOTE_DIR="cs231n-2019-assignment3"
ZIP_FILENAME="a3.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

echo "### Zipping file ###"
zip -r ${ZIP_FILENAME} . -x '*.ipynb_checkpoints*' -i '*.ipynb' '*.py' > assignment_zip.log
echo ""

mkdir -p ${REMOTE_DIR}
cp ${FILES} ${REMOTE_DIR}
mv ${ZIP_FILENAME} ${REMOTE_DIR}

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_a3_pytorch && exit"
