File size: 2,330 Bytes
07ccbd9
 
 
 
 
 
b1cccfe
07ccbd9
b1cccfe
07ccbd9
 
 
 
 
b1cccfe
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
07ccbd9
1440c3c
 
 
 
 
 
 
 
 
 
 
 
07ccbd9
 
 
 
 
 
8b9f790
 
 
 
 
 
1440c3c
07ccbd9
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
import os

from huggingface_hub import HfApi

# Info to change for your repository
# ----------------------------------
TOKEN = os.environ.get("HF_TOKEN")  # A read/write token for your org

OWNER = "searchagent_leaderboard"

REPO_ID = f"{OWNER}/leaderboard"
QUEUE_REPO = f"{OWNER}/requests"
RESULTS_REPO = f"{OWNER}/results"

# Resolve project root (two levels up from this file when packaged)
_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."""
    # Highest priority: explicit environment override
    env_override = os.getenv("EVAL_CACHE_PATH")
    if env_override:
        return os.path.abspath(env_override)

    # Next: if HF_HOME contains the expected folders, use it
    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

    # Fallback to project root so bundled demo data is found
    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}")


# Local caches
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)