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

0 commit comments

Comments
 (0)