-
Notifications
You must be signed in to change notification settings - Fork 0
/
nomad.sh
30 lines (25 loc) · 1.14 KB
/
nomad.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
#!/bin/bash
# This is the file that is ran from Nomad, when we launch a "try-it" job from PAPI
DURATION="${DURATION:-10m}"
UI_PORT="${UI_PORT:-8888}"
# Processing video with Gradio requires ffmpeg
apt-get update
apt install ffmpeg --yes
git clone -b nomad https://github.com/ai4os/deepaas_ui
cd deepaas_ui
# Defaut installation leads to:
# ```
# ERROR: Cannot uninstall 'blinker'. It is a distutils installed project and
# thus we cannot accurately determine which files belong to it which
# would lead to only a partial uninstall.
# ```
# So we need to add the ignore flag.
# https://stackoverflow.com/questions/53807511/pip-cannot-uninstall-package-it-is-a-distutils-installed-project
pip install -r requirements.txt --ignore-installed blinker
nohup deep-start --deepaas &
# sleep 10s to let `deepaas` start before launching the UI
sleep 10
# Use timeout to automatically kill the job after a given duration
# We capture the timeout exit code (124) to return 0 instead, so that the task does not restart (job_type=batch)
echo "Launching Gradio UI ..."
timeout ${DURATION} python launch.py --api_url http://0.0.0.0:5000/ --ui_port ${UI_PORT} || [[ $? -eq 124 ]]