Astropy Units with Dask distributed
See original GitHub issueDescription
Hi there, I’m using dask to scale some work I’m doing. A small step includes some astropy unit conversions. This works fine when using distributed.LocalCluster
for tests, but I’m getting some unexpected errors when I scale to use dask_jobqueue.SLURMCluster
. I’m not sure if the issue lies inside of Dask or astropy units, but I wanted to see if there was something I was missing, or some edge-case that might be cropping up.
Expected behavior
I’m adding/converting arcseconds and degrees, which should convert.
Actual behavior
I get the following error when deployed on the Slurm cluster:
Exception: UnitConversionError("'arcsec' (angle) and 'deg' (angle) are not convertible")
Steps to Reproduce
This is the closest to a basic version of the script I’ve been using. Frustratingly, though, this demo hasn’t been reproducing the same error for me.
#!/usr/bin/env python
import numpy as np
from dask import delayed
from dask_jobqueue import SLURMCluster
from distributed import Client, progress, performance_report, LocalCluster
from dask.diagnostics import ProgressBar
import astropy.units as u
import time
@delayed
def add(x):
y = 1*u.deg
out = x + y
# Mimic some other work
time.sleep(10)
return out
def main(client, verbose=True):
xs = np.ones(4000)*u.arcsec
outputs = []
for x in xs:
output = add(x)
outputs.append(output)
results = client.persist(outputs)
if verbose:
print("Doing work...")
progress(results)
if verbose:
print('Done!')
def cli():
# Leaving at default, but I configure it for my cluster in my scripts
cluster = SLURMCluster()
# Request up to 25 nodes
cluster.adapt(minimum=0, maximum=25)
client = Client(cluster)
main(client)
if __name__ == "__main__":
cli()
System Details
Linux-4.4.180-94.130-default-x86_64-with-SuSE-12-x86_64
Python 3.7.6 (default, Jan 8 2020, 19:59:22)
[GCC 7.3.0]
Numpy 1.18.1
astropy 4.2
Scipy 1.4.1
Matplotlib 3.1.3
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Integration with dask — spectral-cube v0.6.1.dev244+g13f4ea9
To read in a FITS cube using the dask-enabled classes, you can do: >>> >>> from astropy.utils import data >>> from spectral_cube import...
Read more >Units and Quantities (astropy.units) — Astropy v5.2
This subpackage contains classes and functions for defining and converting between different physical units. This code is adapted from the pynbody units module ......
Read more >Simple demonstration of the use of Dask/rsexecute - GitLab
Simple demonstration of the use of Dask/rsexecute . import os import sys sys.path.append(os.path.join('..','..')) import numpy import astropy.units as u ...
Read more >How to serialize metpy (pint) units for use with dask distributed?
as mpcalc from ; from dask.distributed import ; calculate_dewpoint(vapor_pressure): ; return dewpoint cluster = LocalCluster() client = Client( ...
Read more >pyphot.astropy package
class pyphot.astropy.sandbox. Constants [source]¶ ... Photon distribution based effective wavelength. ... Note the usual (non SI) units of flux definitions:.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@pllim in the output logs, it only prints the Error I put above, and not the full traceback. Although, I also just found that this (pretty dumb) change ‘fixes’ the issue is effectively:
@mhvk that sounds like the kind of issue I was worried about. Is that available via conda? Or, will I need to install from the git repo? Thanks!
Sounds fishy. Did you try print out what
x
actually is before it crashed?