Download src/hf_patch.py from Pteclub/Mock-app: direct link, hf CLI and curl.
- Browser
- Download file 843 Bytes
-
https://huggingface.co/spaces/Pteclub/Mock-app/resolve/main/src/hf_patch.py
- Command line
-
hf download hf://spaces/Pteclub/Mock-app/src/hf_patch.py
-
curl -L -o hf_patch.py https://huggingface.co/spaces/Pteclub/Mock-app/resolve/main/src/hf_patch.py
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 | |