Start fixing forecast service API 8

This commit is contained in:
Urtzi Alfaro
2025-07-29 18:12:06 +02:00
parent fe88b696c2
commit 322f1743eb
4 changed files with 19 additions and 18 deletions

View File

@@ -86,19 +86,17 @@ class TrainingServiceClient(BaseServiceClient):
result = await self.get("models", tenant_id=tenant_id, params=params)
return result.get("models", []) if result else None
async def get_latest_model(
async def get_active_model_for_product(
self,
tenant_id: str,
model_type: Optional[str] = None
product_name: str
) -> Optional[Dict[str, Any]]:
"""Get the latest trained model for a tenant"""
params = {"latest": "true"}
if model_type:
params["model_type"] = model_type
result = await self.get("models", tenant_id=tenant_id, params=params)
models = result.get("models", []) if result else []
return models[0] if models else None
"""
Get the active model for a specific product
This is the preferred method since models are stored per product.
"""
result = await self.get(f"models/{product_name}/active", tenant_id=tenant_id)
return result
async def deploy_model(self, tenant_id: str, model_id: str) -> Optional[Dict[str, Any]]:
"""Deploy a trained model"""