Add dataset bench and validation agents
This commit is contained in:
@@ -4,7 +4,7 @@ import asyncio
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
from fastapi import FastAPI, HTTPException
|
||||
from fastapi import FastAPI, File, HTTPException, UploadFile
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from fastapi.responses import FileResponse, StreamingResponse
|
||||
|
||||
@@ -13,9 +13,12 @@ from .catalog import get_catalog
|
||||
from .config import settings
|
||||
from .jobs import cancel_job, create_job
|
||||
from .modules.system.service import disk_usage, get_conda_envs, get_gpus, scan_results
|
||||
from .modules.dataset.service import create_dataset, list_uploaded_datasets, save_upload
|
||||
from .modules.weights.service import load_manifest, sync_weights, verify_weights
|
||||
from .agents.evaluation_agent import evaluate_project
|
||||
from .agents.validation_agent import validate_project
|
||||
from .paths import ensure_inside
|
||||
from .schemas import JobCreate, ProfileCreate, WeightSyncRequest
|
||||
from .schemas import DatasetCreate, JobCreate, ProfileCreate, WeightSyncRequest
|
||||
|
||||
app = FastAPI(title="Seg Data Server Net", version="0.1.0")
|
||||
|
||||
@@ -60,6 +63,24 @@ def api_catalog() -> dict:
|
||||
return get_catalog()
|
||||
|
||||
|
||||
@app.get("/api/datasets")
|
||||
def api_datasets() -> list[dict]:
|
||||
return list_uploaded_datasets()
|
||||
|
||||
|
||||
@app.post("/api/datasets")
|
||||
def api_create_dataset(dataset: DatasetCreate) -> dict:
|
||||
return create_dataset(dataset.name, dataset.description)
|
||||
|
||||
|
||||
@app.post("/api/datasets/{dataset_name}/upload/{kind}")
|
||||
async def api_upload_dataset_files(dataset_name: str, kind: str, files: list[UploadFile] = File(...)) -> dict:
|
||||
try:
|
||||
return await save_upload(dataset_name, kind, files)
|
||||
except Exception as exc:
|
||||
raise HTTPException(status_code=400, detail=str(exc)) from exc
|
||||
|
||||
|
||||
@app.get("/api/profiles")
|
||||
def api_profiles(kind: str | None = None) -> list[dict]:
|
||||
return db.list_profiles(kind)
|
||||
@@ -170,3 +191,12 @@ def api_weight_sync(request: WeightSyncRequest) -> dict:
|
||||
def api_weight_verify() -> dict:
|
||||
return verify_weights()
|
||||
|
||||
|
||||
@app.get("/api/agents/evaluate")
|
||||
def api_agent_evaluate() -> dict:
|
||||
return evaluate_project()
|
||||
|
||||
|
||||
@app.get("/api/agents/validate")
|
||||
def api_agent_validate(run_build: bool = False) -> dict:
|
||||
return validate_project(run_build=run_build)
|
||||
|
||||
Reference in New Issue
Block a user