Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Gym 0.26 support #780

Closed
wants to merge 201 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
201 commits
Select commit Hold shift + click to select a range
ee71299
Remove references to GoalEnv
carlosluis Feb 19, 2022
65343f5
Fix env tests
carlosluis Feb 19, 2022
4d794f3
Fix bug in test creating invalid box space
carlosluis Feb 19, 2022
513ed08
Add classic_control extra packages from gym
carlosluis Feb 21, 2022
861b612
Merge branch 'master' into fix_tests
araffin Feb 21, 2022
2277012
Merge branch 'master' into fix_tests
carlosluis Feb 28, 2022
e5195a0
Change back to gym 0.22 for testing
carlosluis Feb 28, 2022
435f5fb
Fix failing set_env test
carlosluis Feb 28, 2022
f64346a
Fix test failiing due to deprectation of env.seed
carlosluis Mar 3, 2022
9efc37b
Merge branch 'master' into fix_tests
carlosluis Mar 7, 2022
daaa84c
Adjust mean reward threshold in failing test
carlosluis Mar 8, 2022
e62edde
Fix her test failing due to rng
carlosluis Mar 8, 2022
9a41c51
Change seed and revert reward threshold to 90
carlosluis Mar 8, 2022
41f260b
Merge branch 'master' into fix_tests
carlosluis Mar 16, 2022
9c73732
Pin gym version
carlosluis Mar 16, 2022
110be78
Make VecEnv compatible with gym seeding change
carlosluis Mar 16, 2022
dc9c645
Revert change to VecEnv reset signature
carlosluis Mar 17, 2022
e1c6e1b
Change subprocenv seed cmd to call reset instead
carlosluis Mar 17, 2022
29bd222
Fix type check
carlosluis Mar 17, 2022
b1730f4
Add backward compat
araffin Mar 17, 2022
3297091
Merge branch 'master' into fix_tests
araffin Mar 25, 2022
00e7946
Add `compat_gym_seed` helper
araffin Mar 25, 2022
ecf02ce
Merge branch 'master' into fix_tests
araffin Mar 28, 2022
f0e1ccb
Merge branch 'master' into fix_tests
carlosluis Apr 11, 2022
a116a1a
Add goal env checks in env_checker
carlosluis Apr 11, 2022
8780919
Add docs on HER requirements for envs
carlosluis Apr 11, 2022
e0db1ed
Merge branch 'master' into fix_tests
carlosluis Apr 11, 2022
ff44a2f
Merge branch 'master' into fix_tests
araffin Apr 13, 2022
c2ab5cd
Capture user warning in test with inverted box space
carlosluis Apr 13, 2022
cb50e9e
Update ale-py version
araffin Apr 18, 2022
de3f086
Fix randint
araffin Apr 19, 2022
1980db2
Allow noop_max to be zero
araffin Apr 19, 2022
85087bc
Merge branch 'master' into fix_tests
araffin Apr 19, 2022
776217a
Merge branch 'master' into fix_tests
araffin Apr 25, 2022
fa40152
Merge branch 'master' into fix_tests
araffin May 8, 2022
90adf8f
Update changelog
araffin May 8, 2022
d0300c8
Merge branch 'master' into fix_tests
araffin May 8, 2022
25136d7
Merge branch 'master' into fix_tests
araffin May 10, 2022
ec9d50f
Merge branch 'master' into fix_tests
araffin May 10, 2022
0f240fa
Update docker image
araffin May 10, 2022
a6766bd
Merge branch 'fix_tests' of github.com:carlosluis/stable-baselines3 i…
araffin May 10, 2022
3087d58
Update doc conda env and dockerfile
araffin May 13, 2022
7629016
Custom envs should not have any warnings
araffin May 13, 2022
7bb643b
Fix test for numpy >= 1.21
araffin May 13, 2022
706f072
Add check for vectorized compute reward
araffin May 13, 2022
af8e51b
Merge branch 'master' into fix_tests
araffin May 29, 2022
77d188f
Bump to gym 0.24
araffin May 29, 2022
68cec40
Fix gym default step docstring
araffin May 29, 2022
0072b77
Test downgrading gym
araffin May 29, 2022
07a85b8
Revert "Test downgrading gym"
araffin May 29, 2022
d755cc6
Fix protobuf error
araffin May 29, 2022
99b91eb
Fix in dependencies
araffin May 29, 2022
1d7da08
Fix protobuf dep
araffin May 29, 2022
f205865
Merge branch 'master' into fix_tests
araffin May 29, 2022
cf7e438
Use newest version of cartpole
araffin May 29, 2022
3d6f28a
Merge branch 'master' into fix_tests
araffin May 31, 2022
626db1d
Update gym
araffin Jun 10, 2022
f864501
Fix warning
araffin Jun 14, 2022
3af1488
Merge branch 'master' into fix_tests
araffin Jun 23, 2022
5fa3cd9
Loosen required scipy version
araffin Jun 23, 2022
e79148b
Scipy no longer needed
araffin Jun 23, 2022
ebf73d6
Merge branch 'master' into fix_tests
araffin Jul 18, 2022
1ad5f78
Try gym 0.25
araffin Jul 18, 2022
3f0b531
Silence warnings from gym
araffin Jul 25, 2022
2fc09f7
Merge branch 'master' into fix_tests
araffin Jul 25, 2022
b27e555
Filter warnings during tests
araffin Jul 25, 2022
c1e01c9
Merge branch 'master' into fix_tests
araffin Jul 30, 2022
78ef1e4
Merge branch 'master' into fix_tests
araffin Aug 22, 2022
c4bf066
Merge branch 'master' into fix_tests
araffin Aug 22, 2022
ed0f79e
Merge branch 'master' into fix_tests
araffin Aug 25, 2022
ee52936
Merge branch 'master' into fix_tests
araffin Sep 7, 2022
5d3b07f
Merge branch 'master' into fix_tests
araffin Sep 16, 2022
99d2155
Merge branch 'master' into fix_tests
araffin Sep 26, 2022
a0d5c79
Merge branch 'master' into fix_tests
qgallouedec Sep 28, 2022
75fd27e
Merge branch 'master' into fix_tests
araffin Sep 30, 2022
8c65748
Update doc
araffin Oct 1, 2022
0874da1
Update requirements
araffin Oct 1, 2022
26ceefc
Add gym 26 compat in vec env
araffin Oct 1, 2022
a8c579a
Fixes in envs and tests for gym 0.26+
araffin Oct 1, 2022
6ed3079
Enforce gym 0.26 api
araffin Oct 1, 2022
0851440
Merge pull request #1 from carlosluis/fix_tests
tlpss Oct 2, 2022
95bb4d6
format
tlpss Oct 2, 2022
c4517f2
Fix formatting
araffin Oct 2, 2022
9ac7592
Fix dependencies
araffin Oct 2, 2022
d2e6873
Fix syntax
araffin Oct 2, 2022
969c1cf
Cleanup doc and warnings
araffin Oct 2, 2022
2fcd072
Faster tests
araffin Oct 2, 2022
dd67a20
Higher budget for HER perf test (revert prev change)
araffin Oct 2, 2022
ae04b20
Merge branch 'master' into fix_tests
araffin Oct 3, 2022
9ae6fa2
Fixes and update doc
araffin Oct 5, 2022
056454b
Fix doc build
araffin Oct 5, 2022
f9bbb29
Merge branch 'master' into fix_tests
araffin Oct 6, 2022
29dffed
Merge branch 'master' into fix_tests
araffin Oct 10, 2022
cf565d9
Merge branch 'master' into fix_tests
araffin Oct 13, 2022
ed191b0
Merge branch 'master' of https://github.com/DLR-RM/stable-baselines3 …
qgallouedec Oct 17, 2022
04aa926
Merge branch 'master' into fix_tests
araffin Oct 24, 2022
734e19f
Merge branch 'master' into fix_tests
araffin Oct 26, 2022
9ad927b
Fix breaking change
araffin Oct 31, 2022
3ca1b73
Fixes for rendering
araffin Oct 31, 2022
0f5374f
Rename variables in monitor
araffin Oct 31, 2022
9cf2c3d
Merge pull request #2 from carlosluis/fix_tests
tlpss Nov 3, 2022
3320e78
update render method for gym 0.26 API
tlpss Nov 3, 2022
1596ea4
update tests and docs to new gym render API
tlpss Nov 3, 2022
b4b911c
Merge branch 'master' into fix_tests
araffin Nov 7, 2022
008fdce
undo removal of render modes metatadata check
tlpss Nov 7, 2022
93bd988
set rgb_array as default render mode for gym.make
tlpss Nov 7, 2022
c9a29b9
Merge branch 'master' into fix_tests
araffin Nov 15, 2022
720317f
Merge branch 'master' into fix_tests
araffin Nov 16, 2022
53da2d0
undo changes & raise warning if not 'rgb_array'
tlpss Nov 20, 2022
8675011
Merge branch 'master' into fix_tests
araffin Nov 22, 2022
db81278
Merge branch 'master' into fix_tests
araffin Nov 25, 2022
54fb37e
Fix type check
araffin Nov 28, 2022
96793b9
Merge branch 'fix_tests' into fix_tests
araffin Nov 28, 2022
e30c117
Merge branch 'master' into fix_tests
qgallouedec Nov 28, 2022
07ca271
Remove recursion and fix type checking
araffin Nov 28, 2022
acd0420
Merge branch 'master' into fix_tests
araffin Nov 29, 2022
c0a6a18
Remove hacks for protobuf and gym 0.24
araffin Nov 29, 2022
b954703
Fix type annotations
araffin Nov 29, 2022
870139c
reuse existing render_mode attribute
tlpss Dec 3, 2022
bc5335f
return tiled images for 'human' render mode
tlpss Dec 3, 2022
c718106
Merge branch 'fix_tests' of https://github.com/carlosluis/stable-base…
tlpss Dec 3, 2022
11cf07f
Allow to use opencv for human render, fix typos
araffin Dec 6, 2022
9d91ea3
Merge pull request #4 from tlpss/tlss/fix_tests
araffin Dec 6, 2022
3f75a8a
Add warning when using non-zero start with Discrete (fixes #1197)
araffin Dec 7, 2022
08a4712
Merge branch 'master' into fix_tests
araffin Dec 10, 2022
93c86f2
Merge branch 'master' into fix_tests
araffin Dec 13, 2022
d35cfad
Merge branch 'master' into fix_tests
araffin Dec 18, 2022
6251fdc
Fix type checking
araffin Dec 18, 2022
be998e8
Merge branch 'fix_tests' of github.com:carlosluis/stable-baselines3 i…
araffin Dec 18, 2022
d24d30d
Merge branch 'fix_tests' into tlpss/fix_tests
araffin Dec 18, 2022
6b80c93
Bug fixes and handle more cases
araffin Dec 18, 2022
c09fa74
Throw proper warnings
araffin Dec 18, 2022
480a793
Update test
araffin Dec 18, 2022
e03b885
Fix new metadata name
araffin Dec 18, 2022
e4248df
Ignore numpy warnings
araffin Dec 18, 2022
16bb26b
Merge branch 'fix_tests' into tlpss/fix_tests
araffin Dec 18, 2022
1f8ccbe
Fixes in vec recorder
araffin Dec 18, 2022
f4e978a
Global ignore
araffin Dec 18, 2022
408e9c2
Merge branch 'fix_tests' into tlpss/fix_tests
araffin Dec 18, 2022
f98903a
Filter local warning too
araffin Dec 18, 2022
046c12b
Merge branch 'fix_tests' into tlpss/fix_tests
araffin Dec 18, 2022
595be86
Merge branch 'master' into fix_tests
araffin Dec 19, 2022
29086a5
Monkey patch not needed for gym 26
araffin Dec 19, 2022
254107a
Merge branch 'fix_tests' into tlpss/fix_tests
araffin Dec 19, 2022
6103962
Merge branch 'master' into fix_tests
araffin Dec 20, 2022
fbaa8ac
Merge branch 'fix_tests' into tlss/fix_tests
araffin Dec 20, 2022
20faf11
Merge branch 'master' into fix_tests
araffin Dec 22, 2022
01831b6
Merge branch 'master' into fix_tests
araffin Dec 22, 2022
3780476
Merge branch 'fix_tests' into tlpss/fix_tests
araffin Dec 22, 2022
085b4c8
Merge branch 'fix_tests' of github.com:tlpss/stable-baselines3 into t…
araffin Dec 22, 2022
6a3f45d
Add doc of VecEnv vs Gym API
araffin Dec 23, 2022
c645d49
Add render test
araffin Dec 23, 2022
3cf4d00
Merge pull request #3 from tlpss/fix_tests
araffin Dec 23, 2022
3f6413d
Fix return type
araffin Dec 23, 2022
ff609ad
Update VecEnv vs Gym API doc
araffin Dec 23, 2022
99589ce
Add note in the quickstart section
araffin Jan 2, 2023
cf75cdc
Merge branch 'master' into fix_tests
araffin Jan 2, 2023
3611f2c
Merge branch 'master' into fix_tests
araffin Jan 5, 2023
b428a27
Fix for custom render mode
araffin Jan 5, 2023
d98dc9e
Fix return type
araffin Jan 5, 2023
5c32861
Merge branch 'master' into fix_tests
araffin Jan 11, 2023
6eaecd2
Merge branch 'master' into fix_tests
araffin Jan 16, 2023
cd28666
Fix type checking
araffin Jan 16, 2023
4f796a0
Merge branch 'master' into fix_tests
araffin Jan 23, 2023
669ef02
Merge branch 'master' into fix_tests
araffin Jan 23, 2023
c9430ec
check test env test_buffer
qgallouedec Jan 24, 2023
546928c
skip render check
qgallouedec Jan 24, 2023
8462dbb
check env test_dict_env
qgallouedec Jan 24, 2023
205b987
test_env test_gae
qgallouedec Jan 24, 2023
1946082
check envs in remaining tests
qgallouedec Jan 24, 2023
7460782
Update tests
araffin Jan 25, 2023
0431c7a
Merge pull request #5 from DLR-RM/check_test_env
araffin Jan 25, 2023
e5575d8
Add warning for Discrete action space with non-zero (#1295)
araffin Jan 25, 2023
c951311
Merge branch 'master' into fix_tests
qgallouedec Jan 28, 2023
b787d98
Fix atari annotation
qgallouedec Jan 28, 2023
85bb0d4
ignore get_action_meanings [attr-defined]
qgallouedec Jan 28, 2023
ba5827e
Merge branch 'master' into fix_tests
araffin Feb 6, 2023
afa1c73
Fix mypy issues
araffin Feb 6, 2023
f03fd75
Merge branch 'master' into fix_tests
araffin Feb 11, 2023
40048ba
Merge branch 'master' into fix_tests
araffin Feb 11, 2023
75217fa
Fix undefined info
araffin Feb 13, 2023
cff332c
Merge branch 'fix_tests' of github.com:carlosluis/stable-baselines3 i…
araffin Feb 13, 2023
6da9b39
Merge branch 'master' into fix_tests
araffin Feb 25, 2023
06ad5a8
Rename done to terminated
araffin Feb 25, 2023
93c10cf
Fix pygame dependency for python 3.7
araffin Feb 25, 2023
c5a5d73
Merge branch 'master' into fix_tests
araffin Feb 27, 2023
51ffad2
Merge branch 'master' into fix_tests
araffin Mar 3, 2023
00b9bbb
Merge branch 'master' into fix_tests
araffin Mar 11, 2023
8a149f4
Merge branch 'fix_tests' of github.com:carlosluis/stable-baselines3 i…
araffin Mar 11, 2023
b82cacd
Forks don't have access to private variables
araffin Mar 11, 2023
07d2171
Merge branch 'master' into fix_tests
araffin Mar 12, 2023
d0f5e8a
Fix linter warnings
araffin Mar 12, 2023
d5c79b0
[ci skip] Merge branch 'master' into fix_tests
araffin Mar 14, 2023
e91b436
Merge branch 'master' into fix_tests
araffin Mar 20, 2023
5ec7e39
Merge branch 'fix_tests' of github.com:carlosluis/stable-baselines3 i…
araffin Mar 20, 2023
986e6c0
Fix env checker for GoalEnv
araffin Mar 20, 2023
2be728d
Merge branch 'master' into fix_tests
araffin Mar 29, 2023
331853a
Update env checker (more info) and fix dtype
araffin Mar 29, 2023
68861b6
Use micromamab for Docker
araffin Mar 29, 2023
9f0d5d8
Update dependencies
araffin Mar 29, 2023
6617e6e
Clarify VecEnv doc
araffin Mar 29, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
"extra": [
# For render
"opencv-python",
"pygame",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pygame is not used directly, but I assume it is listed, because some environments from gym(nasium) use pygame for rendering. Nevertheless, imho I think it is the responsibility of the environment to install all of its dependencies.

# For atari games,
"ale-py~=0.7.4",
"autorom[accept-rom-license]~=0.4.2",
Expand Down
4 changes: 2 additions & 2 deletions stable_baselines3/common/env_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ def _check_returned_values(env: gym.Env, observation_space: spaces.Space, action
assert isinstance(done, bool), "The `done` signal must be a boolean"
assert isinstance(info, dict), "The `info` returned by `step()` must be a python dictionary"

if isinstance(env, gym.GoalEnv):
# For a GoalEnv, the keys are checked at reset
# Goal conditioned env
if hasattr(env, "compute_reward"):
assert reward == env.compute_reward(obs["achieved_goal"], obs["desired_goal"], info)


Expand Down
4 changes: 2 additions & 2 deletions stable_baselines3/common/envs/bit_flipping_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
from typing import Any, Dict, Optional, Union

import numpy as np
from gym import GoalEnv, spaces
from gym import Env, spaces
from gym.envs.registration import EnvSpec

from stable_baselines3.common.type_aliases import GymStepReturn


class BitFlippingEnv(GoalEnv):
class BitFlippingEnv(Env):
araffin marked this conversation as resolved.
Show resolved Hide resolved
"""
Simple bit flipping env, useful to test HER.
The goal is to flip all the bits to get a vector of ones.
Expand Down
32 changes: 22 additions & 10 deletions tests/test_envs.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
SimpleMultiObsEnv,
]

GYM_MESSAGE = "Function `rng.randint"


@pytest.mark.parametrize("env_id", ["CartPole-v0", "Pendulum-v1"])
def test_env(env_id):
Expand All @@ -44,17 +46,17 @@ def test_env(env_id):
if env_id == "Pendulum-v1":
assert len(record) == 1
else:
# The other environments must pass without warning
assert len(record) == 0
# The other environments are expected to raise warning introduced by Gym.
check_rand_warning(record)


@pytest.mark.parametrize("env_class", ENV_CLASSES)
def test_custom_envs(env_class):
env = env_class()
with warnings.catch_warnings(record=True) as record:
check_env(env)
# No warnings for custom envs
assert len(record) == 0
# Only randint warning coming from gym
check_rand_warning(record)


@pytest.mark.parametrize(
Expand All @@ -72,8 +74,12 @@ def test_bit_flipping(kwargs):
with warnings.catch_warnings(record=True) as record:
check_env(env)

# No warnings for custom envs
assert len(record) == 0
# Only randint warning coming from gym
check_rand_warning(record)


def check_rand_warning(record):
assert all(GYM_MESSAGE in warning.message.args[0] for warning in record)


def test_high_dimension_action_space():
Expand Down Expand Up @@ -151,13 +157,19 @@ def test_non_default_action_spaces(new_action_space):
with warnings.catch_warnings(record=True) as record:
check_env(env)

# No warnings for custom envs
assert len(record) == 0
# Only randint warning coming from gym
check_rand_warning(record)

# Change the action space
env.action_space = new_action_space

with pytest.warns(UserWarning):
check_env(env)
# Gym raises error for Boxed spaces if low > high
if env.action_space.low[0] > env.action_space.high[0]:
with pytest.raises(ValueError):
check_env(env)
else:
with pytest.warns(UserWarning):
check_env(env)


def check_reset_assert_error(env, new_reset_return):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_save_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def select_env(model_class: BaseAlgorithm) -> gym.Env:
if model_class == DQN:
return IdentityEnv(10)
else:
return IdentityEnvBox(10)
return IdentityEnvBox(10, 10)


@pytest.mark.parametrize("model_class", MODEL_LIST)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_vec_normalize.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def reset(self):
return np.array([self.returned_rewards[self.return_reward_idx]])


class DummyDictEnv(gym.GoalEnv):
class DummyDictEnv(gym.Env):
"""
Dummy gym goal env for testing purposes
"""
Expand Down