Skip to content

Commit e4667b6

Browse files
authored
Remove old hacks and update pybullet gymnasium (#421)
1 parent d477a07 commit e4667b6

File tree

5 files changed

+8
-16
lines changed

5 files changed

+8
-16
lines changed

CHANGELOG.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Release 2.2.0a11 (WIP)
1+
## Release 2.2.0a12 (WIP)
22

33
### Breaking Changes
44
- Removed `gym` dependency, the package is still required for some pretrained agents.
@@ -10,6 +10,8 @@
1010
- Added `ppo_lstm` to hyperparams_opt.py (@technocrat13)
1111

1212
### Bug fixes
13+
- Upgraded to `pybullet_envs_gymnasium>=0.4.0`
14+
- Removed old hacks (for instance limiting offpolicy algorithms to one env at test time)
1315

1416
### Documentation
1517

requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ stable-baselines3[extra_no_roms,tests,docs]>=2.2.0a11,<3.0
33
sb3-contrib>=2.2.0a11,<3.0
44
box2d-py==2.3.8
55
pybullet
6-
pybullet_envs_gymnasium
6+
pybullet_envs_gymnasium>=0.4.0
77
# minigrid
88
# scikit-optimize
99
optuna~=3.0

rl_zoo3/enjoy.py

-3
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,6 @@ def enjoy() -> None: # noqa: C901
126126
# Off-policy algorithm only support one env for now
127127
off_policy_algos = ["qrdqn", "dqn", "ddpg", "sac", "her", "td3", "tqc"]
128128

129-
if algo in off_policy_algos:
130-
args.n_envs = 1
131-
132129
set_random_seed(args.seed)
133130

134131
if args.num_threads > 0:

rl_zoo3/utils.py

+3-10
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,6 @@ def create_test_env(
211211
:param env_kwargs: Optional keyword argument to pass to the env constructor
212212
:return:
213213
"""
214-
# Avoid circular import
215-
from rl_zoo3.exp_manager import ExperimentManager
216-
217214
# Create the environment and wrap it if necessary
218215
assert hyperparams is not None
219216
env_wrapper = get_wrapper_class(hyperparams)
@@ -224,12 +221,8 @@ def create_test_env(
224221
del hyperparams["env_wrapper"]
225222

226223
vec_env_kwargs: Dict[str, Any] = {}
227-
vec_env_cls = DummyVecEnv
228-
if n_envs > 1 or (ExperimentManager.is_bullet(env_id) and should_render):
229-
# HACK: force SubprocVecEnv for Bullet env
230-
# as Pybullet envs does not follow gym.render() interface
231-
vec_env_cls = SubprocVecEnv # type: ignore[assignment]
232-
# start_method = 'spawn' for thread safe
224+
# Avoid potential shared memory issue
225+
vec_env_cls = SubprocVecEnv if n_envs > 1 else DummyVecEnv
233226

234227
# Fix for gym 0.26, to keep old behavior
235228
env_kwargs = env_kwargs or {}
@@ -252,7 +245,7 @@ def make_env(**kwargs) -> gym.Env:
252245
seed=seed,
253246
wrapper_class=env_wrapper,
254247
env_kwargs=env_kwargs,
255-
vec_env_cls=vec_env_cls,
248+
vec_env_cls=vec_env_cls, # type: ignore[arg-type]
256249
vec_env_kwargs=vec_env_kwargs,
257250
)
258251

rl_zoo3/version.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.2.0a11
1+
2.2.0a12

0 commit comments

Comments
 (0)