-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentrypoint.py
More file actions
38 lines (30 loc) · 1.18 KB
/
entrypoint.py
File metadata and controls
38 lines (30 loc) · 1.18 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
"""Entry point for Databricks Apps."""
import sys
import os
import logging
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(message)s")
logger = logging.getLogger(__name__)
logger.info("Starting app.py entry point")
logger.info("Python: %s", sys.version)
logger.info("CWD: %s", os.getcwd())
logger.info("DATABRICKS_HOST: %s", os.getenv("DATABRICKS_HOST", "NOT SET"))
# Add backend/ to Python path
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "backend"))
logger.info("Python path updated, importing FastAPI app...")
try:
from app.main import app # noqa: E402, F401
logger.info("FastAPI app imported successfully")
except Exception as exc:
import_error = f"{type(exc).__name__}: {exc}"
logger.error("Failed to import app: %s", import_error, exc_info=True)
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
def root():
return {"error": import_error, "status": "import_failed"}
@app.get("/api/health")
def health():
return {"status": "degraded", "error": import_error}
@app.get("/api/v1/health")
def health_v1():
return {"status": "degraded", "error": import_error}