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

[Bug Report] step and info structures expected to be identical (when record_infos=True) #191

Open
Kallinteris-Andreas opened this issue Feb 17, 2024 · 1 comment

Comments

@Kallinteris-Andreas
Copy link

Kallinteris-Andreas commented Feb 17, 2024

Hey, I am trying to make dataset of Ant-v5 and i am getting this error:

$ py create_dataset.py  # expert-v0
Traceback (most recent call last):
  File "/home/master-andreas/gym/rl/project/create_dataset.py", line 56, in <module>
    obs, rew, terminated, truncated, info = collector_env.step(action)
                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/master-andreas/gym/rl/project/temp_env/lib/python3.11/site-packages/minari/data_collector/data_collector.py", line 222, in step
    self._add_step_data(self._buffer[-1], step_data)
  File "/home/master-andreas/gym/rl/project/temp_env/lib/python3.11/site-packages/minari/data_collector/data_collector.py", line 162, in _add_step_data
    raise ValueError(
ValueError: Info structure inconsistent with info structure returned by original reset.

for reference:
self._reference_info is set using info from reset

self._reference_info = step_data["infos"]

which is then compared to the info from reset

if not _check_infos_same_shape(

Also in general, it is not in Env's specification that info s need to have the same structure each time
https://gymnasium.farama.org/main/api/env/#gymnasium.Env.step

@alexdavey @younik

@Kallinteris-Andreas Kallinteris-Andreas changed the title [Bug Report] Bug title [Bug Report] step and info structures expected to be identical (when record_infos=True) Feb 17, 2024
@younik
Copy link
Member

younik commented Mar 12, 2024

Hello @Kallinteris-Andreas,

The problem is that Ant-v5 returns some info at reset, but not during step.
If we collect and store inconsistent infos in HDF5 file, we may silently misplace infos during dataset reading (for example assigning the second info to the first step, instead of the second episode reset).

This is why we require infos to have the same structure always. With the current code, you can solve it by defining a StepDataCallback or simply setting record_infos=False (which at this point should be the default to avoid failing on simple envs like Gymnasium-Robotics).

We may want to pad infos automatically in the future, but I don't think it is high priority now

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

No branches or pull requests

2 participants