Skip to content

Commit c97399f

Browse files
slevangdcherian
andauthored
Pass node path to tokenize in open_datatree (#10100)
* pass node path to tokenize * whats new --------- Co-authored-by: Deepak Cherian <dcherian@users.noreply.github.com>
1 parent 864b9c4 commit c97399f

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

doc/whats-new.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ Bug fixes
6464
Haacker <https://github.com/j-haacker>`_.
6565
- Fix ``isel`` for multi-coordinate Xarray indexes (:issue:`10063`, :pull:`10066`).
6666
By `Benoit Bovy <https://github.com/benbovy>`_.
67-
67+
- Fix dask tokenization when opening each node in :py:func:`xarray.open_datatree`
68+
(:issue:`10098`, :pull:`10100`). By `Sam Levang <https://github.com/slevang>`_.
6869

6970
Documentation
7071
~~~~~~~~~~~~~

xarray/backends/api.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,7 @@ def _datatree_from_backend_datatree(
455455
inline_array,
456456
chunked_array_type,
457457
from_array_kwargs,
458+
node=path,
458459
**extra_tokens,
459460
)
460461
for path, [node] in group_subtrees(backend_tree)

xarray/tests/test_backends_datatree.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,11 @@ def test_open_datatree_chunks(self, tmpdir, simple_datatree) -> None:
543543
with open_datatree(filepath, engine="zarr", chunks=chunks) as tree:
544544
xr.testing.assert_identical(tree, original_tree)
545545
assert_chunks_equal(tree, original_tree, enforce_dask=True)
546+
# https://github.com/pydata/xarray/issues/10098
547+
# If the open tasks are not give unique tokens per node, and the
548+
# dask graph is computed in one go, data won't be uniquely loaded
549+
# from each node.
550+
xr.testing.assert_identical(tree.compute(), original_tree)
546551

547552
def test_open_groups(self, unaligned_datatree_zarr) -> None:
548553
"""Test `open_groups` with a zarr store of an unaligned group hierarchy."""

0 commit comments

Comments
 (0)