-
-
Notifications
You must be signed in to change notification settings - Fork 871
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
Add docs and graceful Mujoco cleanup ( #1224) #1283
base: main
Are you sure you want to change the base?
Add docs and graceful Mujoco cleanup ( #1224) #1283
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
glfw.make_context_current(None) | ||
glfw.destroy_window(self.window) | ||
self.window = None | ||
except AttributeError: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can a more explicitly error type other than AttributeError
be used?
If not, it is fine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me look into it. Maybe there is another error which can be caught earlier in the stack trace.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope. This is the exact error it throws. No other error is thrown or handled before it.
I did try to use the sys lib to handle it more gracefully, but it gets unloaded before glfw thus resulting in an import error which is more confusing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.log I 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. |
Description
A detailed comment is provided in my name under the issue referenced.
The change summary is:
AttributeError
exception 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-commit
checks withpre-commit run --all-files
(seeCONTRIBUTING.md
instructions to set it up)