dask / dask/dask-mpi

Strange interaction with astropy.coordinates.Angle

Open
#76 10 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
56
Forks
29
PR merge metrics
No merged PRs in 30d

Description

**What happened**:
This may be an issue in astropy, so my apologies if this is in the wrong location. Although, this appears to only happen using `dask-mpi`.

I'm using `dask-mpi` to distribute a task with using a `astropy.coordinates.Angle` object. When I try to convert to the `astropy.units.hourangle` format, I get the following error:
```
File "/group/askap/athomson/miniconda3/envs/spice/lib/python3.8/site-packages/astropy/coordinates/angles.py", line 316, in to_string
values = self.hour
File "/group/askap/athomson/miniconda3/envs/spice/lib/python3.8/site-packages/astropy/units/quantity.py", line 861, in __getattr__
raise AttributeError(
AttributeError: Angle instance has no attribute 'hour'
```

**What you expected to happen**:
Using a `LocalCluster` and a `SLURMcluster` I do not get this error using otherwise identical code. Further, `astropy.coordinate.Angle` explicitly has an `hour` property (L161):
```python
@property
def hour(self):
"""
The angle's value in hours (read-only property).
"""
return self.hourangle
```
Further, if I do (see MCVE):
```
print('hour' in dir(coord))
```
I get `True`! Something strange seems to be happening when I try to access the propety itself. I'll note something similar happened with `coordinates.SkyCoord` and it's `hms` property.

**Minimal Complete Verifiable Example**:
This is as close to a minimal setup as my working script. Very frustratingly, the MCVE does not produce the same error. Hair pulling abounds.
```python
from distributed import Client
from dask_mpi import initialize
from dask import delayed
from astropy.coordinates import Angle
import astropy.units as u

@delayed
def worker(i):
coord = Angle(i*u.deg)
print('coord.to_string()',coord.to_string())
print('coord.to_string(u.hourangle)',coord.to_string(u.hourangle, sep=':', precision=3))
return

def main():
initialize(interface='ipogif0')
client = Client()
results = []
for i in range(90):
results.append(
worker(i)
)
futures = client.persist(results)
outputs = [f.compute() for f in futures]
if __name__ == "__main__":
main()
```

**Anything else we need to know?**:

**Environment**:

- Dask version: 2021.05.0
- Dask-MPI version: 2.21.0
- Python version: 3.8.10
- Operating System: SUSE Linux Enterprise Server 12 SP3
- Install method (conda, pip, source): Conda

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.