Minari
Minari copied to clipboard
[Bug Report] step and info structures expected to be identical (when `record_infos=True`)
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
https://github.com/Farama-Foundation/Minari/blob/9803a700bdba1e228e335de5422511edbfb4c74e/minari/data_collector/data_collector.py#L261
which is then compared to the info
from reset
https://github.com/Farama-Foundation/Minari/blob/9803a700bdba1e228e335de5422511edbfb4c74e/minari/data_collector/data_collector.py#L147
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
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