-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
executable file
·65 lines (52 loc) · 1.58 KB
/
run.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
#!/usr/bin/env bash
# Default parameters
BP_PATH="$HOME/BP"
VIS_PORT=8097
NGROK=false
while [[ $# -gt 0 ]]; do
key="$1"
case "$key" in
-p|--path)
BP_PATH="$2"
shift ; shift ;;
-v|--viz-port)
VIS_PORT="$2"
shift ; shift ;;
-n|--ngrok)
NGROK=true
shift ; shift ;;
*)
shift ;;
esac
done
# ENVIRONMENT VARIABLES
export BACHPROPAGATION_ROOT_PATH="$BP_PATH"
export PYTHONPATH="${PYTHONPATH}:$BP_PATH/src"
echo "> Exported ENV variables"
# VISDOM VISUALIZATION
if lsof -Pi :"$VIS_PORT" -sTCP:LISTEN -t >/dev/null ; then
while : ; do
printf "Visdom server already running, do you want to restart it? [Y/N]: "; read -r restart
[[ "$restart" == "Y" || "$restart" == "N" ]] && break
echo "> Invalid option, try again"
done
if [[ "$restart" = "Y" ]]; then
kill $(lsof -t -i:8097)
visdom -logging_level ERROR -port "$VIS_PORT" > /dev/null &
echo "> Restarted Visdom server"
fi
else
visdom -logging_level ERROR -port "$VIS_PORT" > /dev/null &
echo "> Started Visdom server"
fi
# NGROK TUNNELING
if [[ "$NGROK" == true ]] ; then
ngrok http "$VIS_PORT" > /dev/null &
echo "> Tunneling URL with Ngrok"
sleep 3
WEB_HOOK_URL=$(curl --silent --connect-timeout 10 http://localhost:4040/api/tunnels | \
pipenv run python -c "import json,sys;obj=json.load(sys.stdin);print(obj['tunnels'][0]['public_url'])")
echo "Visdom tunneled in $WEB_HOOK_URL"
fi
# RUN MODEL
pipenv run python src/main.py --viz