Skip to content

Commit

Permalink
check default wrappers exist before stripping (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
nuance1979 authored Jan 30, 2023
1 parent d8777f5 commit f3021b5
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

1 comment on commit f3021b5

@vercel
Copy link

@vercel vercel bot commented on f3021b5 Feb 13, 2023

Choose a reason for hiding this comment

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

Please sign in to comment.