Skip to content

Blockwise.clone doesn't handle (iterable) literal arguments correctly #8978

@JSKenyon

Description

@JSKenyon

What happened:
Calling dask.graph_manipulation.clone on the result of a dask.array.blockwise operation with a (iterable) literal argument results in a ValueError.

What you expected to happen:
The dask.graph_manipulation.clone operation to succeed.

Minimal Complete Verifiable Example:

import dask.array as da
from dask.graph_manipulation import clone

if __name__ == "__main__":

    x = da.ones(10)
    y = (1,)

    z = da.blockwise(lambda x, y: x + y[0], "r",
                     x, "r",
                     y, None)

    clone(z)

Anything else we need to know?:
The above produces:

TypeError: unhashable type: 'list'

I have traced the problem to:

dask/dask/blockwise.py

Lines 812 to 817 in 1ccd1a4

numblocks = {}
for k, nbv in self.numblocks.items():
if k in names:
is_leaf = False
k = clone_key(k, seed)
numblocks[k] = nbv

In the above, the conditional if k in names causes the ValueError when k is not hashable.

Environment:

  • Dask version: 2022.4.1
  • Python version: 3.8.10
  • Operating System: Ubuntu 20.04
  • Install method (conda, pip, source): pip

Metadata

Metadata

Assignees

No one assigned

    Labels

    arraybugSomething is broken

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions