Skip to content

Clarification of the task graph: are futures allowed in tuples that aren't tasks? #4183

Open

Description

@madsbk

As reported by #4177, custreamz CI fails because the task graph contains tuples with future objects.

The question is if this is even allowed? Dask don't allow keys in tuples that aren't tasks. E.g. in the following ("x",) is interpreted as a literal with no dependencies:

import dask.core
dsk = {
    "x": 1,
    "a": ("x",),
    "b": ["x"]
}
assert dask.core.get_dependencies(dsk, "a") == set()
assert dask.core.get_dependencies(dsk, "b") == {"x"}

But what about futures? Conceptually, futures are remote graph keys so I am inclined to think that they should have the same semantic as regular keys.

What are you thoughts, should the following be allowed?

from distributed import LocalCluster, Client

if __name__ == '__main__':
    client = Client(LocalCluster(n_workers=1))

    def getfirst(x):
        return x[0]

    x = client.submit(sum, [1,2])
    y = client.submit(getfirst, (x,))
    y.result()

Activity

  1. jakirkham commented on Oct 23, 2020

    @jakirkham
    Member

    cc @mrocklin @martindurant @jrbourbeau (in case any of you have thoughts 🙂)

  2. martindurant commented on Oct 23, 2020

    @martindurant
    Member

    From the (cu)streamz perspective, I daresay the submits can be changed to use lists instead of tuples where necessary.

  3. jrbourbeau commented on Oct 23, 2020

    @jrbourbeau
    Member

    This is a great question, thanks for asking @madsbk

    I'm somewhat torn on what behavior we should have here. Based on the Dask graph spec I would expect that we shouldn't search through non-task tuples to replace Futures with their results as we don't do this for other graph keys. On the other hand, since we currently do search non-task tuples for Futures changing that behavior can break existing user code (as you mentioned in the custreamz case).

    For now I'm inclined to keep our current behavior of searching non-task tuples for Futures for backwards compatibility (i.e. we merge #4178). Though longer term, I'm open to changing behavior if we don't want to special case Futures like we currently do. It'd probably be worth a deprecation cycle in that case though.

    cc @jcrist who may also be interested in this topic

  4. mrocklin commented on Oct 27, 2020

    @mrocklin
    Member
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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