feat: Add new API endpoints and HTML pages for ML model management
- Implemented HTML pages for datasets, models, training, testing, and results. - Created API endpoints for managing repositories, results, tests, and training sessions. - Added functionality for streaming training progress via Server-Sent Events (SSE). - Introduced a Dockerfile for the ML runner with necessary dependencies. - Developed an SDK for user code execution within the runner container. - Enhanced CSS styles for improved UI layout and navigation. - Established a layout template for consistent HTML structure across pages. - Added JavaScript for dynamic interactions on the models page. - Implemented WebSocket handling for real-time communication with kiosk devices and controllers. - Implemented model registration and management API at /api/models - Added Gitea proxy API for repository interactions at /api/repos - Created results API for listing and comparing training results at /api/results - Developed training management API for enqueueing and retrieving training jobs at /api/trainings - Introduced SSE endpoint for live training progress updates - Added HTML pages for models, datasets, and training management - Created a Dockerfile for the ML runner with necessary dependencies - Developed SDK for user code execution within the runner container - Enhanced CSS styles for improved UI/UX - Implemented WebSocket communication for real-time device and controller interactions in the kiosk system
This commit is contained in:
51
ml/routers/repos.py
Normal file
51
ml/routers/repos.py
Normal file
@@ -0,0 +1,51 @@
|
||||
"""API /api/repos — proxy autenticato verso Gitea."""
|
||||
from __future__ import annotations
|
||||
|
||||
from fastapi import APIRouter, Depends, HTTPException, Query
|
||||
|
||||
from core import gitea
|
||||
from core.auth import require_auth
|
||||
from core.model_spec import fetch_and_parse_spec
|
||||
|
||||
router = APIRouter(prefix="/api/repos", tags=["repos"])
|
||||
|
||||
|
||||
@router.get("")
|
||||
async def list_repos(user=Depends(require_auth)):
|
||||
try:
|
||||
return await gitea.list_repos()
|
||||
except Exception as e:
|
||||
raise HTTPException(502, f"gitea: {e}")
|
||||
|
||||
|
||||
@router.get("/{owner}/{repo}/branches")
|
||||
async def branches(owner: str, repo: str, user=Depends(require_auth)):
|
||||
try:
|
||||
return await gitea.list_branches(f"{owner}/{repo}")
|
||||
except Exception as e:
|
||||
raise HTTPException(502, f"gitea: {e}")
|
||||
|
||||
|
||||
@router.get("/{owner}/{repo}/commits")
|
||||
async def commits(owner: str, repo: str, branch: str = Query("main"), user=Depends(require_auth)):
|
||||
try:
|
||||
return await gitea.list_commits(f"{owner}/{repo}", branch)
|
||||
except Exception as e:
|
||||
raise HTTPException(502, f"gitea: {e}")
|
||||
|
||||
|
||||
@router.get("/{owner}/{repo}/file")
|
||||
async def file_raw(owner: str, repo: str, ref: str, path: str, user=Depends(require_auth)):
|
||||
try:
|
||||
raw = await gitea.get_file_raw(f"{owner}/{repo}", ref, path)
|
||||
return {"content": raw.decode("utf-8", errors="replace"), "size": len(raw)}
|
||||
except Exception as e:
|
||||
raise HTTPException(404, f"file not found: {e}")
|
||||
|
||||
|
||||
@router.get("/{owner}/{repo}/spec")
|
||||
async def spec(owner: str, repo: str, ref: str = Query("main"), user=Depends(require_auth)):
|
||||
s = await fetch_and_parse_spec(f"{owner}/{repo}", ref)
|
||||
if s is None:
|
||||
raise HTTPException(404, "model.yml not found at ref")
|
||||
return s
|
||||
Reference in New Issue
Block a user