forked from bistro-its-berkeley/BISTRO
-
Notifications
You must be signed in to change notification settings - Fork 0
/
competition.sh
executable file
·72 lines (61 loc) · 1.77 KB
/
competition.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env bash
sudo docker rm bistro-competition
POSITIONAL=()
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-s|--scenario)
SCENARIO="$2"
shift # past argument
shift # past value
;;
-sz|--size)
SIZE="$2"
shift # past argument
shift # past value
;;
-m|--memory)
MEMORY="$2"
shift # past argument
shift # past value
;;
-c|--cpus)
CPUS="$2"
shift # past argument
shift # past value
;;
-i|--input)
INPUT="$2"
shift # past argument
shift # past value
;;
-n|--iters)
ITERS="$2"
shift # past argument
shift # past value
;;
*) # unknown option
POSITIONAL+=("$1") # save it in an array for later
shift # past argument
;;
esac
done
set -- "${POSITIONAL[@]}" # restore positional parameters
echo INPUT = "${INPUT}"
for image in $(docker volume ls | awk -F' +' '{print $2}') ; do
if [ ${image} == "competition-output" ]; then
echo "Volume already exists"
fi
done
if [ -z $(docker volume ls | awk -F' +' '{print $2}' | grep "competition-output") ]; then
docker volume create competition-output >> /dev/null
fi
M_EXT=$(echo "${MEMORY}" | awk -F '([0-9])+' '{print $2}')
M_SIZE=$(echo "${MEMORY}" | awk -F '[a-zA-Z]+' '{print $1}')
J_OPT=$(echo "\"-Xmx${M_SIZE}${M_EXT}\" \"-Xms$((M_SIZE/2))${M_EXT}\"")
JJ=$(echo JAVA_OPTS="${J_OPT}")
if [ -z $(docker ps | grep "bistro-competition") -n ]; then
docker rm beam-competition >> /dev/null
fi
docker run -it --memory="${MEMORY}" --cpus="${CPUS}" --name=bistro-competition -v "${INPUT}":/submission-inputs:ro -v $PWD/output:/output:rw -e "${JJ}" beammodel/beam-competition:0.0.3-SNAPSHOT --scenario "${SCENARIO}" --sample-size "${SIZE}" --iters "${ITERS}"