Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BugFix] Raise exception in PixelObservationWrapper if env.render_mode is not specified #3076

Merged
merged 2 commits into from
Sep 8, 2022

Conversation

vmoens
Copy link
Contributor

@vmoens vmoens commented Sep 8, 2022

Description

In 8e812e1 we added a warning when render_mode was not specified, but in 0.26 this will not work anymore.
Hence we require that env.render_mode is not None for PixelObservationWrapper to be used.

Behaviour ante

from gym.wrappers.pixel_observation import PixelObservationWrapper
import gym
base_env = gym. Make("Pendulum-v1") # no error
env = PixelObservationWrapper(env) # no error
env.reset() # error

With the error

~/venv/rl/lib/python3.8/site-packages/gym/utils/passive_env_checker.py in env_render_passive_checker(env, *args, **kwargs)
    314             )
    315 
--> 316     result = env.render(*args, **kwargs)
    317 
    318     # TODO: Check that the result is correct

TypeError: render() got an unexpected keyword argument 'mode'

Behaviour post

An error is raised as soon as PixelObservationWrapper is instantiated

from gym.wrappers.pixel_observation import PixelObservationWrapper
import gym
base_env = gym.make("Pendulum-v1") # no error
env = PixelObservationWrapper(env) # error

Solution

from gym.wrappers.pixel_observation import PixelObservationWrapper
import gym
base_env = gym. Make("Pendulum-v1", render_mode="human") # no error
env = PixelObservationWrapper(env) # no error
env.reset() # no error

"env.render_mode must be specified to use PixelObservationWrapper:"
"`gym.make(env_name, render_mode='rgb_array')`."
"`gym.make(env_name, render_mode='single_rgb_array')`."
Copy link
Contributor

Choose a reason for hiding this comment

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

We can reverted the meaning of the render_modes in v25 back to the previous meaning where rgb_array means single render obs and rgb_array_list will mean list of render obs

Copy link
Contributor

@pseudo-rnd-thoughts pseudo-rnd-thoughts left a comment

Choose a reason for hiding this comment

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

Please make the render mode change otherwise looks good

@vmoens
Copy link
Contributor Author

vmoens commented Sep 8, 2022

Please make the render mode change otherwise looks good

Just made the change!

@jkterry1 jkterry1 merged commit abefea7 into openai:master Sep 8, 2022
@vmoens vmoens deleted the render_wrapper_error branch September 8, 2022 20:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants