"""uvicorn entry point: `uvicorn semif_serve.main:app_from_env --factory --workers 1`.""" from __future__ import annotations import os from fastapi import FastAPI from .app import create_app from .config import Settings def app_from_env() -> FastAPI: settings = Settings.from_env(os.environ) # INV-5: never download at runtime, inside the image or out of it (bug hunt S10). Set before # torch / transformers / huggingface_hub are imported, since they read it at import time. os.environ["HF_HUB_OFFLINE"] = "1" os.environ["TRANSFORMERS_OFFLINE"] = "1" from .engine import TorchEngine # torch loads only here, never in the unit tests return create_app(settings, TorchEngine.load(settings))