Add major caching to sampler manager
Signed-off-by: Felipe Cardoso <felipe.cardoso@hotmail.it>
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import logging
|
||||
import platform
|
||||
from datetime import datetime, timezone
|
||||
|
||||
@@ -7,7 +8,14 @@ from fastapi.middleware.cors import CORSMiddleware
|
||||
|
||||
from app.api.routes import training, samples
|
||||
from app.core.config import settings
|
||||
from app.services.sample_manager import SampleManager
|
||||
|
||||
# Configure logging
|
||||
logging.basicConfig(
|
||||
level=logging.INFO,
|
||||
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
|
||||
)
|
||||
logger = logging.getLogger(__name__)
|
||||
app = FastAPI(
|
||||
title="Training Monitor API",
|
||||
description="API for monitoring ML training progress and samples",
|
||||
@@ -23,6 +31,24 @@ app.add_middleware(
|
||||
allow_headers=["*"],
|
||||
)
|
||||
|
||||
# Create and store SampleManager instance
|
||||
sample_manager = SampleManager()
|
||||
app.state.sample_manager = sample_manager
|
||||
|
||||
|
||||
@app.on_event("startup")
|
||||
async def startup_event():
|
||||
"""Initialize services on startup"""
|
||||
logger.info("Starting up Training Monitor API")
|
||||
await sample_manager.startup()
|
||||
|
||||
|
||||
@app.on_event("shutdown")
|
||||
async def shutdown_event():
|
||||
"""Cleanup on shutdown"""
|
||||
logger.info("Shutting down Training Monitor API")
|
||||
await sample_manager.shutdown()
|
||||
|
||||
# Include routers with versioning
|
||||
app.include_router(training.router, prefix=f"{settings.API_VER_STR}/training", tags=["training"])
|
||||
app.include_router(samples.router, prefix=f"{settings.API_VER_STR}/samples", tags=["samples"])
|
||||
|
||||
Reference in New Issue
Block a user