-
-
Notifications
You must be signed in to change notification settings - Fork 43
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
Support heterogeneous dicts in infos #250
base: main
Are you sure you want to change the base?
Conversation
Infos is now a List[Dict]
…s the same for both backend [arrow,hdf5] Corrected test_step_data_callback.py to not given an error with varying info structure. All tests in data_collector path now pass OK
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 @jamartinh!
I didn't review it completely, just added a couple of comments. However, I do not agree on changing the infos to be a list of dict, as this approach is generally inefficient and inconsistent with what we do with Dict spaces.
To support heterogenous info, we should fill missing values with None/np.nans.
It should be possible to do it in EpisodeBuffer, I believe. This allows minimal changes in the rest of the codebase.
…s the same for both backend [arrow,hdf5] Corrected test_step_data_callback.py to not given an error with varying info structure. All tests now pass OK Optional Using orjson for very fast serialization
…s the same for both backend [arrow,hdf5] Corrected test_step_data_callback.py to not given an error with varying info structure. All tests now pass OK Optional Using orjson for very fast serialization
…s the same for both backend [arrow,hdf5] Corrected test_step_data_callback.py to not given an error with varying info structure. All tests now pass OK Optional Using orjson for very fast serialization
…s the same for both backend [arrow,hdf5] Corrected test_step_data_callback.py to not given an error with varying info structure. All tests now pass OK Optional Using orjson for very fast serialization
…s the same for both backend [arrow,hdf5] Corrected test_step_data_callback.py to not given an error with varying info structure. All tests now pass OK Optional Using orjson for very fast serialization
…s the same for both backend [arrow,hdf5] Corrected test_step_data_callback.py to not given an error with varying info structure. All tests now pass OK Optional Using orjson for very fast serialization
…s the same for both backend [arrow,hdf5] Corrected test_step_data_callback.py to not given an error with varying info structure. All tests now pass OK Optional Using orjson for very fast serialization
…s the same for both backend [arrow,hdf5] Corrected test_step_data_callback.py to not given an error with varying info structure. All tests now pass OK Optional Using orjson for very fast serialization
The feature is now optional, by specifying an optional parameter in data collector creation |
…s the same for both backend [arrow,hdf5] Corrected test_step_data_callback.py to not given an error with varying info structure. All tests now pass OK Optional Using orjson for very fast serialization
Infos can be saved as a dictionary of np.arrays or as a list of arbitrary dictionaries by from minari import DataCollector
import gymnasium as gym
env = gym.make('CartPole-v1')
env = DataCollector(env, record_infos=True, infos_format="list") |
… add test for infos_format="list" option.
I don't like this for a couple reasons:
|
Infos is now a List[Dict]
Description
Allow for infos to be a list of heterogeneous dicts. Currently many environments use different keys for reset() and step(). Also wrappers are free to add arbitrary keys at arbitrary steps, for instance, RecordEspisodeStatistics add keys in the final step.
Hence, so save infos the users has to use almost always a custom step callback to regularize info data.
Fixes #246
Type of change
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.infos_format= None|"dict", "list"
to add the optional functionalityinfos_format= None|"dict", "list"
to add the optional functionality