Dask coroutines
- Vorherrschende Sprache
- Python
- Sterne
- 1.7k
- Forks
- 778
- Ø Merge
- 2 Std. 50 Min.
- Gemergte PRs (30 T.)
- 3
Beschreibung
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
Beitragsleitfaden
Bewertung
Dieses Issue wurde noch nicht bewertet.