@@ -72,6 +72,7 @@ def _maybe_chunk(
7272 inline_array : bool = False ,
7373 chunked_array_type : str | ChunkManagerEntrypoint | None = None ,
7474 from_array_kwargs = None ,
75+ just_use_token = False ,
7576) -> Variable :
7677 from xarray .namedarray .daskmanager import DaskManager
7778
@@ -83,14 +84,16 @@ def _maybe_chunk(
8384 chunked_array_type
8485 ) # coerce string to ChunkManagerEntrypoint type
8586 if isinstance (chunked_array_type , DaskManager ):
86- from dask .base import tokenize
87-
88- # when rechunking by different amounts, make sure dask names change
89- # by providing chunks as an input to tokenize.
90- # subtle bugs result otherwise. see GH3350
91- # we use str() for speed, and use the name for the final array name on the next line
92- token2 = tokenize (token or var ._data , str (chunks ))
93- name2 = f"{ name_prefix } { name } -{ token2 } "
87+ if not just_use_token :
88+ from dask .base import tokenize
89+
90+ # when rechunking by different amounts, make sure dask names change
91+ # by providing chunks as an input to tokenize.
92+ # subtle bugs result otherwise. see GH3350
93+ # we use str() for speed, and use the name for the final array name on the next line
94+ token = tokenize (token or var ._data , str (chunks ))
95+
96+ name2 = f"{ name_prefix } { name } -{ token } "
9497
9598 from_array_kwargs = utils .consolidate_dask_from_array_kwargs (
9699 from_array_kwargs ,
0 commit comments