Start fixing forecast service API 8
This commit is contained in:
@@ -89,8 +89,8 @@ app.add_middleware(
|
||||
)
|
||||
|
||||
# Include API routers
|
||||
app.include_router(forecasts.router, prefix="/api/v1/forecasts", tags=["forecasts"])
|
||||
app.include_router(predictions.router, prefix="/api/v1/predictions", tags=["predictions"])
|
||||
app.include_router(forecasts.router, prefix="/api/v1", tags=["forecasts"])
|
||||
app.include_router(predictions.router, prefix="/api/v1", tags=["predictions"])
|
||||
|
||||
@app.get("/health")
|
||||
async def health_check():
|
||||
|
||||
@@ -129,7 +129,7 @@ class ForecastingService:
|
||||
except Exception as e:
|
||||
logger.error("Error generating forecast",
|
||||
error=str(e),
|
||||
tenant_id=request.tenant_id,
|
||||
tenant_id=tenant_id,
|
||||
product=request.product_name)
|
||||
raise
|
||||
|
||||
@@ -247,11 +247,13 @@ class ForecastingService:
|
||||
|
||||
async def _get_latest_model(self, tenant_id: str, product_name: str) -> Optional[Dict[str, Any]]:
|
||||
"""Get the latest trained model for a tenant/product combination"""
|
||||
|
||||
try:
|
||||
model_data = await self.model_client.get_best_model_for_forecasting(tenant_id, product_name)
|
||||
# Pass the product_name to the model client
|
||||
model_data = await self.model_client.get_best_model_for_forecasting(
|
||||
tenant_id=tenant_id,
|
||||
product_name=product_name # Make sure to pass product_name
|
||||
)
|
||||
return model_data
|
||||
|
||||
except Exception as e:
|
||||
logger.error("Error getting latest model", error=str(e))
|
||||
raise
|
||||
|
||||
@@ -64,9 +64,10 @@ class ModelClient:
|
||||
"""
|
||||
try:
|
||||
# Get latest model
|
||||
latest_model = await self.clients.training.get_latest_model(
|
||||
latest_model = await self.clients.training.get_active_model_for_product(
|
||||
tenant_id=tenant_id,
|
||||
model_type="forecasting"
|
||||
model_type="forecasting",
|
||||
product_name=product_id
|
||||
)
|
||||
|
||||
if not latest_model:
|
||||
|
||||
Reference in New Issue
Block a user