Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions xarray/backends/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ def _chunk_ds(
inline_array=inline_array,
chunked_array_type=chunkmanager,
from_array_kwargs=from_array_kwargs.copy(),
just_use_token=True,
)
return backend_ds._replace(variables)

Expand Down
19 changes: 11 additions & 8 deletions xarray/structure/chunks.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def _maybe_chunk(
inline_array: bool = False,
chunked_array_type: str | ChunkManagerEntrypoint | None = None,
from_array_kwargs=None,
just_use_token=False,
) -> Variable:
from xarray.namedarray.daskmanager import DaskManager

Expand All @@ -83,14 +84,16 @@ def _maybe_chunk(
chunked_array_type
) # coerce string to ChunkManagerEntrypoint type
if isinstance(chunked_array_type, DaskManager):
from dask.base import tokenize

# when rechunking by different amounts, make sure dask names change
# by providing chunks as an input to tokenize.
# subtle bugs result otherwise. see GH3350
# we use str() for speed, and use the name for the final array name on the next line
token2 = tokenize(token or var._data, str(chunks))
name2 = f"{name_prefix}{name}-{token2}"
if not just_use_token:
from dask.base import tokenize

# when rechunking by different amounts, make sure dask names change
# by providing chunks as an input to tokenize.
# subtle bugs result otherwise. see GH3350
# we use str() for speed, and use the name for the final array name on the next line
token = tokenize(token or var._data, str(chunks))

name2 = f"{name_prefix}{name}-{token}"

from_array_kwargs = utils.consolidate_dask_from_array_kwargs(
from_array_kwargs,
Expand Down
Loading