Add error message when terminating the MuJoCo renderer without calling env.close#1283
Add error message when terminating the MuJoCo renderer without calling env.close#1283pseudo-rnd-thoughts merged 5 commits intoFarama-Foundation:mainfrom a-ayesh:fix/mujoco-rendering-shutdown
env.close#1283Conversation
There was a problem hiding this comment.
Thanks for the PR, I think this will resolve the issue for users.
Could you change the print to a gymnasium.logger.warn
Also could you run pre-commit run --all-files
Otherwise good to me, @Kallinteris-Andreas any thoughts?
Kallinteris-Andreas
left a comment
There was a problem hiding this comment.
It works, tested with:
import gymnasium
env = gymnasium.make('Humanoid-v5', render_mode='human')
obs, info = env.reset()
#env.close()Also, please run pre-commit --all-files (more info on contributing.md)
I changed the print statement to use warn. The error now looks like: /home/user/Gymnasium/gymnasium/envs/mujoco/mujoco_rendering.py:372: UserWarning: WARN: Environment was not properly closed using 'env.close()'. Please ensure to close the environment explicitly. GLFW module or dependencies are unloaded. Window cleanup might not have completed.
Also I apologize for marking that I ran An unexpected error has occurred: CalledProcessError: command: ('/home/cowlar/.cache/pre-commit/repoiipfy4zl/node_env-system/bin/node', '/usr/local/bin/npm', 'install', '--include=dev', '--include=prod', '--ignore-prepublish', '--no-progress', '--no-save')
return code: 1
stdout: (none)
stderr:
internal/modules/cjs/loader.js:638
throw err;
^
Error: Cannot find module 'node:path'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (/usr/local/lib/node_modules/npm/lib/cli.js:10:18)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
Check the log at /home/cowlar/.cache/pre-commit/pre-commit.logI am using my work PC though, so I don't want to mess up anything just in case. It would be nice if either of you could checkout the branch from my fork to run it, otherwise I might do it in a day or two. |
|
You can use GitHub Codespaces on your branch to easily run pre-commit. |
|
Hi, I apologize for a simple change request taking so long. I've run the |
Kallinteris-Andreas
left a comment
There was a problem hiding this comment.
No worries, Thanks for the pull request.
env.close
|
Great job @a-ayesh ! |
Description
A detailed comment is provided in my name under the issue referenced.
The change summary is:
AttributeErrorexception handling to thefree()method inmujoco_rendering.py.env.close()before the program terminates when they've setrender_mode: 'human'.free()method.Fixes #1224
Type of change
Checklist:
pre-commitchecks withpre-commit run --all-files(seeCONTRIBUTING.mdinstructions to set it up)