Created
May 10, 2015 14:07
-
-
Save ebenolson/22c021477a527efee6da to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# Usage: experiment.sh SOURCE_FILE LOG_COMMIT_MESSAGE | |
if [ $# -eq 0 ] | |
then | |
echo "Usage: experiment.sh SOURCE_FILE [LOG_COMMIT_MESSAGE]" | |
exit -1 | |
fi | |
if [ $# -eq 2 ] | |
then | |
COMMITMESSAGE=$2 | |
else | |
COMMITMESSAGE="$1 $(git log -n1 --oneline $1)" | |
fi | |
line=$(git status -s $1 | grep "^ M") | |
if [ $? -eq 0 ] | |
then | |
echo "Commit changes before running!" | |
exit -1 | |
fi | |
function cleanup { | |
echo $COMMITMESSAGE | |
kill $PID | |
git add $LOGFILE | |
git commit -m "$COMMITMESSAGE" | |
} | |
VERSION=$(git log -n1 --oneline $1 | awk '{print $1;}') | |
echo $COMMITMESSAGE | |
NOW=$(date +"%Y-%m-%d_%H:%M") | |
LOGFILE="./output/logs/${NOW}_${VERSION}_${1}.txt" | |
python -u $1 --basename "$NOW" >> $LOGFILE 2>&1 & | |
PID=$! | |
echo "Running $1 at commit $VERSION, PID is $PID" >> $LOGFILE | |
echo "Start time is $NOW" >> $LOGFILE | |
trap cleanup SIGHUP SIGTERM SIGINT | |
tail --pid=$PID -f $LOGFILE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment