Skip to content

Commit

Permalink
Merge pull request #6 from Farama-Foundation/main
Browse files Browse the repository at this point in the history
check default wrappers exist before stripping (Farama-Foundation#34)
  • Loading branch information
delaschwein authored Feb 6, 2023
2 parents eab4a16 + f3021b5 commit dac2f9b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ repos:
- --show-source
- --statistics
- repo: https://github.com/PyCQA/isort
rev: 5.10.1
rev: 5.12.0
hooks:
- id: isort
args: ["--profile", "black"]
Expand Down
9 changes: 5 additions & 4 deletions shimmy/openai_gym_compatibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,10 +283,11 @@ def _strip_default_wrappers(env: gym.Env) -> gym.Env:
Returns:
The environment without builtin wrappers
"""
default_wrappers = (
gym.wrappers.render_collection.RenderCollection,
gym.wrappers.human_rendering.HumanRendering,
)
default_wrappers = ()
if hasattr(gym.wrappers, "render_collection"):
default_wrappers += (gym.wrappers.render_collection.RenderCollection,)
if hasattr(gym.wrappers, "human_rendering"):
default_wrappers += (gym.wrappers.human_rendering.HumanRendering,)
while isinstance(env, default_wrappers):
env = env.env
return env
Expand Down

0 comments on commit dac2f9b

Please sign in to comment.