Mock-app / src /hf_patch.py
mohdomer's picture
Create hf_patch.py
9d47f6c verified
Raw History Blame Contribute Delete
843 Bytes
# 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