Skip to content

uproot.dask cannot handle grouped TObject properly #1502

@mrzimu

Description

@mrzimu

Hi,
I'm trying to read a simple object derived from TObject through uproot.dask. It seems that uproot.dask cannot handle branch relationship between TObject and TObject.fUniqueID, TObject.fBits.

When I read the whole tree:

import uproot
dak_arr = uproot.dask({"demo-data.root" : "/my_tree/basic_types"})
dak_arr.compute()

The exception is:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/mrli/work/uproot5/.venv/lib/python3.12/site-packages/dask/base.py", line 370, in compute
    (result,) = compute(self, traverse=False, **kwargs)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mrli/work/uproot5/.venv/lib/python3.12/site-packages/dask/base.py", line 656, in compute
    results = schedule(dsk, keys, **kwargs)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mrli/work/uproot5/src/uproot/_dask.py", line 1261, in __call__
    result, _ = self._call_impl(i, start, stop)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mrli/work/uproot5/src/uproot/_dask.py", line 1265, in _call_impl
    return self.read_tree(
           ^^^^^^^^^^^^^^^
  File "/home/mrli/work/uproot5/src/uproot/_dask.py", line 1016, in read_tree
    mapping = self.form_mapping_info.load_buffers(
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mrli/work/uproot5/src/uproot/_dask.py", line 969, in load_buffers
    assert src_dtype == dst_dtype  # Sanity check!
           ^^^^^^^^^^^^^^^^^^^^^^
AssertionError

I simply checked the loop this assertion in:

uproot5/src/uproot/_dask.py

Lines 957 to 970 in 65b4af6

for key, array in zip(keys, arrays):
# First, convert the sub-array into buffers
ttree_subform, length, ttree_container = awkward.to_buffers(array)
# Load the associated projection subform
projection_subform = self._form.content(key)
# Correlate each TTree form key with the projection form key
for (src, src_dtype), (dst, dst_dtype) in zip(
ttree_subform.expected_from_buffers().items(),
projection_subform.expected_from_buffers(self.buffer_key).items(),
):
assert src_dtype == dst_dtype # Sanity check!
container[dst] = ttree_container[src]

and found the key is TObject (not TObject.fUniqueID or TObject.fBits), but the array is a tuple containing the array of fUniqueID and fBits, so the ttree_subform and projection_subform are different, causing the AssersionError.

If I directly read the whole file:

dak_arr = uproot.dask("demo-data.root")
dak_arr.compute()

The exception is different from above:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/mrli/work/uproot5/.venv/lib/python3.12/site-packages/dask/base.py", line 370, in compute
    (result,) = compute(self, traverse=False, **kwargs)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mrli/work/uproot5/.venv/lib/python3.12/site-packages/dask/base.py", line 656, in compute
    results = schedule(dsk, keys, **kwargs)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mrli/work/uproot5/src/uproot/_dask.py", line 1261, in __call__
    result, _ = self._call_impl(i, start, stop)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mrli/work/uproot5/src/uproot/_dask.py", line 1265, in _call_impl
    return self.read_tree(
           ^^^^^^^^^^^^^^^
  File "/home/mrli/work/uproot5/src/uproot/_dask.py", line 1016, in read_tree
    mapping = self.form_mapping_info.load_buffers(
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mrli/work/uproot5/src/uproot/_dask.py", line 932, in load_buffers
    arrays = tree.arrays(
             ^^^^^^^^^^^^
  File "/home/mrli/work/uproot5/src/uproot/behaviors/TBranch.py", line 906, in arrays
    _fix_asgrouped(
  File "/home/mrli/work/uproot5/src/uproot/behaviors/TBranch.py", line 3221, in _fix_asgrouped
    assert arrays[branch.cache_key] is None
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError

I'm not sure whether this error is caused by the same reason.


The file is:

demo-data.zip

And the version of uproot is 5.6.6

Hope this report can help :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug (unverified)The problem described would be a bug, but needs to be triaged

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions