Spaces:
Running
Running
| from functools import cached_property | |
| from pathlib import Path | |
| from typing import Annotated | |
| from huggingface_hub import HfApi | |
| from pydantic import Field, computed_field | |
| from pydantic_settings import BaseSettings, SettingsConfigDict | |
| # ---------------------------------- | |
| # Info to change for your repository | |
| # ---------------------------------- | |
| class Settings(BaseSettings): | |
| model_config = SettingsConfigDict(env_file=".env") | |
| TOKEN: Annotated[str, Field(..., alias="HF_TOKEN", description="A read/write token for your org")] | |
| # Change to your org - don't forget to create a results and request dataset, with the correct format! | |
| OWNER: Annotated[ | |
| str, | |
| Field("y-playground"), | |
| ] | |
| def REPO_ID(self) -> str: | |
| return (Path(self.OWNER) / "leaderboard").as_posix() | |
| def QUEUE_REPO(self) -> str: | |
| return (Path(self.OWNER) / "requests").as_posix() | |
| def RESULTS_REPO(self) -> str: | |
| return (Path(self.OWNER) / "results").as_posix() | |
| CACHE_PATH: Annotated[ | |
| str, | |
| Field(".", alias="HF_HOME", description="If you setup a cache later, just change `HF_HOME`"), | |
| ] | |
| # Local caches | |
| def EVAL_REQUESTS_PATH(self) -> str: | |
| return (Path(self.CACHE_PATH) / "eval-queue").as_posix() | |
| def EVAL_RESULTS_PATH(self) -> str: | |
| return (Path(self.CACHE_PATH) / "eval-results").as_posix() | |
| def EVAL_REQUESTS_PATH_BACKEND(self) -> str: | |
| return (Path(self.CACHE_PATH) / "eval-queue-bk").as_posix() | |
| def EVAL_RESULTS_PATH_BACKEND(self) -> str: | |
| return (Path(self.CACHE_PATH) / "eval-results-bk").as_posix() | |
| def API(self) -> HfApi: | |
| return HfApi(token=self.TOKEN) | |
| settings = Settings() # pyright: ignore[reportCallIssue] | |
| API = settings.API | |