|
6 | 6 | from typing import Annotated |
7 | 7 | from uuid import UUID |
8 | 8 |
|
9 | | -from fastapi import APIRouter, Body, Depends, Query, status |
| 9 | +from fastapi import APIRouter, Body, Depends, status |
10 | 10 | from fastapi.exceptions import HTTPException |
11 | 11 | from fastapi.openapi.models import Example |
12 | 12 | from starlette.responses import FileResponse |
13 | 13 |
|
14 | 14 | from app.api.dependencies import get_data_collector, get_label_service, get_project, get_project_id, get_project_service |
15 | | -from app.schemas import LabelView, PatchLabels, ProjectCreate, ProjectUpdateName, ProjectView, TrainingConfiguration |
| 15 | +from app.schemas import LabelView, PatchLabels, ProjectCreate, ProjectUpdateName, ProjectView |
16 | 16 | from app.services import ( |
17 | 17 | LabelService, |
18 | 18 | ProjectService, |
|
22 | 22 | ) |
23 | 23 | from app.services.data_collect import DataCollector |
24 | 24 | from app.services.label_service import DuplicateLabelsError |
25 | | -from app.supported_models.hyperparameters import Hyperparameters |
26 | 25 |
|
27 | 26 | router = APIRouter(prefix="/api/projects", tags=["Projects"]) |
28 | 27 |
|
@@ -277,82 +276,3 @@ def capture_next_pipeline_frame( |
277 | 276 | data_collector.collect_next_frame() |
278 | 277 | except ResourceNotFoundError as e: |
279 | 278 | raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail=str(e)) |
280 | | - |
281 | | - |
282 | | -@router.get( |
283 | | - "/{project_id}/training_configuration", |
284 | | - response_model=TrainingConfiguration, |
285 | | - responses={ |
286 | | - status.HTTP_200_OK: {"description": "Training configuration found"}, |
287 | | - status.HTTP_400_BAD_REQUEST: {"description": "Invalid project ID or query parameters"}, |
288 | | - status.HTTP_404_NOT_FOUND: {"description": "Project not found"}, |
289 | | - }, |
290 | | -) |
291 | | -def get_training_configuration( |
292 | | - project_id: Annotated[UUID, Depends(get_project_id)], |
293 | | - project_service: Annotated[ProjectService, Depends(get_project_service)], |
294 | | - model_architecture_id: Annotated[str | None, Query()] = None, |
295 | | - model_revision_id: Annotated[UUID | None, Query()] = None, |
296 | | -) -> TrainingConfiguration: |
297 | | - """ |
298 | | - Get the training configuration for a project. |
299 | | -
|
300 | | - - If model_architecture_id is provided, returns configuration for that specific model architecture. |
301 | | - - If model_revision_id is provided, returns configuration for a specific trained model. |
302 | | - - If neither is provided, returns only general task-related configuration. |
303 | | - Note: model_architecture_id and model_revision_id cannot be used together. |
304 | | -
|
305 | | - Args: |
306 | | - project_id (UUID): The unique identifier of the project. |
307 | | - project_service (ProjectService): The project service |
308 | | - model_architecture_id (Optional[str]): The model architecture ID for specific configuration retrieval. |
309 | | - model_revision_id (Optional[UUID]): The model revision ID for specific configuration retrieval. |
310 | | -
|
311 | | - Returns: |
312 | | - TrainingConfiguration: The training configuration details. |
313 | | - """ |
314 | | - try: |
315 | | - # TODO: Implement actual training configuration retrieval logic |
316 | | - _ = project_id, project_service, model_architecture_id, model_revision_id |
317 | | - return TrainingConfiguration.from_hyperparameters(hyperparameters=Hyperparameters()) |
318 | | - except ResourceNotFoundError as e: |
319 | | - raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail=str(e)) |
320 | | - except ValueError as e: |
321 | | - raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail=str(e)) |
322 | | - |
323 | | - |
324 | | -@router.patch( |
325 | | - "/{project_id}/training_configuration", |
326 | | - status_code=status.HTTP_204_NO_CONTENT, |
327 | | - responses={ |
328 | | - status.HTTP_204_NO_CONTENT: {"description": "Training configuration updated successfully"}, |
329 | | - status.HTTP_400_BAD_REQUEST: {"description": "Invalid project ID, query parameters, or request body"}, |
330 | | - status.HTTP_404_NOT_FOUND: {"description": "Project not found"}, |
331 | | - }, |
332 | | -) |
333 | | -def update_training_configuration( |
334 | | - project_id: Annotated[UUID, Depends(get_project_id)], |
335 | | - training_config_update: Annotated[TrainingConfiguration, Body(description="Training configuration updates")], |
336 | | - project_service: Annotated[ProjectService, Depends(get_project_service)], |
337 | | - model_architecture_id: Annotated[str | None, Query()] = None, |
338 | | -) -> None: |
339 | | - """ |
340 | | - Update the training configuration for a project. |
341 | | -
|
342 | | - - If model_architecture_id is provided, updates configuration for that specific model architecture. |
343 | | - - If not provided, updates the general task-related configuration. |
344 | | - Note: model_architecture_id cannot be used with model_revision_id for updates. |
345 | | -
|
346 | | - Args: |
347 | | - project_id (UUID): The unique identifier of the project. |
348 | | - training_config_update (TrainingConfiguration): The training configuration updates. |
349 | | - project_service (ProjectService): The project service |
350 | | - model_architecture_id (Optional[str]): The model architecture ID for specific configuration update. |
351 | | - """ |
352 | | - try: |
353 | | - # TODO: Implement actual training configuration update logic |
354 | | - _ = project_id, training_config_update, project_service, model_architecture_id |
355 | | - except ResourceNotFoundError as e: |
356 | | - raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail=str(e)) |
357 | | - except ValueError as e: |
358 | | - raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail=str(e)) |
0 commit comments