P0 Critical: presentation isolation (client scoping), storage super_admin fix, template selection in worker, IMAGE_PROVIDERS list fix. P1 High: template layout management UI (delete/filter/bulk), slide-based parsing mode, LLM model listing & connection test, settings persistence to DB (Fernet encryption), logout button. P2 Polish: storage improvements (master deck files, per-client breakdown, bulk delete, hard purge, client selector), image generation error visibility (__image_error__ badge), hamster wheel loading animation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
36 lines
1.2 KiB
Python
36 lines
1.2 KiB
Python
from contextlib import asynccontextmanager
|
|
import os
|
|
|
|
from fastapi import FastAPI
|
|
|
|
from services.database import create_db_and_tables
|
|
from services.redis_service import close_arq_pool
|
|
from utils.get_env import get_app_data_directory_env
|
|
from utils.model_availability import (
|
|
check_llm_and_image_provider_api_or_model_availability,
|
|
)
|
|
|
|
|
|
@asynccontextmanager
|
|
async def app_lifespan(_: FastAPI):
|
|
"""
|
|
Lifespan context manager for FastAPI application.
|
|
Initializes the application data directory and checks LLM model availability.
|
|
|
|
"""
|
|
os.makedirs(get_app_data_directory_env(), exist_ok=True)
|
|
await create_db_and_tables()
|
|
|
|
# Load persisted settings from database into os.environ
|
|
try:
|
|
from services.database import async_session_maker
|
|
from services.settings_service import load_settings
|
|
async with async_session_maker() as session:
|
|
await load_settings(session)
|
|
print("[Lifespan] Loaded persisted settings from database")
|
|
except Exception as e:
|
|
print(f"[Lifespan] Could not load persisted settings (non-fatal): {e}")
|
|
|
|
await check_llm_and_image_provider_api_or_model_availability()
|
|
yield
|
|
await close_arq_pool()
|