- 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
64 lines
1.5 KiB
Python
64 lines
1.5 KiB
Python
"""
|
|
Servizio reindirizzato: api.{domain}/marine/* (Traefik strips /marine prefix)
|
|
"""
|
|
|
|
import os
|
|
from contextlib import asynccontextmanager
|
|
|
|
from dotenv import load_dotenv
|
|
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
|
|
load_dotenv()
|
|
|
|
from routers import catalog, datasets, jobs
|
|
from core.cache import cache_stats, cache_sweep
|
|
|
|
|
|
@asynccontextmanager
|
|
async def lifespan(app: FastAPI):
|
|
api_url = os.getenv("API_SERVICE_URL", "http://api:3003")
|
|
# Pulizia voci scadute della cache su disco all'avvio
|
|
removed = cache_sweep()
|
|
if removed:
|
|
print(f"[Cache] Rimosse {removed} voci scadute dal disco")
|
|
yield
|
|
|
|
|
|
app = FastAPI(
|
|
title="MEB Marine Service",
|
|
description="Copernicus Marine data download and dataset management for the MEB platform",
|
|
version="1.0.0",
|
|
docs_url="/docs",
|
|
redoc_url="/redoc",
|
|
lifespan=lifespan,
|
|
root_path=""
|
|
)
|
|
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origin_regex=r"https?://.*\.(localhost|mebboat\.it)(:\d+)?$",
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
app.include_router(catalog.router)
|
|
app.include_router(jobs.router)
|
|
app.include_router(datasets.router)
|
|
|
|
|
|
@app.get("/", tags=["health"])
|
|
async def root():
|
|
return {"service": "MEB Marine Service", "version": "1.0.0", "docs": "/docs"}
|
|
|
|
|
|
@app.get("/health", tags=["health"])
|
|
async def health():
|
|
return {"status": "healthy", "cache": cache_stats()}
|
|
|
|
|
|
@app.post("/cache/sweep", tags=["health"])
|
|
async def sweep():
|
|
return {"removed": cache_sweep()}
|