forked from openmsa/python-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtraining_container
More file actions
executable file
·67 lines (55 loc) · 1.26 KB
/
training_container
File metadata and controls
executable file
·67 lines (55 loc) · 1.26 KB
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
#!/bin/bash
usage() {
echo './training_container [start|stop|build]'
exit 0
}
if [ -z "$1" ]; then
usage
fi
DOCKER_ID_FILE='running_container_id'
stop() {
if [ ! -f "${DOCKER_ID_FILE}" ]; then
echo 'Training notebooks does not seem to be running... Nothing to stop'
exit 0
fi
docker stop "$(cat ${DOCKER_ID_FILE})"
rm "${DOCKER_ID_FILE}"
}
start() {
if [ -f "${DOCKER_ID_FILE}" ]; then
echo 'Training notebooks is alreay running...'
echo "If not, please delete ${DOCKER_ID_FILE} and run start again."
exit 0
fi
DOCKER_ID=$(docker run --rm -u $UID \
-p 8888:8888 \
-v "$PWD/notebooks:/notebooks" \
-d \
training-notebooks start-notebook.sh \
--NotebookApp.notebook_dir=/notebooks)
echo "${DOCKER_ID}" > "${DOCKER_ID_FILE}"
echo 'Open http://127.0.0.1:8888 in your browser'
}
interactive(){
docker run --rm -it --name train-ntbs-interac training-notebooks ipython
}
build() {
docker build -t training-notebooks .
}
case "$1" in
"start"*)
start
;;
"stop"*)
stop
;;
"build"*)
build
;;
"ipython"*)
interactive
;;
*)
usage
;;
esac