zziang commited on
Commit
4021e8c
·
verified ·
1 Parent(s): 117bd84

director: hold huggingface_hub below 2 (httpx renamed)

Browse files
Files changed (1) hide show
  1. kaggle/notebook_director.py +13 -7
kaggle/notebook_director.py CHANGED
@@ -15,13 +15,19 @@ def sh(cmd: str) -> None:
15
 
16
 
17
  def main() -> None:
18
- # One resolver pass: transformers 5 expects a newer huggingface_hub than the
19
- # image ships, and installing them separately leaves `httpx` missing from
20
- # huggingface_hub.utils.
21
- sh("pip install -q --upgrade 'transformers>=5' 'huggingface_hub>=1.0' accelerate")
22
-
23
- import transformers
24
- print("transformers", transformers.__version__, flush=True)
 
 
 
 
 
 
25
 
26
  from huggingface_hub import snapshot_download
27
 
 
15
 
16
 
17
  def main() -> None:
18
+ # transformers 5 imports `httpx` from huggingface_hub.utils. huggingface_hub
19
+ # 2.x renamed that to httpx2 and the import fails, so hold hub below 2.
20
+ sh("pip install -q --upgrade 'transformers>=5' 'huggingface_hub>=1.31,<2' accelerate")
21
+
22
+ check = subprocess.run(
23
+ [sys.executable, "-c",
24
+ "import transformers, huggingface_hub as h;"
25
+ "print('transformers', transformers.__version__, 'hub', h.__version__);"
26
+ "from huggingface_hub.utils import httpx; print('httpx ok')"],
27
+ capture_output=True, text=True)
28
+ print(check.stdout.strip() or check.stderr[-600:], flush=True)
29
+ if check.returncode != 0:
30
+ raise SystemExit("director environment is broken")
31
 
32
  from huggingface_hub import snapshot_download
33