-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.sh
More file actions
executable file
·50 lines (40 loc) · 2.34 KB
/
start.sh
File metadata and controls
executable file
·50 lines (40 loc) · 2.34 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
#!/usr/bin/env bash
# ─────────────────────────────────────────────────────────────────────
# Databricks API Explorer — startup script (macOS / Linux)
# ─────────────────────────────────────────────────────────────────────
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
cd "$SCRIPT_DIR"
VENV_DIR=".venv"
PYTHON="${PYTHON:-python3}"
PORT="${DATABRICKS_APP_PORT:-8050}"
# ── Ensure Python is available ────────────────────────────────────────
if ! command -v "$PYTHON" &>/dev/null; then
echo "ERROR: $PYTHON not found. Install Python 3.11+ and try again."
exit 1
fi
PY_VERSION=$("$PYTHON" -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')")
PY_MAJOR=$("$PYTHON" -c "import sys; print(sys.version_info.major)")
PY_MINOR=$("$PYTHON" -c "import sys; print(sys.version_info.minor)")
if [ "$PY_MAJOR" -lt 3 ] || { [ "$PY_MAJOR" -eq 3 ] && [ "$PY_MINOR" -lt 11 ]; }; then
echo "ERROR: Python 3.11+ required (found $PY_VERSION)."
exit 1
fi
echo "Using Python $PY_VERSION"
# ── Create virtual environment if missing ─────────────────────────────
if [ ! -d "$VENV_DIR" ]; then
echo "Creating virtual environment..."
"$PYTHON" -m venv "$VENV_DIR"
fi
# ── Activate virtual environment ──────────────────────────────────────
source "$VENV_DIR/bin/activate"
# ── Install / update dependencies ─────────────────────────────────────
echo "Installing dependencies..."
pip install -q --upgrade pip
pip install -q -r requirements.txt
# ── Launch ────────────────────────────────────────────────────────────
echo ""
echo "Starting Databricks API Explorer on http://localhost:$PORT"
echo "Press Ctrl+C to stop."
echo ""
python app.py