from functools import cached_property from pathlib import Path from typing import Annotated from huggingface_hub import HfApi from pydantic import Field, SecretStr, computed_field from pydantic_settings import BaseSettings, SettingsConfigDict # ---------------------------------- # Info to change for your repository # ---------------------------------- class Settings(BaseSettings): model_config = SettingsConfigDict(env_file=".env") HF_TOKEN: Annotated[SecretStr, Field(..., description="A read/write token for your org")] # Settings for Hugging Face repos HF_OWNER: str = "lmms-lab" HF_REPO_NAME: Annotated[str, Field(description="Name of leaderboard repo")] = "EASI-Leaderboard" HF_RESULTS_REPO_NAME: Annotated[str, Field(description="Name of results repo")] = "EASI-Leaderboard-Results" HF_REQUESTS_REPO_NAME: Annotated[str, Field(description="Name of requests repo")] = "EASI-Leaderboard-Requests" @computed_field @cached_property def REPO_ID(self) -> str: return (Path(self.HF_OWNER) / self.HF_REPO_NAME).as_posix() @computed_field @cached_property def RESULTS_REPO_ID(self) -> str: return (Path(self.HF_OWNER) / self.HF_RESULTS_REPO_NAME).as_posix() @computed_field @cached_property def QUEUE_REPO_ID(self) -> str: return (Path(self.HF_OWNER) / self.HF_REQUESTS_REPO_NAME).as_posix() HF_HOME: Annotated[ Path, Field( default_factory=lambda: Path(".").resolve(), description="If you setup a cache later, just change `HF_HOME`", ), ] # Backend settings BACKEND_HOST: Annotated[str, Field("127.0.0.1", description="Backend host")] BACKEND_PORT: Annotated[int, Field(8000, description="Backend port")] # Local caches @computed_field @cached_property def EVAL_REQUESTS_PATH(self) -> Path: return self.HF_HOME / "eval-queue" @computed_field @cached_property def EVAL_RESULTS_PATH(self) -> Path: return self.HF_HOME / "eval-results" @computed_field @cached_property def EVAL_RESULTS_VERSIONS_DIR(self) -> Path: return self.EVAL_RESULTS_PATH / "leaderboard/versions" @computed_field @cached_property def EVAL_REQUESTS_PATH_BACKUP(self) -> Path: return self.HF_HOME / "eval-queue-bk" @computed_field @cached_property def EVAL_RESULTS_PATH_BACKUP(self) -> Path: return self.HF_HOME / "eval-results-bk" ENABLE_BENCHMARK_TABS: bool = False ENABLE_SUBMISSION: bool = True settings = Settings() # pyright: ignore[reportCallIssue] API = HfApi(token=settings.HF_TOKEN.get_secret_value())