Spaces:
Running
Running
yangzhitao
feat: integrate display configuration loading and enhance leaderboard data retrieval with versioning support
c2c3c10
| 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" | |
| def REPO_ID(self) -> str: | |
| return (Path(self.HF_OWNER) / self.HF_REPO_NAME).as_posix() | |
| def RESULTS_REPO_ID(self) -> str: | |
| return (Path(self.HF_OWNER) / self.HF_RESULTS_REPO_NAME).as_posix() | |
| 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 | |
| def EVAL_REQUESTS_PATH(self) -> Path: | |
| return self.HF_HOME / "eval-queue" | |
| def EVAL_RESULTS_PATH(self) -> Path: | |
| return self.HF_HOME / "eval-results" | |
| def EVAL_RESULTS_VERSIONS_DIR(self) -> Path: | |
| return self.EVAL_RESULTS_PATH / "leaderboard/versions" | |
| def EVAL_REQUESTS_PATH_BACKUP(self) -> Path: | |
| return self.HF_HOME / "eval-queue-bk" | |
| def EVAL_RESULTS_PATH_BACKUP(self) -> Path: | |
| return self.HF_HOME / "eval-results-bk" | |
| ENABLE_BENCHMARK_TABS: bool = False | |
| ENABLE_SUBMISSION: bool = False | |
| settings = Settings() # pyright: ignore[reportCallIssue] | |
| API = HfApi(token=settings.HF_TOKEN.get_secret_value()) | |