fancy_gym/test/test_metaworld_envs.py

38 lines
1.3 KiB
Python
Raw Normal View History

2022-09-26 09:46:53 +02:00
from itertools import chain
import pytest
from metaworld.envs import ALL_V2_ENVIRONMENTS_GOAL_OBSERVABLE
import fancy_gym
from test.utils import run_env, run_env_determinism
METAWORLD_IDS = [f'metaworld:{env.split("-goal-observable")[0]}' for env, _ in
ALL_V2_ENVIRONMENTS_GOAL_OBSERVABLE.items()]
METAWORLD_MP_IDS = chain(*fancy_gym.ALL_METAWORLD_MOVEMENT_PRIMITIVE_ENVIRONMENTS.values())
print(METAWORLD_MP_IDS)
SEED = 1
@pytest.mark.parametrize('env_id', METAWORLD_IDS)
def test_step_metaworld_functionality(env_id: str):
"""Tests that step environments run without errors using random actions."""
run_env(env_id)
@pytest.mark.parametrize('env_id', METAWORLD_IDS)
def test_step_metaworld_determinism(env_id: str):
"""Tests that for step environments identical seeds produce identical trajectories."""
run_env_determinism(env_id, SEED)
@pytest.mark.parametrize('env_id', METAWORLD_MP_IDS)
def test_bb_metaworld_functionality(env_id: str):
"""Tests that black box environments run without errors using random actions."""
run_env(env_id)
@pytest.mark.parametrize('env_id', METAWORLD_MP_IDS)
def test_bb_metaworld_determinism(env_id: str):
"""Tests that for black box environment identical seeds produce identical trajectories."""
run_env_determinism(env_id, SEED)