2022-03-31 12:50:38 -07:00
|
|
|
from gym import envs, logger
|
2019-08-09 15:16:44 -07:00
|
|
|
|
2022-05-24 08:47:51 -04:00
|
|
|
SKIP_MUJOCO_V3_WARNING_MESSAGE = (
|
|
|
|
"Cannot run mujoco test because mujoco-py is not installed"
|
2021-07-29 15:39:42 -04:00
|
|
|
)
|
2019-08-09 15:16:44 -07:00
|
|
|
|
2022-05-24 08:47:51 -04:00
|
|
|
skip_mujoco_v3 = False
|
|
|
|
try:
|
|
|
|
import mujoco_py # noqa:F401
|
|
|
|
except ImportError:
|
|
|
|
skip_mujoco_v3 = True
|
2019-02-25 15:12:06 -08:00
|
|
|
|
2021-07-29 02:26:34 +02:00
|
|
|
|
2017-02-11 22:17:02 -08: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
|
2017-02-11 22:17:02 -08:00
|
|
|
# Skip mujoco tests for pull request CI
|
2022-05-24 08:47:51 -04:00
|
|
|
if skip_mujoco_v3 and ep.startswith("gym.envs.mujoco"):
|
2017-02-11 22:17:02 -08:00
|
|
|
return True
|
2019-02-08 11:46:51 -08:00
|
|
|
try:
|
Update the flake8 pre-commit ignores (#2778)
* Remove additional ignores from flake8
* Remove all unused imports
* Remove all unused imports
* Update flake8 and pyupgrade
* F841, removed unused variables
* E731, removed lambda assignment to variables
* Remove E731, F403, F405, F524
* Remove E722, bare exceptions
* Remove E712, compare variable == True or == False to is True or is False
* Remove E402, module level import not at top of file
* Added --pre-file-ignores
* Add --per-file-ignores removing E741, E302 and E704
* Add E741, do not use variables named ‘l’, ‘O’, or ‘I’ to ignore issues in classic control
* Fixed issues for pytest==6.2
* Remove unnecessary # noqa
* Edit comment with the removal of E302
* Added warnings and declared module, attr for pyright type hinting
* Remove unused import
* Removed flake8 E302
* Updated flake8 from 3.9.2 to 4.0.1
* Remove unused variable
2022-04-26 16:18:37 +01:00
|
|
|
import gym.envs.atari # noqa:F401
|
2019-02-08 11:46:51 -08:00
|
|
|
except ImportError:
|
2021-09-22 17:11:21 -06:00
|
|
|
if ep.startswith("gym.envs.atari"):
|
2019-02-08 11:46:51 -08:00
|
|
|
return True
|
|
|
|
try:
|
Update the flake8 pre-commit ignores (#2778)
* Remove additional ignores from flake8
* Remove all unused imports
* Remove all unused imports
* Update flake8 and pyupgrade
* F841, removed unused variables
* E731, removed lambda assignment to variables
* Remove E731, F403, F405, F524
* Remove E722, bare exceptions
* Remove E712, compare variable == True or == False to is True or is False
* Remove E402, module level import not at top of file
* Added --pre-file-ignores
* Add --per-file-ignores removing E741, E302 and E704
* Add E741, do not use variables named ‘l’, ‘O’, or ‘I’ to ignore issues in classic control
* Fixed issues for pytest==6.2
* Remove unnecessary # noqa
* Edit comment with the removal of E302
* Added warnings and declared module, attr for pyright type hinting
* Remove unused import
* Removed flake8 E302
* Updated flake8 from 3.9.2 to 4.0.1
* Remove unused variable
2022-04-26 16:18:37 +01:00
|
|
|
import Box2D # noqa:F401
|
2019-02-08 11:46:51 -08:00
|
|
|
except ImportError:
|
2021-07-29 02:26:34 +02:00
|
|
|
if ep.startswith("gym.envs.box2d"):
|
2019-02-08 11:46:51 -08:00
|
|
|
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 (
|
2021-09-22 17:11:21 -06:00
|
|
|
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")
|
|
|
|
)
|
2017-02-11 22:17:02 -08:00
|
|
|
):
|
2022-01-11 18:12:05 +01:00
|
|
|
logger.warn(f"Skipping tests for env {ep}")
|
2017-02-11 22:17:02 -08:00
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
2021-07-29 02:26:34 +02:00
|
|
|
|
2022-05-24 08:47:51 -04:00
|
|
|
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
|
|
|
|
|
|
|
|
|
2021-07-29 02:26:34 +02:00
|
|
|
spec_list = [
|
|
|
|
spec
|
2022-04-21 20:41:15 +02:00
|
|
|
for spec in sorted(envs.registry.values(), key=lambda x: x.id)
|
2021-07-29 02:26:34 +02:00
|
|
|
if spec.entry_point is not None and not should_skip_env_spec_for_tests(spec)
|
|
|
|
]
|
2022-05-24 08:47:51 -04:00
|
|
|
spec_list_no_mujoco_py = [
|
|
|
|
spec for spec in spec_list if not skip_mujoco_py_env_for_test(spec)
|
|
|
|
]
|