Skip to content

Commit 99fcfbe

Browse files
authored
Fix bug with custom envs and subprocesses (#306)
1 parent 0c5becd commit 99fcfbe

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Release 1.7.0a1 (WIP)
1+
## Release 1.7.0a2 (WIP)
22

33
### Breaking Changes
44

@@ -8,6 +8,7 @@
88

99
### Bug fixes
1010
- Allow `python -m rl_zoo3.cli` to be called directly
11+
- Fix a bug where custom environments were not found despite passing ``--gym-package`` when using subprocesses
1112

1213
### Documentation
1314

rl_zoo3/exp_manager.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,10 +568,19 @@ def create_envs(self, n_envs: int, eval_env: bool = False, no_log: bool = False)
568568
):
569569
self.monitor_kwargs = dict(info_keywords=("is_success",))
570570

571+
# Define make_env here so it works with subprocesses
572+
# when the registry was modified with `--gym-packages`
573+
# See https://github.com/HumanCompatibleAI/imitation/pull/160
574+
spec = gym.spec(self.env_name.gym_id)
575+
576+
def make_env(**kwargs) -> gym.Env:
577+
env = spec.make(**kwargs)
578+
return env
579+
571580
# On most env, SubprocVecEnv does not help and is quite memory hungry
572581
# therefore we use DummyVecEnv by default
573582
env = make_vec_env(
574-
env_id=self.env_name.gym_id,
583+
make_env,
575584
n_envs=n_envs,
576585
seed=self.seed,
577586
env_kwargs=self.env_kwargs,

rl_zoo3/version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.7.0a1
1+
1.7.0a2

0 commit comments

Comments
 (0)