-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathrun_app_local.sh
More file actions
executable file
Β·159 lines (136 loc) Β· 5.06 KB
/
run_app_local.sh
File metadata and controls
executable file
Β·159 lines (136 loc) Β· 5.06 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#!/bin/bash
# Run the Databricks App locally for debugging
# This helps debug deployment issues by running the app locally with debug mode
# Usage: ./run_app_local.sh [--verbose]
set -e
# Parse command line arguments
VERBOSE=false
if [[ "$1" == "--verbose" ]]; then
VERBOSE=true
echo "π Verbose mode enabled"
fi
# Function to print timing info
print_timing() {
if [ "$VERBOSE" = true ]; then
echo "β±οΈ $(date '+%H:%M:%S') - $1"
fi
}
# Load environment variables from .env.local if it exists
print_timing "Loading environment variables"
if [ -f .env.local ]; then
set -a
source .env.local
set +a
fi
# Validate required configuration
if [ -z "$DATABRICKS_APP_NAME" ]; then
echo "β DATABRICKS_APP_NAME is not set. Please run ./setup.sh first."
exit 1
fi
if [ -z "$DATABRICKS_AUTH_TYPE" ]; then
echo "β DATABRICKS_AUTH_TYPE is not set. Please run ./setup.sh first."
exit 1
fi
if [ -z "$DBA_SOURCE_CODE_PATH" ]; then
echo "β DBA_SOURCE_CODE_PATH is not set. Please run ./setup.sh first."
exit 1
fi
# Handle authentication based on type
print_timing "Starting authentication"
echo "π Authenticating with Databricks..."
if [ "$DATABRICKS_AUTH_TYPE" = "pat" ]; then
# PAT Authentication
if [ -z "$DATABRICKS_HOST" ] || [ -z "$DATABRICKS_TOKEN" ]; then
echo "β PAT authentication requires DATABRICKS_HOST and DATABRICKS_TOKEN. Please run ./setup.sh first."
exit 1
fi
echo "Using Personal Access Token authentication"
export DATABRICKS_HOST="$DATABRICKS_HOST"
export DATABRICKS_TOKEN="$DATABRICKS_TOKEN"
# Test connection
if ! databricks current-user me >/dev/null 2>&1; then
echo "β PAT authentication failed. Please check your credentials."
exit 1
fi
elif [ "$DATABRICKS_AUTH_TYPE" = "databricks-cli" ]; then
# Profile Authentication
if [ -z "$DATABRICKS_CONFIG_PROFILE" ]; then
echo "β Profile authentication requires DATABRICKS_CONFIG_PROFILE. Please run ./setup.sh first."
exit 1
fi
echo "Using profile authentication: $DATABRICKS_CONFIG_PROFILE"
# Test connection
if ! databricks current-user me --profile "$DATABRICKS_CONFIG_PROFILE" >/dev/null 2>&1; then
echo "β Profile authentication failed. Please check your profile configuration."
exit 1
fi
else
echo "β Invalid DATABRICKS_AUTH_TYPE: $DATABRICKS_AUTH_TYPE. Must be 'pat' or 'databricks-cli'."
exit 1
fi
echo "β
Databricks authentication successful"
print_timing "Authentication completed"
# Display app info
echo ""
echo "π Running Databricks App Locally for Debugging"
echo "π± App Name: $DATABRICKS_APP_NAME"
echo "π Source Path: $DBA_SOURCE_CODE_PATH"
echo ""
# Check if run-local command is available
print_timing "Checking CLI version"
if ! databricks apps run-local --help >/dev/null 2>&1; then
echo "β The 'databricks apps run-local' command is not available in your CLI version."
echo "π‘ You may need to update your Databricks CLI to use this feature."
echo ""
echo "To update the Databricks CLI:"
echo " # macOS/Linux with Homebrew:"
echo " brew upgrade databricks"
echo ""
echo " # Windows with WinGet:"
echo " winget upgrade databricks.databricks"
echo ""
echo " # Cross-platform with curl:"
echo " curl -fsSL https://raw.githubusercontent.com/databricks/setup-cli/main/install.sh | sh"
echo ""
echo "π See official installation docs: https://docs.databricks.com/aws/en/dev-tools/cli/install"
echo ""
echo "Current CLI version:"
databricks --version
echo ""
echo "Alternative debugging approaches:"
echo " 1. Use ./app_status.sh --verbose to check deployment status"
echo " 2. Visit your app URL + /logz in browser for deployment logs"
echo " 3. Check the workspace files are synced correctly"
echo " 4. Try redeploying with ./deploy.sh"
exit 1
fi
# Run the app locally with debug mode
print_timing "Starting local app run"
echo "π Running app locally with debug mode..."
echo "π‘ This will help identify deployment issues by running the app locally"
echo ""
if [ "$DATABRICKS_AUTH_TYPE" = "databricks-cli" ]; then
if [ "$VERBOSE" = true ]; then
echo "Running: databricks apps run-local --prepare-environment --debug --profile $DATABRICKS_CONFIG_PROFILE"
databricks apps run-local --prepare-environment --debug --profile "$DATABRICKS_CONFIG_PROFILE"
else
databricks apps run-local --prepare-environment --debug --profile "$DATABRICKS_CONFIG_PROFILE"
fi
else
if [ "$VERBOSE" = true ]; then
echo "Running: databricks apps run-local --prepare-environment --debug"
databricks apps run-local --prepare-environment --debug
else
databricks apps run-local --prepare-environment --debug
fi
fi
print_timing "Local app run completed"
echo ""
echo "β
Local app run completed!"
echo ""
echo "π‘ Useful next steps:"
echo " - Check the debug output above for any errors"
echo " - If the app runs locally but fails in deployment, check workspace sync"
echo " - Use ./app_status.sh --verbose to check deployment status"
echo " - Visit the app URL + /logz in browser for deployment logs"
echo " - Try deploying again with ./deploy.sh"