From ef9bb691fbfe9ac927fa6f5f351da4a636fa0067 Mon Sep 17 00:00:00 2001 From: Yi Su Date: Sat, 28 Jan 2023 15:42:57 -0800 Subject: [PATCH 1/3] check default wrappers exist before stripping --- shimmy/openai_gym_compatibility.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/shimmy/openai_gym_compatibility.py b/shimmy/openai_gym_compatibility.py index 2711a96c..f84a3545 100644 --- a/shimmy/openai_gym_compatibility.py +++ b/shimmy/openai_gym_compatibility.py @@ -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.append(gym.wrappers.render_collection.RenderCollection) + if hasattr(gym.wrappers, "human_rendering"): + default_wrappers.append(gym.wrappers.human_rendering.HumanRendering) while isinstance(env, default_wrappers): env = env.env return env From 85f3da1b45c573ec8faba7e7c4b4513bcae39082 Mon Sep 17 00:00:00 2001 From: Yi Su Date: Sat, 28 Jan 2023 15:48:09 -0800 Subject: [PATCH 2/3] make it a tuple --- shimmy/openai_gym_compatibility.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/shimmy/openai_gym_compatibility.py b/shimmy/openai_gym_compatibility.py index f84a3545..82fd4fdc 100644 --- a/shimmy/openai_gym_compatibility.py +++ b/shimmy/openai_gym_compatibility.py @@ -283,11 +283,11 @@ def _strip_default_wrappers(env: gym.Env) -> gym.Env: Returns: The environment without builtin wrappers """ - default_wrappers = [] + default_wrappers = () if hasattr(gym.wrappers, "render_collection"): - default_wrappers.append(gym.wrappers.render_collection.RenderCollection) + default_wrappers += (gym.wrappers.render_collection.RenderCollection,) if hasattr(gym.wrappers, "human_rendering"): - default_wrappers.append(gym.wrappers.human_rendering.HumanRendering) + default_wrappers += (gym.wrappers.human_rendering.HumanRendering,) while isinstance(env, default_wrappers): env = env.env return env From 3084042f99cd12bd1368dbefeeaf8d076289888f Mon Sep 17 00:00:00 2001 From: Yi Su Date: Sun, 29 Jan 2023 09:25:55 -0800 Subject: [PATCH 3/3] upgrade isort to fix an error with poetry --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e4abcfd4..4059f452 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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"]