File size: 1,142 Bytes
61d29fc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""
Helper script to test Databricks Apps deployment locally.
Simulates the Databricks Apps environment.
"""
import os
import sys
import subprocess
from pathlib import Path

def main():
    """Run local test of Databricks App."""
    print("🧪 Testing Databricks App locally...\n")
    
    # Check if frontend is built
    static_dir = Path("api/static")
    if not static_dir.exists():
        print("❌ Frontend not built. Building now...")
        subprocess.run(["npm", "run", "build"], cwd="frontend", check=True)
        print("✅ Frontend built successfully\n")
    
    # Set environment variables
    env = os.environ.copy()
    env.update({
        "DATABRICKS_HOST": os.getenv("DATABRICKS_HOST", "http://localhost:8000"),
        "LOG_LEVEL": "INFO"
    })
    
    # Run uvicorn
    print("🚀 Starting application on http://localhost:8000\n")
    print("   API docs: http://localhost:8000/api/docs")
    print("   Web UI:   http://localhost:8000\n")
    
    subprocess.run(
        ["uvicorn", "api.app:app", "--host", "0.0.0.0", "--port", "8000", "--reload"],
        env=env
    )

if __name__ == "__main__":
    main()