From 88e69d47caa8cdb1ab0f47ffa27b2a6d113896d9 Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Tue, 17 Feb 2026 14:13:43 -0600 Subject: [PATCH] chore: support RNTuple v1.0.1.0 format (attribute set record frame) (#1580) * chore: support rntuple v1.0.1.0 format (attribute set record frame) * fix: pass version number to FooterReader since not just empty frame * style: pre-commit fixes * fix: define and use _rntuple_linked_attribute_set_format once; fix url to v1.0.1.0 commit * style: pre-commit fixes --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Andres Rios Tascon --- src/uproot/models/RNTuple.py | 42 +++++++++++++- tests/test_1510_rntuple_v1010.py | 96 ++++++++++++++++++++++++++++++++ 2 files changed, 136 insertions(+), 2 deletions(-) create mode 100644 tests/test_1510_rntuple_v1010.py diff --git a/src/uproot/models/RNTuple.py b/src/uproot/models/RNTuple.py index 8223f5814709684d64e5861c727f46c7405696cd..d32f161c84d1567c3fe468efca01831530cd16b6 100644 --- a/src/uproot/models/RNTuple.py +++ b/src/uproot/models/RNTuple.py @@ -52,6 +52,8 @@ _rntuple_extra_type_info_format = struct.Struct("= (1, 0, 1, 0): + self.linked_attribute_sets = ListFrameReader( + RecordFrameReader(LinkedAttributeSetRecordReader()) + ) + else: + self.linked_attribute_sets = None def read(self, chunk, cursor, context): out = MetaData("Footer") @@ -1611,6 +1642,13 @@ def read(self, chunk, cursor, context): out.cluster_group_records = self.cluster_group_record_frames.read( chunk, cursor, context ) + # Linked attribute sets only exist in v1.0.1.0 and later + if self.linked_attribute_sets is not None: + out.linked_attribute_sets = self.linked_attribute_sets.read( + chunk, cursor, context + ) + else: + out.linked_attribute_sets = [] out.checksum = cursor.field(chunk, _rntuple_checksum_format, context) return out diff --git a/tests/test_1510_rntuple_v1010.py b/tests/test_1510_rntuple_v1010.py new file mode 100644 index 0000000000000000000000000000000000000000..3da7875cc3931ab17e31902163f497a532fe6b03 --- /dev/null +++ b/tests/test_1510_rntuple_v1010.py @@ -0,0 +1,96 @@ +# BSD 3-Clause License; see https://github.com/scikit-hep/uproot5/blob/main/LICENSE + +""" +Tests for RNTuple version 1.0.1.0 support (issue #1510). + +RNTuple v1.0.1.0 added linked attribute sets to the footer structure. +This test ensures that both v1.0.1.0 files (with attributes) and v1.0.0.0 +files (without attributes) can be read correctly. +""" + +import skhep_testdata + +import uproot + + +def test_rntuple_v1010_footer_parsing(): + """ + Test that RNTuple v1.0.1.0 files can be read. + + The v1.0.1.0 format added a "linked attribute sets" list frame to the + footer, appearing between cluster_group_records and the checksum. + Without proper support, this causes an AssertionError due to checksum + mismatch. + """ + filename = skhep_testdata.data_path("ntpl001_staff_rntuple_v1-0-1-0.root") + + with uproot.open(filename) as f: + obj = f["Staff"] + + # Verify version + assert obj.member("fVersionEpoch") == 1 + assert obj.member("fVersionMajor") == 0 + assert obj.member("fVersionMinor") == 1 + assert obj.member("fVersionPatch") == 0 + + # Access footer - should not raise AssertionError + footer = obj.footer + + # Verify footer structure includes linked_attribute_sets + assert hasattr(footer, "linked_attribute_sets") + assert isinstance(footer.linked_attribute_sets, list) + + # Verify checksum validation passes + import xxhash + + chunk = obj._footer_chunk + computed = xxhash.xxh3_64_intdigest(chunk.raw_data[:-8]) + stored = footer.checksum + assert ( + computed == stored + ), f"Footer checksum mismatch: {computed:016x} != {stored:016x}" + + # Verify we can retrieve keys (original failing operation) + keys = obj.keys() + assert len(keys) > 0 + + +def test_rntuple_v1000_backward_compatibility(): + """ + Verify backward compatibility: v1.0.0.0 files still work with the fix. + + The fix adds a linked_attribute_sets reader that should gracefully handle + older files by reading an empty list frame (num_items=0). + """ + filename = skhep_testdata.data_path("ntpl001_staff_rntuple_v1-0-0-0.root") + + with uproot.open(filename) as f: + obj = f["Staff"] + + # Verify version + assert obj.member("fVersionEpoch") == 1 + assert obj.member("fVersionMajor") == 0 + assert obj.member("fVersionMinor") == 0 + assert obj.member("fVersionPatch") == 0 + + # Access footer - should still work + footer = obj.footer + + # Footer should have linked_attribute_sets field (but empty) + assert hasattr(footer, "linked_attribute_sets") + assert isinstance(footer.linked_attribute_sets, list) + assert len(footer.linked_attribute_sets) == 0 + + # Verify checksum validation still passes + import xxhash + + chunk = obj._footer_chunk + computed = xxhash.xxh3_64_intdigest(chunk.raw_data[:-8]) + stored = footer.checksum + assert ( + computed == stored + ), f"Footer checksum mismatch: {computed:016x} != {stored:016x}" + + # Verify normal operations still work + keys = obj.keys() + assert len(keys) > 0