Skip to content

API: KeyError raised when dask graph refers to its final output #886

@sinhrks

Description

@sinhrks

We can define dask graph using function and key name as below.

def f(x):
    return x

dsk = {('x', 0): np.array([1, 2]),
       ('y', 0): np.array([1, 2]),
       ('x', 1): (f, ('y', 0))}

# OK
darr = da.Array(dsk, 'x', chunks=(2, ), shape=(4, ))
darr.compute()
# array([1, 2, 1, 2])

However, if the argument has the same name as the final output (final Array's name), it raises KeyError because current dependency search doesn't includes keys in the final output.

dsk = {('x', 0): np.array([1, 2]),
       ('x', 1): (f, ('x', 0))}

darr = da.Array(dsk, 'x', chunks=(2, ), shape=(4, ))
darr.compute()
# /Users/sin/Documents/Git/dask/dask/core.pyc in get_dependencies(dsk, task, as_list)
#     201     set(['x'])
#     202     """
# --> 203     args = [dsk[task]]
#     204     result = []
#     205     while args:
# KeyError: ('x', 0)

I think it can be allowed without problems?

This is related to #885. The algorithm uses previous LU decomposition results of blocks on the diagonal.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions