Skip to content

Conversation

pseudo-rnd-thoughts
Copy link
Contributor

@pseudo-rnd-thoughts pseudo-rnd-thoughts commented Jun 5, 2022

We are still interested in an environment checker being run on gym.make however running env_checker as previously implemented resulted in step and resest being called.
However, this was found to cause a significant number of issue

Therefore, this PR makes the following upgrades

  • The "env_checker" is a "invasive" checker that calls step, reset and render to check that the environments follow the gym API specification
  • Add a "passive" env checker that does not change the step or reset functions but checks the returns data is correct. In addition, passive observation and action space checkers are added and run on initialisation.
  • Add a wrapper for the passive env checker that is added to the environment on gym.make (otherwise disable_env_checker=True is passed. This check will run on only the first reset, step and render function checking their function signatures, and that data returned. As this wrapper needs direct access to the environment, is it the first wrapper applied to the environment in gym.make.
  • Various upgrades have been made to the environment checker such that checking all observation and action spaces, but not custom spaces sadly. I have attempted to make the code more modular allowing new tests to be added in the future.

)


class PassiveEnvChecker(gym.Wrapper):
Copy link
Contributor

Choose a reason for hiding this comment

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

Why define the Wrapper here and the method implementation in another file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question, I think that is because the passive environment checker file has more functions than are used in the wrapper and I use the passive env reset and step check in the full invasive environment checker. So these functions would have to be in a separate place

Comment on lines +201 to +202
for mode in render_modes:
env.render(mode=mode)
Copy link
Contributor

Choose a reason for hiding this comment

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

This will not work anymore with the new Render API.

Initially, I thought to just change the env_checker to receive the environment specification. In this way, internally it can creates as many copies as it needs without touching the copy made for the user. Having the env_spec here will also solve the problem for rendering (and in general for checking the parameters that are passed to__init__)

Copy link
Contributor Author

@pseudo-rnd-thoughts pseudo-rnd-thoughts Jun 6, 2022

Choose a reason for hiding this comment

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

I don't totally get what you mean, but as this PR is going to be in the next sub-release, would you be able to make the changes in your render PR?

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