forked from tangger/lerobot
Add policies/factory, Add test, Add _self_ in config
This commit is contained in:
0
test/__init__.py
Normal file
0
test/__init__.py
Normal 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
17
test/test_policies.py
Normal 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
11
test/utils.py
Normal 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
|
||||
Reference in New Issue
Block a user