-
-
Notifications
You must be signed in to change notification settings - Fork 428
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 mappings from env name to env module (e.g., mpe_environments
) in addition to all_environments
#1155
Add mappings from env name to env module (e.g., mpe_environments
) in addition to all_environments
#1155
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 so much for this! I really appreciate it.
I am more of the opinion that keeping the same name in these module files and in all_modules
(Aka keep the prefix) makes it less bug prone as an env in the library is uniquely identified by one and only one string. Plus this allows to have all_modules be the union of these.
but i can work with any choice of convention without any problems
(in case you decide to keep as is, you can still have all_environments be the union, you just need to preappend the prefix to the dict keys. This way is less bug prone as if you change an env name in one place you won't need to remember to change it in the other)
Ah okay I can see that logic actually, sure yeah I can revert and keep the unique identifiers that are used everywhere then. And when we change the env names we always do a find and replace and replace all of them, but yeah you're right that it is slightly easier to maintain if it is a union of the other environment mappings. |
My only concern with this PR is that previously when you do This is also the same as how Gymnasium does it, and I've seen it in a lot of other projects as well, so I don't think it's a huge deal. Will have to make a note of it in the release notes though. |
To address that, instead of putting the dicts in the init file, we could put then in a new file (all_modules.py to follow the utils convention, for example) so that the users can import that only if they need it. |
I was thinking about that, but I couldn't come up with anything that made much sense. All modules would be confusing to have multiple files, maybe something including the word "mapping" or something. Okay after thinking some more, the end result I want it to be |
that could work. The only thing i see is that you are repeating “classic” in the filename and it would lead to that file having different names in different modules, while something like environments.py (containing an |
Another option, just to throw it on the table, for you to keep it in init, is to have the dict inside a function that runs the imports only when called. |
We've discussed adding a registry system, similar to https://github.com/Farama-Foundation/Gymnasium/blob/main/gymnasium/envs/registration.py for example, but if it does get added I want to do it right, so I think I'm going to wait on that. You are right about re-using the word classic though, It could just be called |
This isn't a bad idea either but I think keeping things as simple as possible is probably best for now. Adding a registration system in the future definitely would be good to do, and I don't want to add too many bells and whistles right now which would have to be removed for that. |
Just as a note, I decided to keep the mappings named |
This fixes an issue raised in facebookresearch/BenchMARL#41 where the
all_environments
mapping requires all of the environments' packages, but if a user wants to have a mapping of subsets of environments, it is not currently possible. This allows you to dofrom pettingzoo.mpe import mpe_environments
which contains a mapping from name to module"mpe/simple_adversary_v3": simple_adversary_v3
etc.Edit: used the same as in all_modules with
mpe/simple_adversary
instead of belowDescription
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.
Fixes # (issue), Depends on # (pull request)
Type of change
Screenshots
Checklist:
pre-commit
checks withpre-commit run --all-files
(seeCONTRIBUTING.md
instructions to set it up)pytest -v
and no errors are present.pytest -v
has generated that are related to my code to the best of my knowledge.