Download tests/test_zero_gpu.py from build-small-hackathon/Scriptorium: direct link, hf CLI and curl.
- Browser
- Download file 848 Bytes
-
https://huggingface.co/spaces/build-small-hackathon/Scriptorium/resolve/main/tests/test_zero_gpu.py
- Command line
-
hf download hf://spaces/build-small-hackathon/Scriptorium/tests/test_zero_gpu.py
-
curl -L -o test_zero_gpu.py https://huggingface.co/spaces/build-small-hackathon/Scriptorium/resolve/main/tests/test_zero_gpu.py
848 Bytes
| import importlib | |
| import sys | |
| from types import SimpleNamespace | |
| def test_omnivoice_adapter_registers_zero_gpu_decorator(monkeypatch) -> None: | |
| decorated = {} | |
| def fake_gpu(fn=None, **kwargs): | |
| def decorate(inner): | |
| decorated["name"] = inner.__name__ | |
| decorated["kwargs"] = kwargs | |
| setattr(inner, "_zero_gpu_wrapped", True) | |
| return inner | |
| if fn is not None: | |
| return decorate(fn) | |
| return decorate | |
| monkeypatch.setitem(sys.modules, "spaces", SimpleNamespace(GPU=fake_gpu)) | |
| sys.modules.pop("backend.omnivoice_adapter", None) | |
| module = importlib.import_module("backend.omnivoice_adapter") | |
| assert decorated == {"name": "synthesize", "kwargs": {"duration": 300}} | |
| assert getattr(module.OmniVoiceAdapter.synthesize, "_zero_gpu_wrapped", False) is True | |