Inconsistent return type in result from `client.submit` when returning an `astropy.units.Quantity` object
- Dominant language
- Python
- Stars
- 1.7k
- Forks
- 778
- Avg merge
- 2h 50m
- Merged PRs (30d)
- 3
Description
**What happened**:
The [astropy](https://www.astropy.org/) library provides the [`Quantity`](https://docs.astropy.org/en/stable/units/index.html) object which is essentially an array-like with unit information attached that allows for unit-aware arithmetic. When calling a function with `client.submit` that returns an `Quantity` object, the type of the returned result does not match that of the function or the `type` attribute of the associated `Future`. Instead of being a `Quantity`, it is just a bare numpy array.
**What you expected to happen**:
The return type of the result from `client.submit` to be a `Quantity` rather than `numpy` array when the function being passed to `submit` returns a `Quantity`. In general, I expect the return types of calling the function normally and calling with `client.submit` to be consistent.
**Minimal Complete Verifiable Example**:
```python
>>> import distributed
>>> import astropy.units as u
>>> client = distributed.Client()
>>> func = lambda x: u.Quantity([x], 's')
# The return type of func is a Quantity
>>> func(10)
>>> type(func(10))
>>> task = client.submit(func, 10)
# The resulting future says the result of client.submit is Quantity
>>> task.type
# But the result is just a numpy array
>>> task.result()
array([10.])
>>> type(task.result())
```
**Anything else we need to know?**:
In past versions of dask/distributed and astropy, this inconsistency in return type was not present. I have not yet nailed down which version of which package led to this issue.
**Environment**:
- Dask version: 2022.7.1
- distributed version: 2022.7.1
- astropy version: 5.1
- Python version: 3.10.4
- Operating System: macOS 11.5.2
- Install method (conda, pip, source): pip
Contributor guide
Assessment
This issue has not been assessed yet.