openai / gym

A toolkit for developing and comparing reinforcement learning algorithms.
https://www.gymlibrary.dev
Other
34.5k stars 8.59k forks source link

[Proposal] Allow 3rd-party environments to suppress warnings #2916

Closed Radagaisus closed 2 years ago

Radagaisus commented 2 years ago

Proposal

A way for environment developers to suppress warnings, either globally or on a per-type basis.

Motivation

I’m developing a simple environment that receives some well-intentioned but totally wrong for my use case warnings (“WARN: Agent's maximum action space value is infinity”, “We recommend you to use a symmetric and normalized Box action space”). Nothing for me to do to resolve them, and I don’t want them to pop up, confuse, and sow doubt for the end-user.

Pitch

I think the natural place to manage this config is during registration:

gym_registration(
  id='namespace/name-version',
  entry_point='module:Class',
  warnings=False
)

If an end-user is trying to debug an issue with the environment, they might force it to be re-enabled by setting a global gym.warnings=True flag.

Checklist

BlueskyFR commented 2 years ago

I am just beginning to use the library but AFAIK, in the meantime, you can disable_env_checker=True in gym.make()

RedTachyon commented 2 years ago

That's a good point, we had some discussions about some sort of a global disable option of the env checker, but it fell through the cracks since we solved its main issue in a different way.

It might make sense to just make disable_env_checker to be a part of the environment spec. Then you can manually disable it as an env developer, and it can be reenabled by end-users in make.

BTW an easy way to kinda do this is by setting gym.logger.set_level(ERROR) somewhere in your code, it should silence all the warnings. It's not the exact same thing, but might be close enough

pseudo-rnd-thoughts commented 2 years ago

@Radagaisus FYI, the environment checker is going to have a major bug fix the next version (v25) as it currently has a number of significant issues. This is the new PR, https://github.com/openai/gym/pull/2903 @RedTachyon I like the idea, would we want to change disable_env_checker: Optional[bool] = None to detect if we should overwrite the register spec.

jkterry1 commented 2 years ago

Closing in favor of #2903