code-review-fix task 15.3: replace datetime.utcnow() with datetime.now(timezone.utc) in main.py
This commit is contained in:
parent
9c08ffc44d
commit
059c436717
1 changed files with 7 additions and 7 deletions
|
|
@ -14,7 +14,7 @@ import uuid
|
|||
from contextlib import asynccontextmanager
|
||||
from pathlib import Path
|
||||
from typing import Optional, Dict, Any, List
|
||||
from datetime import datetime
|
||||
from datetime import datetime, timezone
|
||||
import json
|
||||
|
||||
import requests as http_requests
|
||||
|
|
@ -81,7 +81,7 @@ async def lifespan(app: FastAPI):
|
|||
.where(TrainingRun.status == "running")
|
||||
.values(
|
||||
status="failed",
|
||||
completed_at=datetime.utcnow(),
|
||||
completed_at=datetime.now(timezone.utc),
|
||||
metrics_summary={"error": "Service restarted while training was in progress"},
|
||||
)
|
||||
)
|
||||
|
|
@ -1226,7 +1226,7 @@ def _run_training_background(run_id: str, model_type: str, config: PipelineConfi
|
|||
.where(TrainingRun.run_id == run_id)
|
||||
.values(
|
||||
status="failed",
|
||||
completed_at=datetime.utcnow(),
|
||||
completed_at=datetime.now(timezone.utc),
|
||||
metrics_summary={
|
||||
"error": "Training timed out after 30 minutes"
|
||||
},
|
||||
|
|
@ -1268,7 +1268,7 @@ def _run_training_background(run_id: str, model_type: str, config: PipelineConfi
|
|||
"model": model_instance,
|
||||
"metadata": {
|
||||
"model_type": model_type,
|
||||
"trained_at": datetime.utcnow().isoformat(),
|
||||
"trained_at": datetime.now(timezone.utc).isoformat(),
|
||||
"run_id": run_id,
|
||||
"feature_columns": feature_cols,
|
||||
"labels": (
|
||||
|
|
@ -1288,7 +1288,7 @@ def _run_training_background(run_id: str, model_type: str, config: PipelineConfi
|
|||
.where(TrainingRun.run_id == run_id)
|
||||
.values(
|
||||
status="completed",
|
||||
completed_at=datetime.utcnow(),
|
||||
completed_at=datetime.now(timezone.utc),
|
||||
metrics_summary=metrics,
|
||||
)
|
||||
)
|
||||
|
|
@ -1306,7 +1306,7 @@ def _run_training_background(run_id: str, model_type: str, config: PipelineConfi
|
|||
.where(TrainingRun.run_id == run_id)
|
||||
.values(
|
||||
status="failed",
|
||||
completed_at=datetime.utcnow(),
|
||||
completed_at=datetime.now(timezone.utc),
|
||||
metrics_summary={"error": str(exc)},
|
||||
)
|
||||
)
|
||||
|
|
@ -1368,7 +1368,7 @@ async def training_start(request: TrainingStartRequest):
|
|||
experiment_name=config.stages.training.mlflow.experiment_name,
|
||||
pipeline_config_hash=config_hash,
|
||||
status="running",
|
||||
created_at=datetime.utcnow(),
|
||||
created_at=datetime.now(timezone.utc),
|
||||
metrics_summary={},
|
||||
)
|
||||
db.add(training_run)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue