Skip to content

Fix nested infos decoding in ArrowStorage - #347

Open
yurekami wants to merge 2 commits into
Farama-Foundation:mainfrom
yurekami:fix/arrow-nested-infos
Open

Fix nested infos decoding in ArrowStorage#347
yurekami wants to merge 2 commits into
Farama-Foundation:mainfrom
yurekami:fix/arrow-nested-infos

Conversation

@yurekami

@yurekami yurekami commented Sep 4, 2026

Copy link
Copy Markdown

_decode_info in arrow_storage.py checks isinstance(field, pa.StructArray), but field is a pa.Field (it comes from iterating the struct type), so the branch that recurses into nested dictionaries never runs. Nested info dictionaries stored with the arrow/parquet formats come back as an object array of per-step dicts, with the inner arrays flattened, instead of the nested dict of stacked arrays that the HDF5 backend returns:

hdf5     infos['nested'] -> dict: {'matrix': ('float64', (4, 2, 2))}
arrow    infos['nested'] -> ndarray: object (4,) [{'matrix': array([0., 0., 0., 0.])} ...]

This PR checks the field type with pa.types.is_struct so nested dictionaries are decoded recursively (matching _encode_info), and adds test_add_episodes_with_nested_infos in tests/dataset/test_minari_storage.py, parametrized over all storage formats. The test fails on arrow and parquet before the change and passes after.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • I have run the pre-commit checks with pre-commit run --all-files
  • I have run pytest -v and no errors are present.
  • 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

🤖 Generated with Claude Code

https://claude.ai/code/session_011vZKTbRaDh8FuXSbVpQomD

yurekami and others added 2 commits September 3, 2026 19:19
`_decode_info` checked `isinstance(field, pa.StructArray)`, but `field` is a
`pa.Field` (it comes from iterating the struct type), so the branch that
recurses into nested dictionaries never ran. Nested info dictionaries stored
with the arrow/parquet formats came back as an object array of per-step
dicts, with inner arrays flattened, instead of the nested dict of stacked
arrays that HDF5 returns and that `EpisodeData.infos` documents.

Check the field type with `pa.types.is_struct` so nested dictionaries are
decoded recursively, and add a round-trip test covering all storage formats.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011vZKTbRaDh8FuXSbVpQomD
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.

2 participants