File size: 843 Bytes
9d47f6c | 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 | # Fix missing imports in newer huggingface_hub that Gradio Client still expects
import sys
import types
# Create a fake huggingface_hub module or extend existing one
import huggingface_hub
fake = huggingface_hub
# Add missing symbols if not present
if not hasattr(fake, "HfFolder"):
fake.HfFolder = object
if not hasattr(fake, "CommitOperationAdd"):
class CommitOperationAdd:
def __init__(self, *args, **kwargs):
pass
fake.CommitOperationAdd = CommitOperationAdd
if not hasattr(fake, "SpaceHardware"):
class SpaceHardware:
T4_SMALL = "t4-small"
fake.SpaceHardware = SpaceHardware
if not hasattr(fake, "SpaceStage"):
class SpaceStage:
RUNNING = "RUNNING"
fake.SpaceStage = SpaceStage
# Replace module so Gradio imports patched version
sys.modules["huggingface_hub"] = fake
|