REFACTOR ALL APIs
This commit is contained in:
@@ -37,12 +37,12 @@ class TrainingServiceClient(BaseServiceClient):
|
||||
"min_data_points": min_data_points,
|
||||
**kwargs
|
||||
}
|
||||
return await self.post("jobs", data=data, tenant_id=tenant_id)
|
||||
return await self.post("training/jobs", data=data, tenant_id=tenant_id)
|
||||
|
||||
async def get_training_job(self, tenant_id: str, job_id: str) -> Optional[Dict[str, Any]]:
|
||||
"""Get training job details"""
|
||||
return await self.get(f"jobs/{job_id}", tenant_id=tenant_id)
|
||||
|
||||
return await self.get(f"training/jobs/{job_id}/status", tenant_id=tenant_id)
|
||||
|
||||
async def list_training_jobs(
|
||||
self,
|
||||
tenant_id: str,
|
||||
@@ -53,13 +53,13 @@ class TrainingServiceClient(BaseServiceClient):
|
||||
params = {"limit": limit}
|
||||
if status:
|
||||
params["status"] = status
|
||||
|
||||
result = await self.get("jobs", tenant_id=tenant_id, params=params)
|
||||
|
||||
result = await self.get("training/jobs", tenant_id=tenant_id, params=params)
|
||||
return result.get("jobs", []) if result else None
|
||||
|
||||
|
||||
async def cancel_training_job(self, tenant_id: str, job_id: str) -> Optional[Dict[str, Any]]:
|
||||
"""Cancel a training job"""
|
||||
return await self.delete(f"jobs/{job_id}", tenant_id=tenant_id)
|
||||
return await self.delete(f"training/jobs/{job_id}", tenant_id=tenant_id)
|
||||
|
||||
# ================================================================
|
||||
# MODELS
|
||||
@@ -67,7 +67,7 @@ class TrainingServiceClient(BaseServiceClient):
|
||||
|
||||
async def get_model(self, tenant_id: str, model_id: str) -> Optional[Dict[str, Any]]:
|
||||
"""Get model details"""
|
||||
return await self.get(f"models/{model_id}", tenant_id=tenant_id)
|
||||
return await self.get(f"training/models/{model_id}", tenant_id=tenant_id)
|
||||
|
||||
async def list_models(
|
||||
self,
|
||||
@@ -83,7 +83,7 @@ class TrainingServiceClient(BaseServiceClient):
|
||||
if model_type:
|
||||
params["model_type"] = model_type
|
||||
|
||||
result = await self.get("models", tenant_id=tenant_id, params=params)
|
||||
result = await self.get("training/models", tenant_id=tenant_id, params=params)
|
||||
return result.get("models", []) if result else None
|
||||
|
||||
async def get_active_model_for_product(
|
||||
@@ -95,16 +95,16 @@ class TrainingServiceClient(BaseServiceClient):
|
||||
Get the active model for a specific product by inventory product ID
|
||||
This is the preferred method since models are stored per product.
|
||||
"""
|
||||
result = await self.get(f"models/{inventory_product_id}/active", tenant_id=tenant_id)
|
||||
result = await self.get(f"training/models/{inventory_product_id}/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"""
|
||||
return await self.post(f"models/{model_id}/deploy", data={}, tenant_id=tenant_id)
|
||||
return await self.post(f"training/models/{model_id}/deploy", data={}, tenant_id=tenant_id)
|
||||
|
||||
async def delete_model(self, tenant_id: str, model_id: str) -> Optional[Dict[str, Any]]:
|
||||
"""Delete a model"""
|
||||
return await self.delete(f"models/{model_id}", tenant_id=tenant_id)
|
||||
return await self.delete(f"training/models/{model_id}", tenant_id=tenant_id)
|
||||
|
||||
# ================================================================
|
||||
# MODEL METRICS & PERFORMANCE
|
||||
@@ -112,7 +112,7 @@ class TrainingServiceClient(BaseServiceClient):
|
||||
|
||||
async def get_model_metrics(self, tenant_id: str, model_id: str) -> Optional[Dict[str, Any]]:
|
||||
"""Get model performance metrics"""
|
||||
return await self.get(f"models/{model_id}/metrics", tenant_id=tenant_id)
|
||||
return await self.get(f"training/models/{model_id}/metrics", tenant_id=tenant_id)
|
||||
|
||||
async def get_model_predictions(
|
||||
self,
|
||||
@@ -128,5 +128,5 @@ class TrainingServiceClient(BaseServiceClient):
|
||||
if end_date:
|
||||
params["end_date"] = end_date
|
||||
|
||||
result = await self.get(f"models/{model_id}/predictions", tenant_id=tenant_id, params=params)
|
||||
result = await self.get(f"training/models/{model_id}/predictions", tenant_id=tenant_id, params=params)
|
||||
return result.get("predictions", []) if result else None
|
||||
Reference in New Issue
Block a user