-
Notifications
You must be signed in to change notification settings - Fork 0
/
score_algos.sh
77 lines (54 loc) · 1.63 KB
/
score_algos.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
73
74
75
76
77
#! /usr/bin/bash
unset image
unset algo
unset volume
while getopts i:a:v: flag
do
case "${flag}" in
i) image=${OPTARG};;
a) algo=${OPTARG};;
v) volume=${OPTARG};;
*)
echo 'Error in command line parsing' >&2
exit 1
esac
done
shift "$(( OPTIND - 1 ))"
if [ -z "$image" ] ; then
echo 'Error: Missing -i flag for image to pull' >&2
exit 1
fi
if [ -z "$algo" ] ; then
echo 'Error: Missing -a flag for algo to pull' >&2
exit 1
fi
if [ -z "$volume" ]; then
echo 'Error: Missing -v flag for volume name' >&2
exit 1
fi
# echo "image: $image";
# echo "algo: $algo";
# echo "volume: $volume";
#---------------------------------------------------------------------------
host_vol_path="$(pwd)/${volume}"
container_vol_path="/app/${volume}"
echo "host_vol_path: $host_vol_path"
echo "container_vol_path: $container_vol_path"
container_name="$algo"
# stop and remove container if it exists
docker stop $container_name || true && docker rm $container_name || true
# now run the container
docker run -d -p 3000:3000 -v $host_vol_path:$container_vol_path --name $container_name $image
# run training
docker exec $container_name python train.py
#run test predictions
docker exec $container_name python predict.py
#run scoring
docker exec $container_name python score.py
#---------------------------------------------------------------------------
# stop and remove the container
docker stop $container_name
docker rm $container_name
# # remove the image
# docker rmi $image
#---------------------------------------------------------------------------