Spaces:
Sleeping
Sleeping
File size: 997 Bytes
395651c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | #!/usr/bin/env python3
"""
Download and load all heavy models during Docker build (YOLO, PaddleOCR, Pix2Tex, agents).
Fails the image build if initialization fails.
"""
from __future__ import annotations
import logging
import os
import sys
# Ensure imports work when run as `python scripts/prewarm_models.py` from WORKDIR
_APP_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
if _APP_ROOT not in sys.path:
sys.path.insert(0, _APP_ROOT)
os.chdir(_APP_ROOT)
from dotenv import load_dotenv
load_dotenv()
from app.runtime_env import apply_runtime_env_defaults
apply_runtime_env_defaults()
logging.basicConfig(level=logging.INFO, format="%(levelname)s %(name)s | %(message)s")
logger = logging.getLogger("prewarm")
def main() -> None:
from agents.orchestrator import Orchestrator
logger.info("Constructing Orchestrator (full agent + model load)...")
Orchestrator()
logger.info("Prewarm finished successfully.")
if __name__ == "__main__":
main()
|