Files
Gymnasium/tests/envs/spec_list.py
Mark Towers 0263deb5ab Add support for python 3.6 (#2836)
* Add support for python 3.6

* Add support for python 3.6

* Added check for python 3.6 to not install mujoco as no version exists

* Fixed the install groups for python 3.6

* Re-added python 3.6 support for gym

* black

* Added support for dataclasses through dataclasses module in setup that backports the module

* Fixed install requirements

* Re-added dummy env spec with dataclasses

* Changed type for compatability for python 3.6

* Added a python 3.6 warning

* Fixed python 3.6 typing issue

* Removed __future__ import annotation for python 3.6 support

* Fixed python 3.6 typing
2022-05-25 10:28:19 -04:00

71 lines
1.8 KiB
Python

from gym import envs, logger
SKIP_MUJOCO_V3_WARNING_MESSAGE = (
"Cannot run mujoco test because `mujoco-py` is not installed"
)
SKIP_MUJOCO_V4_WARNING_MESSAGE = (
"Cannot run mujoco test because `mujoco` is not installed"
)
skip_mujoco_v3 = False
try:
import mujoco_py # noqa:F401
except ImportError:
skip_mujoco_v3 = True
skip_mujoco_v4 = False
try:
import mujoco # noqa:F401
except ImportError:
skip_mujoco_v4 = True
def should_skip_env_spec_for_tests(spec):
# We skip tests for envs that require dependencies or are otherwise
# troublesome to run frequently
ep = spec.entry_point
# Skip mujoco tests for pull request CI
if (skip_mujoco_v3 or skip_mujoco_v4) and ep.startswith("gym.envs.mujoco"):
return True
try:
import gym.envs.atari # noqa:F401
except ImportError:
if ep.startswith("gym.envs.atari"):
return True
try:
import Box2D # noqa:F401
except ImportError:
if ep.startswith("gym.envs.box2d"):
return True
if (
"GoEnv" in ep
or "HexEnv" in ep
or (
ep.startswith("gym.envs.atari")
and not spec.id.startswith("Pong")
and not spec.id.startswith("Seaquest")
)
):
logger.warn(f"Skipping tests for env {ep}")
return True
return False
def skip_mujoco_py_env_for_test(spec):
ep = spec.entry_point
version = spec.version
if ep.startswith("gym.envs.mujoco") and version < 4:
return True
return False
spec_list = [
spec
for spec in sorted(envs.registry.values(), key=lambda x: x.id)
if spec.entry_point is not None and not should_skip_env_spec_for_tests(spec)
]
spec_list_no_mujoco_py = [
spec for spec in spec_list if not skip_mujoco_py_env_for_test(spec)
]