Add regression tests (#119)
- Add `tests/scripts/save_policy_to_safetensor.py` to generate test artifacts - Add `test_backward_compatibility to test generated outputs from the policies against artifacts
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import platform
|
||||
|
||||
import pytest
|
||||
import torch
|
||||
|
||||
@@ -9,6 +11,51 @@ DEFAULT_CONFIG_PATH = "lerobot/configs/default.yaml"
|
||||
DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
|
||||
|
||||
|
||||
def require_x86_64_kernel(func):
|
||||
"""
|
||||
Decorator that skips the test if plateform device is not an x86_64 cpu.
|
||||
"""
|
||||
from functools import wraps
|
||||
|
||||
@wraps(func)
|
||||
def wrapper(*args, **kwargs):
|
||||
if platform.machine() != "x86_64":
|
||||
pytest.skip("requires x86_64 plateform")
|
||||
return func(*args, **kwargs)
|
||||
|
||||
return wrapper
|
||||
|
||||
|
||||
def require_cpu(func):
|
||||
"""
|
||||
Decorator that skips the test if device is not cpu.
|
||||
"""
|
||||
from functools import wraps
|
||||
|
||||
@wraps(func)
|
||||
def wrapper(*args, **kwargs):
|
||||
if DEVICE != "cpu":
|
||||
pytest.skip("requires cpu")
|
||||
return func(*args, **kwargs)
|
||||
|
||||
return wrapper
|
||||
|
||||
|
||||
def require_cuda(func):
|
||||
"""
|
||||
Decorator that skips the test if cuda is not available.
|
||||
"""
|
||||
from functools import wraps
|
||||
|
||||
@wraps(func)
|
||||
def wrapper(*args, **kwargs):
|
||||
if not torch.cuda.is_available():
|
||||
pytest.skip("requires cuda")
|
||||
return func(*args, **kwargs)
|
||||
|
||||
return wrapper
|
||||
|
||||
|
||||
def require_env(func):
|
||||
"""
|
||||
Decorator that skips the test if the required environment package is not installed.
|
||||
|
||||
Reference in New Issue
Block a user