forked from dlabsai/mlflow-for-gcp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentry-point.sh
executable file
·53 lines (42 loc) · 1.64 KB
/
entry-point.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
#!/usr/bin/env bash
set -e
# Verify that all required variables are set
if [[ -z "${GCP_PROJECT}" ]]; then
echo "Error: GCP_PROJECT not set"
exit 1
fi
# Fetch secrets from Secret Manager in CGP
export MLFLOW_TRACKING_USERNAME="$(python3 /app/get_secret.py --project="${GCP_PROJECT}" --secret=mlflow_tracking_username)"
export MLFLOW_TRACKING_PASSWORD="$(python3 /app/get_secret.py --project="${GCP_PROJECT}" --secret=mlflow_tracking_password)"
export ARTIFACT_URL="$(python3 /app/get_secret.py --project="${GCP_PROJECT}" --secret=mlflow_artifact_url)"
if [[ -z "${DATABASE_URL}" ]]; then # Allow overriding for local deployment
export DATABASE_URL="$(python3 /app/get_secret.py --project="${GCP_PROJECT}" --secret=mlflow_database_url)"
fi
# Verify that all required variables are set
if [[ -z "${MLFLOW_TRACKING_USERNAME}" ]]; then
echo "Error: MLFLOW_TRACKING_USERNAME not set"
exit 1
fi
if [[ -z "${MLFLOW_TRACKING_PASSWORD}" ]]; then
echo "Error: MLFLOW_TRACKING_PASSWORD not set"
exit 1
fi
if [[ -z "${ARTIFACT_URL}" ]]; then
echo "Error: ARTIFACT_URL not set"
exit 1
fi
if [[ -z "${DATABASE_URL}" ]]; then
echo "Error: DATABASE_URL not set"
exit 1
fi
if [[ -z "${PORT}" ]]; then
export PORT=8080
fi
if [[ -z "${HOST}" ]]; then
export HOST=0.0.0.0
fi
export WSGI_AUTH_CREDENTIALS="${MLFLOW_TRACKING_USERNAME}:${MLFLOW_TRACKING_PASSWORD}"
export _MLFLOW_SERVER_ARTIFACT_ROOT="${ARTIFACT_URL}"
export _MLFLOW_SERVER_FILE_STORE="${DATABASE_URL}"
# Start MLflow and ngingx using supervisor
exec gunicorn -b "${HOST}:${PORT}" -w 4 --log-level debug --access-logfile=- --error-logfile=- --log-level=debug mlflow_auth:app