-
Notifications
You must be signed in to change notification settings - Fork 8.6k
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
[Bug Report] Import of custom environments is broken in 0.22 #2809
Comments
You need to register the environment before making an environment In 0.22.0, there was a large modification to the make function which is probably what caused this issue. |
Last line of
|
Sorry, I didnt see that final line, I should read the code more closely |
I can reproduce this behavior and it seems like a serious bug. @RedTachyon could you explain how the registration of custom environments is supposed to work and which module has to be imported to @pseudo-rnd-thoughts I think the point is that in 0.22 you need to import |
First time I'm hearing of the pattern |
I doubt that there is any real documentation of this (because there hasn't been any real documentation at all so far). However, the template of the environment creation page in gym-docs used this pattern at the very bottom of the page: It didn't work for me so I changed it to something that worked with 0.22. The template page appeared in the second commit in gym-docs (by Jordan). It was titled "move over docs". Idk where it came from. |
Ok, I took a closer look at the code, I think I know what happened. The problem is that you used to be able to write, for example: import gym
gym.make('pybullet_envs:HopperBulletEnv-v0') and this will work, because This happens due to the Between 0.21 and 0.22, there was a pretty large change to the registration mechanism, which made environment creation a bit more precise - it uses all this fancy logic to check if the environment exists, if there's some typos etc. It seems to have forgotten this specific pattern, which is the unfortunate reality of maintaining a previously abandoned project. This same registration mechanism happens to be completely erased and revamped now for the upcoming 0.24 release, and integrating this feature into it would be fairly simple with the new approach if there's interest in it. I agree it's actually a pretty useful thing, but I'm treating it as more of a "new feature request" at this point, since it was a niche feature that accidentally disappeared a few releases ago. |
Thanks for looking into it! If this is now a "new feature request", let me quickly make a case for this feature. It's most useful for programs that accept the name of the environment as a command line argument, environment variable, etc. - basically some form of input. So,
can become
The alternative is modifying the source code of As far as I understand, the newly implemented plugin system addresses the same issue or at least overlaps a lot. But, again, as far as I understand, the plugin protocol needs to be implemented by the author of the environment. |
@RedTachyon Are you happy to work on this new feature? |
I don't really have the bandwidth to do it properly at the moment, if someone else wants to work on it now, that'd be great. Otherwise I can come back to it in some time. I can also offer pretty specific guidance on how I'd see this actually being implemented - it shouldn't be too complex overall, and most of the work would be writing tests and documentation (which is the bottleneck for me right now) |
I can work on this if that's okay. I'll maybe check with @RedTachyon if I run into any complications. |
Hi, can you please tell me if there is any update on this? |
It should work properly in the more recent releases of Gym (maybe try 0.25) |
Describe the bug
In gym 0.21 there is a useful feature for loading custom environments. One can call
And gym will import the
module
before trying to makeEnv
. In gym 0.22 it got broken.Code example
Make a file named
test.py
:then, in python console or in another file, run
gym.make('test:Dummy-v0')
. If you have gym 0.21.0 installed, you getWith gym 0.22.0 it's
System Info
Python 3.9.12, installing gym 0.21.0 and 0.22.0 via poetry on Ubuntu 18.04.6 LTS, 4.15.0-176-generic
Checklist
The text was updated successfully, but these errors were encountered: