Checking onboardin flow - fix 2
This commit is contained in:
@@ -57,17 +57,18 @@ async def start_training_job(
|
||||
"""Start a new training job for all products"""
|
||||
try:
|
||||
|
||||
tenant_id_str = str(tenant_id)
|
||||
new_job_id = str(uuid4())
|
||||
|
||||
logger.info("Starting training job",
|
||||
tenant_id=tenant_id,
|
||||
tenant_id=tenant_id_str,
|
||||
job_id=uuid4(),
|
||||
config=request.dict())
|
||||
|
||||
# Create training job
|
||||
job = await training_service.create_training_job(
|
||||
db, # Pass db here
|
||||
tenant_id=tenant_id,
|
||||
tenant_id=tenant_id_str,
|
||||
job_id=new_job_id,
|
||||
config=request.dict()
|
||||
)
|
||||
@@ -76,7 +77,7 @@ async def start_training_job(
|
||||
try:
|
||||
await publish_job_started(
|
||||
job_id=new_job_id,
|
||||
tenant_id=tenant_id,
|
||||
tenant_id=tenant_id_str,
|
||||
config=request.dict()
|
||||
)
|
||||
except Exception as e:
|
||||
@@ -99,7 +100,7 @@ async def start_training_job(
|
||||
job_id=job.job_id,
|
||||
status=TrainingStatus.PENDING,
|
||||
message="Training job created successfully",
|
||||
tenant_id=tenant_id,
|
||||
tenant_id=tenant_id_str,
|
||||
created_at=job.created_at,
|
||||
estimated_duration_minutes=30
|
||||
)
|
||||
@@ -107,7 +108,7 @@ async def start_training_job(
|
||||
except Exception as e:
|
||||
logger.error("Failed to start training job",
|
||||
error=str(e),
|
||||
tenant_id=tenant_id)
|
||||
tenant_id=str(tenant_id))
|
||||
raise HTTPException(status_code=500, detail=f"Failed to start training job: {str(e)}")
|
||||
|
||||
@router.get("/tenants/{tenant_id}/training/jobs", response_model=List[TrainingJobResponse])
|
||||
@@ -121,14 +122,17 @@ async def get_training_jobs(
|
||||
):
|
||||
"""Get training jobs for tenant"""
|
||||
try:
|
||||
|
||||
tenant_id_str = str(tenant_id)
|
||||
|
||||
logger.debug("Getting training jobs",
|
||||
tenant_id=tenant_id,
|
||||
tenant_id=tenant_id_str,
|
||||
status=status,
|
||||
limit=limit,
|
||||
offset=offset)
|
||||
|
||||
jobs = await training_service.get_training_jobs(
|
||||
tenant_id=tenant_id,
|
||||
tenant_id=tenant_id_str,
|
||||
status=status,
|
||||
limit=limit,
|
||||
offset=offset
|
||||
@@ -136,14 +140,14 @@ async def get_training_jobs(
|
||||
|
||||
logger.debug("Retrieved training jobs",
|
||||
count=len(jobs),
|
||||
tenant_id=tenant_id)
|
||||
tenant_id=tenant_id_str)
|
||||
|
||||
return jobs
|
||||
|
||||
except Exception as e:
|
||||
logger.error("Failed to get training jobs",
|
||||
error=str(e),
|
||||
tenant_id=tenant_id)
|
||||
tenant_id=str(tenant_id))
|
||||
raise HTTPException(status_code=500, detail=f"Failed to get training jobs: {str(e)}")
|
||||
|
||||
@router.get("/tenants/{tenant_id}/training/jobs/{job_id}", response_model=TrainingJobResponse)
|
||||
@@ -155,9 +159,12 @@ async def get_training_job(
|
||||
):
|
||||
"""Get specific training job details"""
|
||||
try:
|
||||
|
||||
tenant_id_str = str(tenant_id)
|
||||
|
||||
logger.debug("Getting training job",
|
||||
job_id=job_id,
|
||||
tenant_id=tenant_id)
|
||||
tenant_id=tenant_id_str)
|
||||
|
||||
job = await training_service.get_training_job(job_id)
|
||||
|
||||
@@ -165,7 +172,7 @@ async def get_training_job(
|
||||
if job.tenant_id != tenant_id:
|
||||
logger.warning("Unauthorized job access attempt",
|
||||
job_id=job_id,
|
||||
tenant_id=tenant_id,
|
||||
tenant_id=str(tenant_id),
|
||||
job_tenant_id=job.tenant_id)
|
||||
raise HTTPException(status_code=404, detail="Job not found")
|
||||
|
||||
@@ -188,13 +195,16 @@ async def get_training_progress(
|
||||
):
|
||||
"""Get real-time training progress"""
|
||||
try:
|
||||
|
||||
tenant_id_str = str(tenant_id)
|
||||
|
||||
logger.debug("Getting training progress",
|
||||
job_id=job_id,
|
||||
tenant_id=tenant_id)
|
||||
tenant_id=tenant_id_str)
|
||||
|
||||
# Verify job belongs to tenant
|
||||
job = await training_service.get_training_job(job_id)
|
||||
if job.tenant_id != tenant_id:
|
||||
if job.tenant_id != tenant_id_str:
|
||||
raise HTTPException(status_code=404, detail="Job not found")
|
||||
|
||||
progress = await training_service.get_job_progress(job_id)
|
||||
|
||||
Reference in New Issue
Block a user