Spaces:
Running
Running
File size: 2,244 Bytes
fe8ec74 3b3db42 8b1f7a0 fe8ec74 8b1f7a0 fe8ec74 01ea22b 0df3db8 8b1f7a0 fe8ec74 60906bd fe8ec74 bd30e41 fe8ec74 d66a6a3 fe8ec74 d66a6a3 fe8ec74 d66a6a3 fe8ec74 d66a6a3 fe8ec74 d66a6a3 fe8ec74 d66a6a3 fe8ec74 d66a6a3 fe8ec74 8b1f7a0 fe8ec74 29efd58 8b1f7a0 d66a6a3 fe8ec74 |
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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
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"),
]
BACKEND_HOST: Annotated[str, Field("127.0.0.1", description="Backend host")]
BACKEND_PORT: Annotated[int, Field(8000, description="Backend port")]
@computed_field
@cached_property
def REPO_ID(self) -> str:
return (Path(self.OWNER) / "leaderboard").as_posix()
@computed_field
@cached_property
def QUEUE_REPO(self) -> str:
return (Path(self.OWNER) / "requests").as_posix()
@computed_field
@cached_property
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
@computed_field
@cached_property
def EVAL_REQUESTS_PATH(self) -> str:
return (Path(self.CACHE_PATH) / "eval-queue").as_posix()
@computed_field
@cached_property
def EVAL_RESULTS_PATH(self) -> str:
return (Path(self.CACHE_PATH) / "eval-results").as_posix()
@computed_field
@cached_property
def EVAL_REQUESTS_PATH_BACKEND(self) -> str:
return (Path(self.CACHE_PATH) / "eval-queue-bk").as_posix()
@computed_field
@cached_property
def EVAL_RESULTS_PATH_BACKEND(self) -> str:
return (Path(self.CACHE_PATH) / "eval-results-bk").as_posix()
@computed_field
@cached_property
def API(self) -> HfApi:
return HfApi(token=self.TOKEN)
settings = Settings() # pyright: ignore[reportCallIssue]
API = settings.API
|