Fix training start 2
This commit is contained in:
@@ -29,7 +29,7 @@ from app.services.messaging import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
from sqlalchemy.ext.asyncio import AsyncSession
|
from sqlalchemy.ext.asyncio import AsyncSession
|
||||||
from app.core.database import get_db
|
from app.core.database import get_db_session
|
||||||
|
|
||||||
# Import unified authentication from shared library
|
# Import unified authentication from shared library
|
||||||
from shared.auth.decorators import (
|
from shared.auth.decorators import (
|
||||||
@@ -48,7 +48,7 @@ async def start_training_job(
|
|||||||
tenant_id: str = Depends(get_current_tenant_id_dep),
|
tenant_id: str = Depends(get_current_tenant_id_dep),
|
||||||
current_user: Dict[str, Any] = Depends(get_current_user_dep),
|
current_user: Dict[str, Any] = Depends(get_current_user_dep),
|
||||||
training_service: TrainingService = Depends(),
|
training_service: TrainingService = Depends(),
|
||||||
db: AsyncSession = Depends(get_db) # Ensure db is available
|
db: AsyncSession = Depends(get_db_session) # Ensure db is available
|
||||||
):
|
):
|
||||||
"""Start a new training job for all products"""
|
"""Start a new training job for all products"""
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ from fastapi.responses import JSONResponse
|
|||||||
import uvicorn
|
import uvicorn
|
||||||
|
|
||||||
from app.core.config import settings
|
from app.core.config import settings
|
||||||
from app.core.database import database_manager, get_db_health
|
from app.core.database import initialize_training_database, cleanup_training_database
|
||||||
from app.api import training, models
|
from app.api import training, models
|
||||||
from app.services.messaging import setup_messaging, cleanup_messaging
|
from app.services.messaging import setup_messaging, cleanup_messaging
|
||||||
from shared.monitoring.logging import setup_logging
|
from shared.monitoring.logging import setup_logging
|
||||||
@@ -41,7 +41,7 @@ async def lifespan(app: FastAPI):
|
|||||||
try:
|
try:
|
||||||
# Initialize database
|
# Initialize database
|
||||||
logger.info("Initializing database connection")
|
logger.info("Initializing database connection")
|
||||||
await database_manager.create_tables()
|
initialize_training_database()
|
||||||
logger.info("Database initialized successfully")
|
logger.info("Database initialized successfully")
|
||||||
|
|
||||||
# Initialize messaging
|
# Initialize messaging
|
||||||
@@ -81,7 +81,7 @@ async def lifespan(app: FastAPI):
|
|||||||
logger.info("Messaging cleanup completed")
|
logger.info("Messaging cleanup completed")
|
||||||
|
|
||||||
# Close database connections
|
# Close database connections
|
||||||
await database_manager.close_connections()
|
cleanup_training_database()
|
||||||
logger.info("Database connections closed")
|
logger.info("Database connections closed")
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
Reference in New Issue
Block a user