Improve the event messaging for training service
This commit is contained in:
@@ -61,7 +61,16 @@ class TrainingService:
|
||||
|
||||
logger.info(f"Starting training job {job_id} for tenant {tenant_id}")
|
||||
|
||||
from app.services.messaging import TrainingStatusPublisher
|
||||
status_publisher = TrainingStatusPublisher(job_id, tenant_id)
|
||||
|
||||
try:
|
||||
|
||||
await status_publisher.job_started({
|
||||
"bakery_location": bakery_location,
|
||||
"has_custom_dates": bool(requested_start or requested_end)
|
||||
}, 0) # Will be updated when we know product count
|
||||
|
||||
# Step 1: Prepare training dataset with date alignment and orchestration
|
||||
logger.info("Step 1: Preparing and aligning training data")
|
||||
training_dataset = await self.orchestrator.prepare_training_data(
|
||||
@@ -101,10 +110,12 @@ class TrainingService:
|
||||
}
|
||||
|
||||
logger.info(f"Training job {job_id} completed successfully")
|
||||
await status_publisher.job_completed(final_result)
|
||||
return TrainingService.create_detailed_training_response(final_result)
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Training job {job_id} failed: {str(e)}")
|
||||
await status_publisher.job_failed(str(e))
|
||||
# Return error response in same detailed format
|
||||
final_result = {
|
||||
"job_id": job_id,
|
||||
|
||||
Reference in New Issue
Block a user