Start fixing forecast service API 5
This commit is contained in:
@@ -47,7 +47,7 @@ async def create_single_forecast(
|
||||
)
|
||||
|
||||
# Generate forecast
|
||||
forecast = await forecasting_service.generate_forecast(tenant_id, request, db)
|
||||
forecast = await forecasting_service.generate_forecast(request, db)
|
||||
|
||||
# Convert to response model
|
||||
return ForecastResponse(
|
||||
|
||||
@@ -108,7 +108,7 @@ async def health_check():
|
||||
@app.get("/metrics")
|
||||
async def get_metrics():
|
||||
"""Metrics endpoint for Prometheus"""
|
||||
return metrics_collector.generate_latest()
|
||||
return metrics_collector.get_metrics()
|
||||
|
||||
if __name__ == "__main__":
|
||||
import uvicorn
|
||||
|
||||
@@ -24,7 +24,12 @@ class ForecastRequest(BaseModel):
|
||||
"""Request schema for generating forecasts"""
|
||||
tenant_id: str = Field(..., description="Tenant ID")
|
||||
product_name: str = Field(..., description="Product name")
|
||||
forecast_date: date = Field(..., description="Date for which to generate forecast")
|
||||
forecast_date: date = Field(..., description="Starting date for forecast")
|
||||
forecast_days: int = Field(1, ge=1, le=30, description="Number of days to forecast")
|
||||
location: str = Field(..., description="Location identifier")
|
||||
|
||||
# Optional parameters - internally handled
|
||||
confidence_level: float = Field(0.8, ge=0.5, le=0.95, description="Confidence level")
|
||||
|
||||
@validator('forecast_date')
|
||||
def validate_forecast_date(cls, v):
|
||||
@@ -37,14 +42,7 @@ class BatchForecastRequest(BaseModel):
|
||||
tenant_id: str = Field(..., description="Tenant ID")
|
||||
batch_name: str = Field(..., description="Batch name for tracking")
|
||||
products: List[str] = Field(..., description="List of product names")
|
||||
location: str = Field(..., description="Location identifier")
|
||||
forecast_days: int = Field(7, ge=1, le=30, description="Number of days to forecast")
|
||||
business_type: BusinessType = Field(BusinessType.INDIVIDUAL, description="Business model type")
|
||||
|
||||
# Options
|
||||
include_weather: bool = Field(True, description="Include weather data")
|
||||
include_traffic: bool = Field(True, description="Include traffic data")
|
||||
confidence_level: float = Field(0.8, ge=0.5, le=0.95, description="Confidence level")
|
||||
|
||||
class ForecastResponse(BaseModel):
|
||||
"""Response schema for forecast results"""
|
||||
|
||||
@@ -249,7 +249,7 @@ class ForecastingService:
|
||||
"""Get the latest trained model for a tenant/product combination"""
|
||||
|
||||
try:
|
||||
model_data = await self.data_client.get_best_model_for_forecasting(tenant_id, product_name)
|
||||
model_data = await self.model_client.get_best_model_for_forecasting(tenant_id, product_name)
|
||||
return model_data
|
||||
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user