-
Notifications
You must be signed in to change notification settings - Fork 0
/
launch.sh
85 lines (71 loc) · 1.81 KB
/
launch.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
78
79
80
81
82
83
84
85
#!/bin/bash
image_name="ft_linear_regression"
container_name="ft_linear_regression"
if [ -z "$1" ]; then
help
fi
help() {
echo "Usage: $0 {setup|train|precise|predict|clean}"
exit 1
}
setup() {
echo "This script uses X11 forwarding to display the GUI outside the Docker container."
echo "Please ensure that your X11 server is running on your preferred host."
read -p "Is your X11 server ready? (yes/no): " x11_ready
if [ "$x11_ready" != "yes" ]; then
echo "Please start your X11 server and then run this script again."
exit 1
fi
read -p "Is your X11 server launched locally or remotely? (local/remote): " display_type
if [ "$display_type" = "local" ]; then
export IP=$(ifconfig en0 | grep inet | awk '$1=="inet" {print $2}')
elif [ "$display_type" = "remote" ]; then
read -p "Please enter the IP address of the host running the X11 server: " IP
else
echo "Invalid option: $display_type"
exit 1
fi
if ! docker image ls | grep "$image_name"; then
docker build -t "$image_name" .
fi
if ! docker container ls -a | grep "$container_name" ; then
docker run -d -it --rm -e DISPLAY="${IP}:0.0" --name "$container_name" -v ./src:/src "$image_name"
fi
}
clean() {
echo "Cleaning up the environment..."
docker stop "$container_name"
docker rmi "$image_name"
}
train () {
echo "Training Started..."
docker exec -it "$container_name" python3.10 /src/train.py
}
predict () {
echo "Predict Price..."
docker exec -it "$container_name" python3.10 /src/predict.py
}
precise () {
echo "Calculate the precision of my Algorithm..."
docker exec -it "$container_name" python3.10 /src/precision.py
}
case "$1" in
"setup")
setup
;;
"train")
train
;;
"predict")
predict
;;
"precise")
precise
;;
"clean")
clean
;;
*)
help
;;
esac