""" config.py — Centralized application settings. All tuneable knobs live here; override via environment variables. """ from pathlib import Path from pydantic_settings import BaseSettings, SettingsConfigDict class Settings(BaseSettings): model_config = SettingsConfigDict( env_file=".env", env_file_encoding="utf-8", case_sensitive=False, ) # ── App ─────────────────────────────────────────────────────────── app_name: str = "MLForge Platform" version: str = "1.0.0" debug: bool = False # ── API ─────────────────────────────────────────────────────────── host: str = "0.0.0.0" port: int = 7860 # Default for HF Spaces cors_origins: list[str] = ["*"] # ── Storage ─────────────────────────────────────────────────────── base_dir: Path = Path(__file__).resolve().parents[1] data_dir: Path = base_dir / "data" logs_dir: Path = data_dir / "logs" db_path: Path = data_dir / "modelzoo.db" # ── Search ──────────────────────────────────────────────────────── search_max_results: int = 1000 # ── Sync ────────────────────────────────────────────────────────── auto_sync_on_startup: bool = True # ── Hugging Face API ────────────────────────────────────────────── hf_api_base: str = "https://huggingface.co/api" hf_hub_url: str = "https://huggingface.co" hf_token: str | None = None # Optional: HF_TOKEN env var hf_models_per_task: int = 200 # Discovery server pulls more per task def ensure_dirs(self) -> None: self.data_dir.mkdir(parents=True, exist_ok=True) self.logs_dir.mkdir(parents=True, exist_ok=True) settings = Settings()