|
|
import os |
|
|
|
|
|
from huggingface_hub import HfApi |
|
|
|
|
|
|
|
|
|
|
|
TOKEN = os.environ.get("HF_TOKEN") |
|
|
|
|
|
OWNER = "searchagent_leaderboard" |
|
|
|
|
|
REPO_ID = f"{OWNER}/leaderboard" |
|
|
QUEUE_REPO = f"{OWNER}/requests" |
|
|
RESULTS_REPO = f"{OWNER}/results" |
|
|
|
|
|
|
|
|
_SRC_DIR = os.path.dirname(os.path.abspath(__file__)) |
|
|
_PROJECT_ROOT = os.path.abspath(os.path.join(_SRC_DIR, os.pardir)) |
|
|
|
|
|
|
|
|
def _resolve_cache_path() -> str: |
|
|
"""Determine where eval assets should be read from.""" |
|
|
|
|
|
env_override = os.getenv("EVAL_CACHE_PATH") |
|
|
if env_override: |
|
|
return os.path.abspath(env_override) |
|
|
|
|
|
|
|
|
hf_home = os.getenv("HF_HOME") |
|
|
if hf_home: |
|
|
hf_home = os.path.abspath(hf_home) |
|
|
expected_results = os.path.join(hf_home, "eval-results") |
|
|
expected_queue = os.path.join(hf_home, "eval-queue") |
|
|
if os.path.isdir(expected_results) or os.path.isdir(expected_queue): |
|
|
return hf_home |
|
|
|
|
|
|
|
|
return _PROJECT_ROOT |
|
|
|
|
|
|
|
|
CACHE_PATH = _resolve_cache_path() |
|
|
|
|
|
|
|
|
def _debug_path(label: str, path: str, max_entries: int = 10) -> None: |
|
|
try: |
|
|
entries = os.listdir(path) |
|
|
preview = entries[:max_entries] |
|
|
print(f"[envs] {label}: {path} | {len(entries)} entries | preview={preview}") |
|
|
except FileNotFoundError: |
|
|
print(f"[envs] {label}: {path} | missing") |
|
|
except Exception as exc: |
|
|
print(f"[envs] {label}: {path} | error={exc}") |
|
|
|
|
|
|
|
|
|
|
|
EVAL_REQUESTS_PATH = os.path.join(CACHE_PATH, "eval-queue") |
|
|
EVAL_RESULTS_PATH = os.path.join(CACHE_PATH, "eval-results") |
|
|
EVAL_REQUESTS_PATH_BACKEND = os.path.join(CACHE_PATH, "eval-queue-bk") |
|
|
EVAL_RESULTS_PATH_BACKEND = os.path.join(CACHE_PATH, "eval-results-bk") |
|
|
|
|
|
if os.getenv("DEBUG_ENV_PATHS", "0").lower() in {"1", "true", "yes"}: |
|
|
print( |
|
|
f"[envs] HF_HOME={os.getenv('HF_HOME')} | EVAL_CACHE_PATH={os.getenv('EVAL_CACHE_PATH')} | CACHE_PATH={CACHE_PATH}" |
|
|
) |
|
|
_debug_path("EVAL_RESULTS_PATH", EVAL_RESULTS_PATH) |
|
|
_debug_path("EVAL_REQUESTS_PATH", EVAL_REQUESTS_PATH) |
|
|
|
|
|
API = HfApi(token=TOKEN) |
|
|
|