Coverage for services/inference/src/main.py: 87%
30 statements
« prev ^ index » next coverage.py v7.11.0, created at 2025-10-25 16:18 +0000
« prev ^ index » next coverage.py v7.11.0, created at 2025-10-25 16:18 +0000
1from datetime import datetime
2from fastapi import FastAPI
3from fastapi.middleware.cors import CORSMiddleware
4from .config import settings
5from .models.health import HealthResponse
6from .routers import predict, analytics
8SERVICE_NAME = "inference"
9SERVICE_VERSION = "0.1.0"
10SERVICE_PORT = 8003
12app = FastAPI(title=f"Heimdall SDR - {SERVICE_NAME}", version=SERVICE_VERSION)
14app.add_middleware(CORSMiddleware, allow_origins=["*"], allow_credentials=True, allow_methods=["*"], allow_headers=["*"])
16# Include routers
17# app.include_router(predict.router) # Temporarily disabled
18app.include_router(analytics.router)
21@app.get("/api/v1/analytics/test")
22async def test_analytics():
23 return {"message": "Analytics router is working"}
26@app.get("/")
27async def root():
28 return {"service": SERVICE_NAME, "status": "running", "timestamp": datetime.utcnow().isoformat()}
31@app.get("/health")
32async def health_check():
33 return HealthResponse(status="healthy", service=SERVICE_NAME, version=SERVICE_VERSION, timestamp=datetime.utcnow())
36@app.get("/api/v1/inference/health")
37async def inference_health_check_public():
38 """Public health check endpoint - used by API Gateway and dashboard monitoring."""
39 return HealthResponse(status="healthy", service=SERVICE_NAME, version=SERVICE_VERSION, timestamp=datetime.utcnow())
42@app.get("/ready")
43async def readiness_check():
44 return {"ready": True}
47if __name__ == "__main__":
48 import uvicorn
49 uvicorn.run(app, host="0.0.0.0", port=SERVICE_PORT)