Skip to content
New issue

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

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

Already on GitHub? # to your account

Improve the warning when error is raised from plugin #225

Conversation

pseudo-rnd-thoughts
Copy link
Member

Within the plugin system, it is possible that the plugin raises an error, this is logged as a warning however does not give context on the plugin that caused the error.

@RedTachyon
Copy link
Member

Do you have a before and after of how the resulting warning looks?

@pseudo-rnd-thoughts
Copy link
Member Author

pseudo-rnd-thoughts commented Jan 5, 2023

Do you have a before and after of how the resulting warning looks?

>>> import gymnasium
gymnasium/envs/registration.py:313: UserWarning: WARN: cannot import name 'Viewer' from 'gymnasium.envs.mujoco.mujoco_rendering' (gymnasium/envs/mujoco/mujoco_rendering.py)
  logger.warn(str(e))

The PR result

>>> import gymnasium
gymnasium/envs/registration.py:314: UserWarning: WARN: plugin: shimmy.registration:register_gymnasium_envs raised Traceback (most recent call last):
  File "gymnasium/envs/registration.py", line 312, in load_env_plugins
    fn()
  File "site-packages/shimmy/registration.py", line 232, in register_gymnasium_envs
    _register_dm_control_envs()
  File "/shimmy/registration.py", line 26, in _register_dm_control_envs
    from shimmy.dm_control_compatibility import DmControlCompatibility
  File "shimmy/dm_control_compatibility.py", line 18, in <module>
    from gymnasium.envs.mujoco.mujoco_rendering import Viewer
ImportError: cannot import name 'Viewer' from 'gymnasium.envs.mujoco.mujoco_rendering' (gymnasium/envs/mujoco/mujoco_rendering.py)

  logger.warn(f"plugin: {plugin.value} raised {traceback.format_exc()}")

Context is that I didn't update shimmy so I got the previous error and I was different to work out what caused the issue.
To reproduce this use gymnasium==0.27 and shimmy=0.1

@pseudo-rnd-thoughts pseudo-rnd-thoughts merged commit c52ef43 into Farama-Foundation:main Jan 11, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants