Skip to content
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

EzPickle support #50

Closed

Conversation

elliottower
Copy link
Contributor

Description

Updated all environments to support EzPickle (similar to Farama-Foundation/PettingZoo#924)

Fixes # (issue), Depends on # (pull request)

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

Screenshots

Please attach before and after screenshots of the change if applicable.
To upload images to a PR -- simply drag and drop or copy paste.

Checklist:

  • I have run the pre-commit checks with pre-commit run --all-files (see CONTRIBUTING.md instructions to set it up)
  • I have run pytest -v and no errors are present.
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I solved any possible warnings that pytest -v has generated that are related to my code to the best of my knowledge.
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@elliottower
Copy link
Contributor Author

@pseudo-rnd-thoughts says this shouldn't be necessary, going to change this PR to add testing that the ezpickle functionality works as properly

@pseudo-rnd-thoughts
Copy link
Member

@pseudo-rnd-thoughts says this shouldn't be necessary, going to change this PR to add testing that the ezpickle functionality works as properly

I should clarify what I mean. @elliottower @jkterry1

Why is EzPickle used?

It is helpful for users to save the state of an environment or to duplicate an environment, this is often done using pickle, i.e., pickle.load(pickle.dump(env)).
However, pickle is unable to understand non-python code without explicit __getstate__ or __setstate functions. This is where EzPickle comes in. For objects that are unable to be pickled, then EzPickle implements __getstate__ and __setstate__ functions to recreate the object using the arguments passed to the constructor.

It is important to note that this does not perfectly recreate an object as if an object has an updated as EzPickle does not account for this.

When should EzPickle be used in gymnasium, pettingzoo and other respective projects

EzPickle should only be used when an environment uses external modules that use non-python code, i.e., mujoco and ale. In these cases and only these cases then EzPickle should be added to the environment in which all of the environment constructor parameters should be passed to EzPickle.

EzPickle should be used sparingly and only when necessary and is not an apply to all environments type of solution as this can break backwards compatibility.

@jkterry1
Copy link
Member

jkterry1 commented Mar 28, 2023 via email

@pseudo-rnd-thoughts
Copy link
Member

This is why we have pickle or ezpickle in the standards

The standards don't include this https://farama.org/project_standards

@elliottower
Copy link
Contributor Author

Closing this in favor of #53

@elliottower elliottower deleted the ezpickle-support branch March 30, 2023 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants