Skip to content

Commit 5ea4f05

Browse files
authored
[CI,Feature] Upgrade to gymnasium (#898)
1 parent 74fdadc commit 5ea4f05

File tree

22 files changed

+383
-66
lines changed

22 files changed

+383
-66
lines changed

.circleci/unittest/linux/scripts/environment.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@ dependencies:
88
- hypothesis
99
- future
1010
- cloudpickle
11-
- gym
1211
- pygame
13-
- gym[accept-rom-license]
14-
- gym[atari]
1512
- moviepy
1613
- tqdm
1714
- pytest

.circleci/unittest/linux/scripts/setup_env.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,35 @@ fi
8686
pip install pip --upgrade
8787

8888
conda env update --file "${this_dir}/environment.yml" --prune
89+
90+
conda deactivate
91+
conda activate "${env_dir}"
92+
93+
if [[ $OSTYPE != 'darwin'* ]]; then
94+
# install ale-py: manylinux names are broken for CentOS so we need to manually download and
95+
# rename them
96+
PY_VERSION=$(python --version)
97+
echo "installing ale-py for ${PY_PY_VERSION}"
98+
if [[ $PY_VERSION == *"3.7"* ]]; then
99+
wget https://files.pythonhosted.org/packages/ab/fd/6615982d9460df7f476cad265af1378057eee9daaa8e0026de4cedbaffbd/ale_py-0.8.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
100+
pip install ale_py-0.8.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
101+
rm ale_py-0.8.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
102+
elif [[ $PY_VERSION == *"3.8"* ]]; then
103+
wget https://files.pythonhosted.org/packages/0f/8a/feed20571a697588bc4bfef05d6a487429c84f31406a52f8af295a0346a2/ale_py-0.8.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
104+
pip install ale_py-0.8.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
105+
rm ale_py-0.8.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
106+
elif [[ $PY_VERSION == *"3.9"* ]]; then
107+
wget https://files.pythonhosted.org/packages/a0/98/4316c1cedd9934f9a91b6e27a9be126043b4445594b40cfa391c8de2e5e8/ale_py-0.8.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
108+
pip install ale_py-0.8.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
109+
rm ale_py-0.8.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
110+
elif [[ $PY_VERSION == *"3.10"* ]]; then
111+
wget https://files.pythonhosted.org/packages/60/1b/3adde7f44f79fcc50d0a00a0643255e48024c4c3977359747d149dc43500/ale_py-0.8.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
112+
mv ale_py-0.8.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl ale_py-0.8.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
113+
pip install ale_py-0.8.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
114+
rm ale_py-0.8.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
115+
fi
116+
echo "installing gymnasium"
117+
pip install "gymnasium[atari,accept-rom-license]"
118+
else
119+
pip install "gymnasium[atari,accept-rom-license]"
120+
fi

.circleci/unittest/linux_examples/scripts/environment.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@ dependencies:
88
- hypothesis
99
- future
1010
- cloudpickle
11-
- gym
1211
- pygame
13-
- gym[accept-rom-license]
14-
- gym[atari]
1512
- moviepy
1613
- tqdm
1714
- pytest

.circleci/unittest/linux_examples/scripts/setup_env.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,33 @@ fi
8686
pip install pip --upgrade
8787

8888
conda env update --file "${this_dir}/environment.yml" --prune
89+
90+
conda deactivate
91+
conda activate "${env_dir}"
92+
93+
if [[ $OSTYPE != 'darwin'* ]]; then
94+
# install ale-py: manylinux names are broken for CentOS so we need to manually download and
95+
# rename them
96+
PY_VERSION=$(python --version)
97+
if [[ $PY_VERSION == *"3.7"* ]]; then
98+
wget https://files.pythonhosted.org/packages/ab/fd/6615982d9460df7f476cad265af1378057eee9daaa8e0026de4cedbaffbd/ale_py-0.8.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
99+
pip install ale_py-0.8.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
100+
rm ale_py-0.8.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
101+
elif [[ $PY_VERSION == *"3.8"* ]]; then
102+
wget https://files.pythonhosted.org/packages/0f/8a/feed20571a697588bc4bfef05d6a487429c84f31406a52f8af295a0346a2/ale_py-0.8.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
103+
pip install ale_py-0.8.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
104+
rm ale_py-0.8.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
105+
elif [[ $PY_VERSION == *"3.9"* ]]; then
106+
wget https://files.pythonhosted.org/packages/a0/98/4316c1cedd9934f9a91b6e27a9be126043b4445594b40cfa391c8de2e5e8/ale_py-0.8.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
107+
pip install ale_py-0.8.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
108+
rm ale_py-0.8.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
109+
elif [[ $PY_VERSION == *"3.10"* ]]; then
110+
wget https://files.pythonhosted.org/packages/60/1b/3adde7f44f79fcc50d0a00a0643255e48024c4c3977359747d149dc43500/ale_py-0.8.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
111+
mv ale_py-0.8.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl ale_py-0.8.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
112+
pip install ale_py-0.8.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
113+
rm ale_py-0.8.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
114+
fi
115+
pip install "gymnasium[atari,accept-rom-license]"
116+
else
117+
pip install "gymnasium[atari,accept-rom-license]"
118+
fi

.circleci/unittest/linux_libs/scripts_envpool/environment.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@ dependencies:
88
- hypothesis
99
- future
1010
- cloudpickle
11-
- gym
1211
- pygame
13-
- gym[accept-rom-license]
14-
- gym[atari]
1512
- moviepy
1613
- pytest-cov
1714
- pytest-mock
@@ -22,4 +19,3 @@ dependencies:
2219
- scipy
2320
- dm_control
2421
- coverage
25-
- envpool

.circleci/unittest/linux_libs/scripts_envpool/setup_env.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,37 @@ cat "${this_dir}/environment.yml"
4646
pip install pip --upgrade
4747

4848
conda env update --file "${this_dir}/environment.yml" --prune
49+
50+
conda deactivate
51+
conda activate "${env_dir}"
52+
53+
if [[ $OSTYPE != 'darwin'* ]]; then
54+
# install ale-py: manylinux names are broken for CentOS so we need to manually download and
55+
# rename them
56+
PY_VERSION=$(python --version)
57+
echo "installing ale-py for ${PY_PY_VERSION}"
58+
if [[ $PY_VERSION == *"3.7"* ]]; then
59+
wget https://files.pythonhosted.org/packages/ab/fd/6615982d9460df7f476cad265af1378057eee9daaa8e0026de4cedbaffbd/ale_py-0.8.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
60+
pip install ale_py-0.8.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
61+
rm ale_py-0.8.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
62+
elif [[ $PY_VERSION == *"3.8"* ]]; then
63+
wget https://files.pythonhosted.org/packages/0f/8a/feed20571a697588bc4bfef05d6a487429c84f31406a52f8af295a0346a2/ale_py-0.8.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
64+
pip install ale_py-0.8.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
65+
rm ale_py-0.8.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
66+
elif [[ $PY_VERSION == *"3.9"* ]]; then
67+
wget https://files.pythonhosted.org/packages/a0/98/4316c1cedd9934f9a91b6e27a9be126043b4445594b40cfa391c8de2e5e8/ale_py-0.8.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
68+
pip install ale_py-0.8.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
69+
rm ale_py-0.8.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
70+
elif [[ $PY_VERSION == *"3.10"* ]]; then
71+
wget https://files.pythonhosted.org/packages/60/1b/3adde7f44f79fcc50d0a00a0643255e48024c4c3977359747d149dc43500/ale_py-0.8.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
72+
mv ale_py-0.8.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl ale_py-0.8.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
73+
pip install ale_py-0.8.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
74+
rm ale_py-0.8.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
75+
fi
76+
echo "installing gym"
77+
# envpool does not currently work with gymnasium
78+
pip install "gym[atari,accept-rom-license]"
79+
else
80+
pip install "gym[atari,accept-rom-license]"
81+
fi
82+
pip install envpool

.circleci/unittest/linux_libs/scripts_gym/batch_scripts.sh

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,49 @@ do
103103
conda deactivate
104104
conda env remove --prefix ./cloned_env
105105
done
106+
107+
# For this version "gym[accept-rom-license]" is required.
108+
for GYM_VERSION in '0.27'
109+
do
110+
# Create a copy of the conda env and work with this
111+
conda deactivate
112+
conda create --prefix ./cloned_env --clone ./env -y
113+
conda activate ./cloned_env
114+
115+
echo "Testing gym version: ${GYM_VERSION}"
116+
pip3 install 'gymnasium[accept-rom-license]'==$GYM_VERSION
117+
118+
119+
if [[ $OSTYPE != 'darwin'* ]]; then
120+
# install ale-py: manylinux names are broken for CentOS so we need to manually download and
121+
# rename them
122+
PY_VERSION=$(python --version)
123+
if [[ $PY_VERSION == *"3.7"* ]]; then
124+
wget https://files.pythonhosted.org/packages/ab/fd/6615982d9460df7f476cad265af1378057eee9daaa8e0026de4cedbaffbd/ale_py-0.8.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
125+
pip install ale_py-0.8.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
126+
rm ale_py-0.8.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
127+
elif [[ $PY_VERSION == *"3.8"* ]]; then
128+
wget https://files.pythonhosted.org/packages/0f/8a/feed20571a697588bc4bfef05d6a487429c84f31406a52f8af295a0346a2/ale_py-0.8.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
129+
pip install ale_py-0.8.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
130+
rm ale_py-0.8.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
131+
elif [[ $PY_VERSION == *"3.9"* ]]; then
132+
wget https://files.pythonhosted.org/packages/a0/98/4316c1cedd9934f9a91b6e27a9be126043b4445594b40cfa391c8de2e5e8/ale_py-0.8.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
133+
pip install ale_py-0.8.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
134+
rm ale_py-0.8.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
135+
elif [[ $PY_VERSION == *"3.10"* ]]; then
136+
wget https://files.pythonhosted.org/packages/60/1b/3adde7f44f79fcc50d0a00a0643255e48024c4c3977359747d149dc43500/ale_py-0.8.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
137+
mv ale_py-0.8.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl ale_py-0.8.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
138+
pip install ale_py-0.8.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
139+
rm ale_py-0.8.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
140+
fi
141+
pip install gymnasium[atari]
142+
else
143+
pip install gymnasium[atari]
144+
fi
145+
146+
$DIR/run_test.sh
147+
148+
# delete the conda copy
149+
conda deactivate
150+
conda env remove --prefix ./cloned_env
151+
done

.circleci/unittest/linux_stable/scripts/environment.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@ dependencies:
99
- hypothesis
1010
- future
1111
- cloudpickle
12-
- gym
1312
- pygame
14-
- gym[accept-rom-license]
15-
- gym[atari]
1613
- moviepy
1714
- tqdm
1815
- pytest

.circleci/unittest/linux_stable/scripts/setup_env.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,35 @@ fi
8686
pip install pip --upgrade
8787

8888
conda env update --file "${this_dir}/environment.yml" --prune
89+
90+
conda deactivate
91+
conda activate "${env_dir}"
92+
93+
if [[ $OSTYPE != 'darwin'* ]]; then
94+
# install ale-py: manylinux names are broken for CentOS so we need to manually download and
95+
# rename them
96+
PY_VERSION=$(python --version)
97+
echo "installing ale-py for ${PY_PY_VERSION}"
98+
if [[ $PY_VERSION == *"3.7"* ]]; then
99+
wget https://files.pythonhosted.org/packages/ab/fd/6615982d9460df7f476cad265af1378057eee9daaa8e0026de4cedbaffbd/ale_py-0.8.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
100+
pip install ale_py-0.8.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
101+
rm ale_py-0.8.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
102+
elif [[ $PY_VERSION == *"3.8"* ]]; then
103+
wget https://files.pythonhosted.org/packages/0f/8a/feed20571a697588bc4bfef05d6a487429c84f31406a52f8af295a0346a2/ale_py-0.8.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
104+
pip install ale_py-0.8.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
105+
rm ale_py-0.8.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
106+
elif [[ $PY_VERSION == *"3.9"* ]]; then
107+
wget https://files.pythonhosted.org/packages/a0/98/4316c1cedd9934f9a91b6e27a9be126043b4445594b40cfa391c8de2e5e8/ale_py-0.8.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
108+
pip install ale_py-0.8.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
109+
rm ale_py-0.8.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
110+
elif [[ $PY_VERSION == *"3.10"* ]]; then
111+
wget https://files.pythonhosted.org/packages/60/1b/3adde7f44f79fcc50d0a00a0643255e48024c4c3977359747d149dc43500/ale_py-0.8.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
112+
mv ale_py-0.8.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl ale_py-0.8.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
113+
pip install ale_py-0.8.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
114+
rm ale_py-0.8.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
115+
fi
116+
echo "installing gymnasium"
117+
pip install "gymnasium[atari,accept-rom-license]"
118+
else
119+
pip install "gymnasium[atari,accept-rom-license]"
120+
fi

test/_utils_internal.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,16 @@ def _set_gym_environments(): # noqa: F811
5858
PONG_VERSIONED = "ALE/Pong-v5"
5959

6060

61+
@implement_for("gymnasium", "0.27.0", None)
62+
def _set_gym_environments(): # noqa: F811
63+
global CARTPOLE_VERSIONED, HALFCHEETAH_VERSIONED, PENDULUM_VERSIONED, PONG_VERSIONED
64+
65+
CARTPOLE_VERSIONED = "CartPole-v1"
66+
HALFCHEETAH_VERSIONED = "HalfCheetah-v4"
67+
PENDULUM_VERSIONED = "Pendulum-v1"
68+
PONG_VERSIONED = "ALE/Pong-v5"
69+
70+
6171
if _has_gym:
6272
_set_gym_environments()
6373

test/smoke_test_deps.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,16 @@ def test_dm_control_pixels():
3737

3838

3939
def test_gym():
40-
import gym # noqa: F401
40+
try:
41+
import gymnasium as gym
42+
except ImportError as err:
43+
ERROR = err
44+
try:
45+
import gym # noqa: F401
46+
except ImportError as err:
47+
raise ImportError(
48+
f"gym and gymnasium load failed. Gym got error {err}."
49+
) from ERROR
4150

4251
assert _has_gym
4352
env = GymEnv(PONG_VERSIONED)

test/test_env.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@
4848

4949
gym_version = None
5050
if _has_gym:
51-
import gym
51+
try:
52+
import gymnasium as gym
53+
except ModuleNotFoundError:
54+
import gym
5255

5356
gym_version = version.parse(gym.__version__)
5457

@@ -1055,7 +1058,10 @@ def test_batch_unlocked_with_batch_size(device):
10551058
)
10561059
@pytest.mark.parametrize("device", get_available_devices())
10571060
def test_info_dict_reader(device, seed=0):
1058-
import gym
1061+
try:
1062+
import gymnasium as gym
1063+
except ModuleNotFoundError:
1064+
import gym
10591065

10601066
env = GymWrapper(gym.make(HALFCHEETAH_VERSIONED), device=device)
10611067
env.set_info_dict_reader(default_info_dict_reader(["x_position"]))

test/test_libs.py

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,23 @@
3535
from torchrl.modules import ActorCriticOperator, MLP, SafeModule, ValueOperator
3636

3737
if _has_gym:
38-
import gym
39-
40-
gym_version = version.parse(gym.__version__)
41-
if gym_version > version.parse("0.19"):
42-
from gym.wrappers.pixel_observation import PixelObservationWrapper
43-
else:
44-
from torchrl.envs.libs.utils import (
45-
GymPixelObservationWrapper as PixelObservationWrapper,
46-
)
38+
try:
39+
import gymnasium as gym
40+
from gymnasium import __version__ as gym_version
41+
42+
gym_version = version.parse(gym_version)
43+
from gymnasium.wrappers.pixel_observation import PixelObservationWrapper
44+
except ModuleNotFoundError:
45+
import gym
46+
47+
gym_version = version.parse(gym.__version__)
48+
if gym_version > version.parse("0.19"):
49+
from gym.wrappers.pixel_observation import PixelObservationWrapper
50+
else:
51+
from torchrl.envs.libs.utils import (
52+
GymPixelObservationWrapper as PixelObservationWrapper,
53+
)
54+
4755

4856
if _has_dmc:
4957
from dm_control import suite
@@ -163,6 +171,11 @@ def _make_gym_environment(env_name): # noqa: F811
163171
return gym.make(env_name, render_mode="rgb_array")
164172

165173

174+
@implement_for("gymnasium", "0.27", None)
175+
def _make_gym_environment(env_name): # noqa: F811
176+
return gym.make(env_name, render_mode="rgb_array")
177+
178+
166179
@pytest.mark.skipif(not _has_dmc, reason="no dm_control library found")
167180
@pytest.mark.parametrize("env_name,task", [["cheetah", "run"]])
168181
@pytest.mark.parametrize("frame_skip", [1, 3])
@@ -281,7 +294,7 @@ def test_td_creation_from_spec(env_lib, env_args, env_kwargs):
281294
and env_kwargs.get("from_pixels", False)
282295
and torch.cuda.device_count() == 0
283296
):
284-
pytest.skip(
297+
raise pytest.skip(
285298
"Skipping test as rendering is not supported in tests before gym 0.26."
286299
)
287300
env = env_lib(*env_args, **env_kwargs)

test/test_specs.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -994,11 +994,6 @@ def test_equality_composite(self):
994994
assert ts != ts_other
995995

996996

997-
if __name__ == "__main__":
998-
args, unknown = argparse.ArgumentParser().parse_known_args()
999-
pytest.main([__file__, "--capture", "no", "--exitfirst"] + unknown)
1000-
1001-
1002997
class TestSpec:
1003998
@pytest.mark.parametrize(
1004999
"action_spec_cls", [OneHotDiscreteTensorSpec, DiscreteTensorSpec]
@@ -1672,3 +1667,8 @@ def test_unboundeddiscrete(
16721667
spec = UnboundedDiscreteTensorSpec(shape=shape1, device="cpu", dtype=torch.long)
16731668
assert spec == spec.clone()
16741669
assert spec is not spec.clone()
1670+
1671+
1672+
if __name__ == "__main__":
1673+
args, unknown = argparse.ArgumentParser().parse_known_args()
1674+
pytest.main([__file__, "--capture", "no", "--exitfirst"] + unknown)

0 commit comments

Comments
 (0)