AI4deeperScience commited on
Commit
b46e5e8
·
verified ·
1 Parent(s): 20bef68

Add shim huggingface_hub.py to satisfy gradio.oauth imports

Browse files
Files changed (1) hide show
  1. huggingface_hub.py +31 -0
huggingface_hub.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Minimal shim for `huggingface_hub` to satisfy `gradio.oauth` imports
3
+ This provides lightweight `HfFolder` and `whoami` symbols so that
4
+ `import gradio` doesn't fail during build/runtime when the installed
5
+ `huggingface_hub` API surface differs.
6
+
7
+ This shim intentionally implements only the tiny surface gradio needs:
8
+ - `HfFolder` with `get_token` / `save_token` / `path_token`
9
+ - `whoami(token=None)` returning a minimal dict or None
10
+
11
+ Note: This is a compatibility shim for Spaces deployment only.
12
+ """
13
+
14
+ def whoami(token=None):
15
+ # Return minimal user info shape; gradio only checks truthiness
16
+ return None
17
+
18
+
19
+ class HfFolder:
20
+ @staticmethod
21
+ def path_token():
22
+ return None
23
+
24
+ @staticmethod
25
+ def save_token(token, **kwargs):
26
+ # No-op: Spaces already handle tokens via environment
27
+ return None
28
+
29
+ @staticmethod
30
+ def get_token():
31
+ return None