dask / dask/dask

`dask.compute` can't handle some `dataclass`es as input

Open
#9,370 0 comments 0 reactions 0 assignees View on GitHub
bug core needs attention
Dominant language
Python
Stars
13.9k
Forks
2k
PR merge metrics
No merged PRs in 30d

Description

As mentioned in https://github.com/dask/dask/pull/9345#discussion_r940533164, `dask.compute` can't handle some `dataclass`es as inputs due to a limitation in `dask.base.unpack_collections`. In #9345, we added support or error handling for these types of `dataclass`es, but the implementation of `dask.base.unpack_collections` makes it non-trivial to apply those changes. Specifically, we experience issues as soon as we encounter a custom `__init__`, `__post_init__`, fields with `init=False` or `InitVar`s in the `dataclass`. #9363 would provide an alternative route to solving this issue.

```python3
import dask
from dataclasses import dataclass

@dataclass
class MyDataClass:
arg1: int
def __init__(self, arg):
self.arg1 = arg

dask.compute([dask.delayed(1), MyDataClass(1)])
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.