-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_dashboard.sh
More file actions
executable file
·59 lines (55 loc) · 1.74 KB
/
run_dashboard.sh
File metadata and controls
executable file
·59 lines (55 loc) · 1.74 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
#!/usr/bin/env bash
# Start the SWC Slurm Dashboard (Streamlit) safely for local or tunnel use.
#
# Usage:
# ./run_dashboard.sh # pick first free port in 8501–8510
# ./run_dashboard.sh 8765 # explicit custom port
#
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
if [[ -n "${1:-}" ]]; then
PORT="$1"
else
# Try to find the first free port in 8501–8510.
PORT="$(
python - <<'PY'
import socket
for port in range(8501, 8511):
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
try:
s.bind(("0.0.0.0", port))
except OSError:
continue
print(port)
break
else:
raise SystemExit("No free port found in 8501-8510")
PY
)"
fi
HOSTNAME="$(hostname)"
USER_NAME="${USER}"
LOCAL_PORT="${PORT}" # default: use same port locally; change if busy on your laptop
echo "============================================================"
echo " SWC Slurm Dashboard is starting"
echo "============================================================"
echo "Host (this node): ${USER_NAME}@${HOSTNAME}"
echo "Portal port: ${PORT}"
echo
echo "From your LAPTOP, run this in a NEW terminal:"
echo
echo " ssh -J ${USER_NAME}@ssh.swc.ucl.ac.uk ${USER_NAME}@${HOSTNAME} -N -L ${LOCAL_PORT}:127.0.0.1:${PORT}"
echo
echo "If ${LOCAL_PORT} is already in use on your laptop, change the first number"
echo "in the -L argument (before the colon) and use that instead below."
echo
echo "Then in your browser, open:"
echo
echo " http://localhost:${LOCAL_PORT}"
echo "============================================================"
echo
exec streamlit run swc_slurm_dashboard.py \
--server.port "$PORT" \
--server.address 0.0.0.0 \
--browser.gatherUsageStats false