Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- TIMEOUT_VAL=60 #unit : seconds
- ####### Auxiliary functions ######
- get_id() {
- local id=$(echo "$1" | /bin/grep -oPi -m 1 "[A|B]\d{6}" | head -1)
- echo ${id}
- }
- get_float() {
- echo "$@" | /bin/grep -oP "\d+\.\d+" #Try capturing floating number
- if [ $? -ne 0 ]
- then
- echo "$@" | /bin/grep -oP "\d+" #Or, just capture an integer
- fi
- }
- bc_true() {
- (( $(echo "$@" | bc -l) != 0))
- }
- get_1st_loss() {
- local ret=$(echo "$1" | /bin/grep -A 1 "^0 번째 트레이닝")
- get_float "$ret"
- }
- get_final_loss() {
- local ret=$(echo "$1" | /bin/grep -A 1 "^30 번째 트레이닝" )
- get_float "$ret"
- }
- get_accuracy() {
- local ret=$(echo "$1" | /bin/grep -A 3 "^30 번째 트레이닝" | tail -1 )
- get_float "$ret"
- }
- ####### Score each student's assignment ######
- for path in $(find . -name *singlelayer.py)
- do
- id=$(get_id "${path}")
- cp -f $path ../workspace/
- if [ $? -ne 0 ]
- then
- echo "Something is wrong."
- exit 1
- fi
- printf "Score %s's assignment.\n" "$id"
- val=$(timeout --foreground $TIMEOUT_VAL python3 ../workspace/main.py 2>&1)
- if [ $? -ne 0 ]
- then
- printf "%s got failed.\n" "$id"
- continue
- fi
- loss=$(get_1st_loss "$val")
- finalLoss=$(get_final_loss "$val")
- accu=$(get_accuracy "$val")
- if bc_true "${loss} < 5" && bc_true "${finalLoss} < 1" && bc_true "${accu} >= 60"
- then
- printf "%s got passed.\n" "$id"
- else
- printf "%s got failed.\n" "$id"
- fi
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement