Add policies/factory, Add test, Add _self_ in config

This commit is contained in:
Cadene
2024-02-25 10:50:23 +00:00
parent 64b5920e94
commit 598bb496b0
13 changed files with 61 additions and 38 deletions

0
test/__init__.py Normal file
View File

View File

@@ -6,6 +6,8 @@ from lerobot.common.envs.factory import make_env
from lerobot.common.envs.pusht import PushtEnv
from lerobot.common.envs.simxarm import SimxarmEnv
from .utils import init_config
def print_spec_rollout(env):
print("observation_spec:", env.observation_spec)
@@ -83,14 +85,6 @@ def test_pusht(from_pixels, pixels_only):
],
)
def test_factory(config_name):
import hydra
from hydra import compose, initialize
config_path = "../lerobot/configs"
hydra.core.global_hydra.GlobalHydra.instance().clear()
initialize(config_path=config_path)
cfg = compose(config_name=config_name)
cfg = init_config(config_name)
env = make_env(cfg)
check_env_specs(env)

17
test/test_policies.py Normal file
View File

@@ -0,0 +1,17 @@
import pytest
from lerobot.common.policies.factory import make_policy
from .utils import init_config
@pytest.mark.parametrize(
"config_name",
[
"default",
"pusht",
],
)
def test_factory(config_name):
cfg = init_config(config_name)
policy = make_policy(cfg)

11
test/utils.py Normal file
View File

@@ -0,0 +1,11 @@
import hydra
from hydra import compose, initialize
CONFIG_PATH = "../lerobot/configs"
def init_config(config_name):
hydra.core.global_hydra.GlobalHydra.instance().clear()
initialize(config_path=CONFIG_PATH)
cfg = compose(config_name=config_name)
return cfg