-
-
Notifications
You must be signed in to change notification settings - Fork 152
/
cli.sh
48 lines (37 loc) · 1.08 KB
/
cli.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
#!/bin/bash
need_build=false
need_container=false
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
if [ "$1" = "clean" ]; then
docker stop luxai_runner
docker rmi luxai
exit
fi
if [[ "$(docker images -q luxai 2> /dev/null)" == "" ]]; then
need_build=true
fi
if [[ "$(docker ps | grep -w "luxai_runner")" == "" ]]; then
need_container=true
fi
setup () {
if [ $need_build = true ]; then
if test -f "Dockerfile"; then
echo "Using local Dockerfile"
docker build -t luxai .
else
echo "Using local hosted Dockerfile"
docker build -t luxai https://github.com/Lux-AI-Challenge/Lux-Design-2021/raw/master/Dockerfile
fi
fi
if [ $need_container = true ]; then
container_id=$(docker run -it -d --name luxai_runner -v $(pwd)/:/root --rm luxai bash)
echo Started runner container $container_id
fi
}
run () {
# example main.py main.py --out=replays/out.json
# NOTE, to use --out, you must pick replays as the folder or else it won't be copied over.
docker exec -w /root luxai_runner lux-ai-2021 $@
}
setup
run $@