Fix nested infos decoding in ArrowStorage - #347
Open
yurekami wants to merge 2 commits into
Open
Conversation
`_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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
_decode_infoinarrow_storage.pychecksisinstance(field, pa.StructArray), butfieldis apa.Field(it comes from iterating the struct type), so the branch that recurses into nested dictionaries never runs. Nested info dictionaries stored with thearrow/parquetformats 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:This PR checks the field type with
pa.types.is_structso nested dictionaries are decoded recursively (matching_encode_info), and addstest_add_episodes_with_nested_infosintests/dataset/test_minari_storage.py, parametrized over all storage formats. The test fails onarrowandparquetbefore the change and passes after.Type of change
Checklist:
pre-commitchecks withpre-commit run --all-filespytest -vand no errors are present.🤖 Generated with Claude Code
https://claude.ai/code/session_011vZKTbRaDh8FuXSbVpQomD