dask / dask/distributed

Dask coroutines

Ouverte
#1,663 11 commentaires 2 réactions 0 personnes assignées Voir sur GitHub
discussion enhancement
Langage dominant
Python
Étoiles
1.7k
Forks
778
Merge moyen
2 h 50 min
PR mergées (30 j)
3

Description

There are currently a few ways to construct highly dynamic workloads, where the graph can change during computation. This includes operations like `get_client()`, calling `dask.compute` within a task, using futures and `as_completed`, and so on.

Sometimes these workloads can grow complex and difficult to reason about (see https://github.com/dask/distributed/issues/1424). Are there better programming interfaces to present to users that still cover the same options, but perhaps guide users to correct behavior.

Asynchronous projects like Tornado/Asyncio/Curio/Trio seem to prefer a coroutine-style approach. Is this a possible option for a distributed runtime like Dask? If so what would it look like?

Here are a couple of toy problems that come up frequently and naive thoughts on how they might look as coroutines

### Fibonacci

```python
@dask.coroutine
def fib(i):
if i < 2:
return i
else:
a, b = yield [fib(i - 1), fib(i - 2)]
return a + b
```

### Evaluating on a remote list of unknown size

```python
@dask.coroutine
def generate_data():
return list(range(random.randint(0, 10))) # a list of data of unknown length

@dask.coroutine
def inc(x):
return x + 1

@dask.coroutine
def my_len(L):
return len(L)

@dask.coroutine
def my_sum(L):
return sum(L)

@dask.coroutine
def process_all():
L = generate_data()
n = yield my_len(L)
processed = [inc(L[i]) for i in range(n)]
total = yield sum(processed)
return total
```

There are problems with both examples. They also don't represent the full space of complexity that existing solutions can cover. Broad thoughts on this topic are welcome.

cc @ogrisel @pitrou @remram44 @adamklein

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.