Fix issues 4

This commit is contained in:
Urtzi Alfaro
2025-08-17 15:21:10 +02:00
parent cafd316c4b
commit f33f5d242a
6 changed files with 255 additions and 45 deletions

View File

@@ -627,13 +627,14 @@ class EnhancedTrainingService:
"status": status or "pending",
"progress": progress or 0,
"current_step": current_step or "initializing",
"start_time": datetime.utcnow()
"start_time": datetime.now(timezone.utc)
}
if error_message:
log_data["error_message"] = error_message
if results:
log_data["results"] = results
# Ensure results are JSON-serializable before storing
log_data["results"] = make_json_serializable(results)
await self.training_log_repo.create_training_log(log_data)
logger.info("Created initial training log", job_id=job_id, tenant_id=tenant_id)
@@ -655,9 +656,10 @@ class EnhancedTrainingService:
if error_message:
update_data["error_message"] = error_message
if results:
update_data["results"] = results
# Ensure results are JSON-serializable before storing
update_data["results"] = make_json_serializable(results)
if status in ["completed", "failed"]:
update_data["end_time"] = datetime.utcnow()
update_data["end_time"] = datetime.now(timezone.utc)
if update_data:
await self.training_log_repo.update(existing_log.id, update_data)