Files
Gymnasium/tests/envs/spec_list.py

58 lines
1.4 KiB
Python
Raw Normal View History

from gym import envs, logger
import os
2021-07-29 15:39:42 -04:00
SKIP_MUJOCO_WARNING_MESSAGE = (
"Cannot run mujoco test (either license key not found or mujoco not"
"installed properly)."
)
2021-07-29 02:26:34 +02:00
skip_mujoco = not (os.environ.get("MUJOCO_KEY"))
if not skip_mujoco:
try:
import mujoco_py
except ImportError:
skip_mujoco = True
2021-07-29 02:26:34 +02:00
def should_skip_env_spec_for_tests(spec):
# We skip tests for envs that require dependencies or are otherwise
# troublesome to run frequently
2019-07-12 13:59:33 -04:00
ep = spec.entry_point
# Skip mujoco tests for pull request CI
2021-07-29 15:39:42 -04:00
if skip_mujoco and (
ep.startswith("gym.envs.mujoco") or ep.startswith("gym.envs.robotics:")
):
return True
try:
import gym.envs.atari
except ImportError:
if ep.startswith("gym.envs.atari"):
return True
try:
import Box2D
except ImportError:
2021-07-29 02:26:34 +02:00
if ep.startswith("gym.envs.box2d"):
return True
2021-07-29 02:26:34 +02:00
if (
"GoEnv" in ep
or "HexEnv" in ep
2021-07-29 15:39:42 -04:00
or (
ep.startswith("gym.envs.atari")
2021-07-29 15:39:42 -04:00
and not spec.id.startswith("Pong")
and not spec.id.startswith("Seaquest")
)
):
logger.warn("Skipping tests for env {}".format(ep))
return True
return False
2021-07-29 02:26:34 +02:00
spec_list = [
spec
for spec in sorted(envs.registry.all(), key=lambda x: x.id)
if spec.entry_point is not None and not should_skip_env_spec_for_tests(spec)
]