dask / dask/distributed

Dask coroutines

Đang mở
#1,663 11 bình luận 2 reaction 0 người được giao Xem trên GitHub
discussion enhancement
Ngôn ngữ chính
Python
Star
1.7k
Fork
778
Merge trung bình
2 giờ 50 phút
Pull request đã merge (30 ngày)
3

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.