Spaces:
Running on L40S
Running on L40S
Download cosmos-framework/cosmos_framework/utils/timer_test.py from nvidia/Cosmos3-Action-Viewer: direct link, hf CLI and curl.
- Browser
- Download file 516 Bytes
-
https://huggingface.co/spaces/nvidia/Cosmos3-Action-Viewer/resolve/main/cosmos-framework/cosmos_framework/utils/timer_test.py
- Command line
-
hf download hf://spaces/nvidia/Cosmos3-Action-Viewer/cosmos-framework/cosmos_framework/utils/timer_test.py
-
curl -L -o timer_test.py https://huggingface.co/spaces/nvidia/Cosmos3-Action-Viewer/resolve/main/cosmos-framework/cosmos_framework/utils/timer_test.py
516 Bytes
| import pytest | |
| from cosmos_framework.utils.timer import Timer | |
| def test_timer_decorator_resets_after_exception(): | |
| timer = Timer(measure_cpu=True, measure_cuda=False, debug=True) | |
| calls = 0 | |
| def fail_once(): | |
| nonlocal calls | |
| calls += 1 | |
| if calls == 1: | |
| raise RuntimeError("first call failed") | |
| return "ok" | |
| with pytest.raises(RuntimeError, match="first call failed"): | |
| fail_once() | |
| assert timer.busy is False | |
| assert fail_once() == "ok" | |