""" DLH Data Lakehouse - Dynamic Pipeline & Storage API Modular Entrypoint with FastAPI """ import logging from fastapi import FastAPI from fastapi.middleware.cors import CORSMiddleware from app.core.config import settings from app.routers import api_v1_router, legacy_router from app.schemas.pipeline import DeployRequest, DraftRequest from app.schemas.connection import ConnectionTestRequest, CustomConnectionRequest from app.services.pipeline_parser import parse_yaml_to_pipeline_dict from app.services.metadb_service import save_connection_to_metadb from app.services.dbt_service import sync_dbt_models_from_nodes # Configure root logger logging.basicConfig( level=logging.INFO, format="%(asctime)s [%(levelname)s] %(name)s: %(message)s" ) logger = logging.getLogger(__name__) # Module-level variable exports for backward compatibility with existing scripts CONFIGS_DIR = settings.CONFIGS_DIR UPLOADS_DIR = settings.UPLOADS_DIR DOCS_DIR = settings.DOCS_DIR DBT_DIR = settings.DBT_DIR # FastAPI Application Factory / Instance app = FastAPI( title=settings.PROJECT_NAME, version=settings.VERSION, description="Modular FastAPI Backend for MERICA Studio, Dynamic Lakehouse YAML Generation, and Airflow 3 DAG Bundles." ) # CORS Setup app.add_middleware( CORSMiddleware, allow_origins=settings.CORS_ORIGINS, allow_credentials=True, allow_methods=["*"], allow_headers=["*"], ) # Mount RESTful v1 Router and Canvas v0.1 Backward Compatibility Router app.include_router(api_v1_router) app.include_router(legacy_router) @app.get("/api/v1/health", tags=["System"], summary="System health check probe") def health_check(): """Health check probe endpoint.""" return { "status": "ok", "service": settings.PROJECT_NAME, "version": settings.VERSION } # Backward compatibility health check probes (hidden from OpenAPI schema) @app.get("/health", include_in_schema=False) @app.get("/api/health", include_in_schema=False) def legacy_health_check(): return health_check() # Exported symbols for python imports __all__ = [ "app", "settings", "CONFIGS_DIR", "UPLOADS_DIR", "DOCS_DIR", "DBT_DIR", "parse_yaml_to_pipeline_dict", "save_connection_to_metadb", "sync_dbt_models_from_nodes", "DeployRequest", "DraftRequest", "ConnectionTestRequest", "CustomConnectionRequest", ]