Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
| """ | |
| 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() | |