File size: 1,527 Bytes
e5d9366
 
 
 
 
675721d
 
 
 
 
e5d9366
675721d
e5d9366
157f0bf
e5d9366
675721d
 
e5d9366
 
 
675721d
e5d9366
 
 
 
4021e8c
675721d
4021e8c
 
675721d
 
 
0f5baba
 
 
 
675721d
e5d9366
 
 
 
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
"""Kaggle notebook body: the director stage, isolated from Ming's transformers.

Ming pins transformers 4.46.3; Qwen3.5 needs 5.x. They cannot share a process,
so the director runs here and leaves a validated script behind. The radio stage
reads that file instead of calling an LLM itself.

The probe runs as a subprocess on purpose: this notebook imports huggingface_hub
to download the bundle, and after `pip install --upgrade` the already-imported
module is stale, which breaks transformers' `from huggingface_hub.utils import
httpx`. A fresh interpreter picks up the new version.
"""
import os
import subprocess
import sys

BUNDLE = "/kaggle/working/webfm-eval"


def sh(cmd: str) -> None:
    print(f"$ {cmd}", flush=True)
    if subprocess.run(cmd, shell=True).returncode != 0:
        raise SystemExit(f"failed: {cmd}")


def main() -> None:
    # transformers 5 imports `httpx` from huggingface_hub.utils. huggingface_hub
    # 2.x renamed that to httpx2, so hold hub below 2.
    sh("pip install -q --upgrade 'transformers>=5' 'huggingface_hub>=1.31,<2' accelerate")

    target = os.path.join(BUNDLE, "kaggle/director_probe.py")
    if not os.path.exists(target):
        raise SystemExit(f"{target} missing")
    env = dict(os.environ, WORK_ROOT="/kaggle/working",
               MODE=os.environ.get("MODE", "probe"),
               N_SAMPLES=os.environ.get("N_SAMPLES", "8"))
    rc = subprocess.run([sys.executable, target], env=env).returncode
    print("director rc", rc)


if __name__ == "__main__":
    main()