Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /olaflaitinen_Promethium /src /promethium /api /routers /ml.py
| from fastapi import APIRouter, Depends, HTTPException | |
| from sqlalchemy.ext.asyncio import AsyncSession | |
| from sqlalchemy.future import select | |
| from typing import List | |
| from promethium.core.database import get_db | |
| from promethium.api.models.ml_model import MLModel | |
| from promethium.api.models.user import User | |
| from promethium.api.schemas.ml_model import MLModelRead, MLModelCreate, MLModelUpdate | |
| from promethium.api.deps.auth import get_current_active_user | |
| from promethium.core.logging import logger | |
| router = APIRouter(prefix="/ml/models", tags=["ml-models"]) | |
| async def create_model( | |
| model_in: MLModelCreate, | |
| db: AsyncSession = Depends(get_db), | |
| current_user: User = Depends(get_current_active_user) | |
| ): | |
| new_model = MLModel( | |
| name=model_in.name, | |
| type=model_in.type, | |
| version=model_in.version, | |
| description=model_in.description, | |
| config=model_in.config, | |
| metrics=model_in.metrics | |
| ) | |
| db.add(new_model) | |
| await db.commit() | |
| await db.refresh(new_model) | |
| return new_model | |
| async def list_models( | |
| skip: int = 0, | |
| limit: int = 100, | |
| db: AsyncSession = Depends(get_db), | |
| current_user: User = Depends(get_current_active_user) | |
| ): | |
| result = await db.execute(select(MLModel).offset(skip).limit(limit)) | |
| models = result.scalars().all() | |
| return models | |
| async def get_model( | |
| model_id: int, | |
| db: AsyncSession = Depends(get_db), | |
| current_user: User = Depends(get_current_active_user) | |
| ): | |
| model = await db.get(MLModel, model_id) | |
| if not model: | |
| raise HTTPException(status_code=404, detail="Model not found") | |
| return model | |
Xet Storage Details
- Size:
- 1.79 kB
- Xet hash:
- 5ebdd6708d63d87aff4b27fb37f96fecd168bfbb7b9cc8760e33d528242621ca
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.