From c9544fc5e70e5a665e3056626c5e6474c5976ec4 Mon Sep 17 00:00:00 2001 From: Xi Bai Date: Mon, 27 Jan 2025 17:33:08 +0000 Subject: [PATCH] resolve merging conflicts --- app/api/routers/evaluation.py | 2 +- app/api/routers/training_operations.py | 35 +++++++++++++++++--------- pyproject.toml | 2 +- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/app/api/routers/evaluation.py b/app/api/routers/evaluation.py index e5a21fb..5459fe1 100644 --- a/app/api/routers/evaluation.py +++ b/app/api/routers/evaluation.py @@ -3,7 +3,7 @@ import uuid import tempfile -from typing import List +from typing import List, Union from typing_extensions import Annotated from fastapi import APIRouter, Query, Depends, UploadFile, Request, File from fastapi.responses import StreamingResponse, JSONResponse diff --git a/app/api/routers/training_operations.py b/app/api/routers/training_operations.py index 3d2ab0d..53de686 100644 --- a/app/api/routers/training_operations.py +++ b/app/api/routers/training_operations.py @@ -3,7 +3,7 @@ import sys import tempfile import uuid -from typing import List +from typing import List, Union from typing_extensions import Annotated from fastapi import APIRouter, Depends, Request, Query, UploadFile, File from fastapi.responses import JSONResponse @@ -19,6 +19,7 @@ from utils import filter_by_concept_ids import api.globals as cms_globals +from api.dependencies import validate_tracking_id from model_services.base import AbstractModelService router = APIRouter() @@ -41,12 +42,13 @@ def train_eval_info(request: Request, @router.post("/evaluate", - tags=[Tags.Training.name], + tags=[Tags.Evaluating.name], response_class=JSONResponse, dependencies=[Depends(cms_globals.props.current_active_user)], description="Evaluate the model being served with a trainer export") async def get_evaluation_with_trainer_export(request: Request, trainer_export: Annotated[List[UploadFile], File(description="One or more trainer export files to be uploaded")], + tracking_id: Union[str, None] = Depends(validate_tracking_id), model_service: AbstractModelService = Depends(cms_globals.model_service_dep)) -> JSONResponse: files = [] file_names = [] @@ -67,18 +69,27 @@ async def get_evaluation_with_trainer_export(request: Request, json.dump(concatenated, data_file) data_file.flush() data_file.seek(0) - evaluation_id = str(uuid.uuid4()) - evaluation_accepted = model_service.train_supervised(data_file, - 0, - sys.maxsize, - evaluation_id, - ",".join(file_names)) + evaluation_id = tracking_id or str(uuid.uuid4()) + evaluation_accepted, experiment_id, run_id = model_service.train_supervised( + data_file, 0, sys.maxsize, evaluation_id, ",".join(file_names) + ) if evaluation_accepted: - return JSONResponse(content={"message": "Your evaluation started successfully.", "evaluation_id": evaluation_id}, - status_code=HTTP_202_ACCEPTED) + return JSONResponse( + content={ + "message": "Your evaluation started successfully.", + "evaluation_id": evaluation_id, + "experiment_id": experiment_id, + "run_id": run_id, + }, status_code=HTTP_202_ACCEPTED + ) else: - return JSONResponse(content={"message": "Another training or evaluation on this model is still active. Please retry later."}, - status_code=HTTP_503_SERVICE_UNAVAILABLE) + return JSONResponse( + content={ + "message": "Another training or evaluation on this model is still active. Please retry later.", + "experiment_id": experiment_id, + "run_id": run_id, + }, status_code=HTTP_503_SERVICE_UNAVAILABLE + ) @router.post("/cancel_training", diff --git a/pyproject.toml b/pyproject.toml index 79bef0b..f298e9e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -63,7 +63,7 @@ dev = [ "httpx~=0.24.1", "mypy==1.8.0", "ruff==0.6.9", - "locust~=2.31.8", + "locust<2.32.0", "typer-cli~=0.15.1", "types-toml==0.10.8.20240310", ]