Repository navigation
Closed
Description
When using dask[array], most commands to create array objects claim to require a chunks= kwarg in the docs. However, a dask array object is successfully created with the default chunks=None. Then it fails when .compute() is called, with a less than informative traceback.
Minimal example:
import dask.array as da
has_chunks = da.random.random(size=(100, 100), chunks=(100, 100))
no_chunks = da.random.random(size=(100, 100)) # chunks left at default (None), succeeds
has_chunks.mean(axis=0).compute() # succeeds
no_chunks.mean(axis=0).compute() # fails - traceback not particularly informative (see below)Unless some future functionality is intended to automatically set chunks if chunks=None, I'd propose this workflow should fail earlier at the point chunks is not provided to be consistent with the docs. Alternatively, the error when .compute() is called on an array with chunks=None could be more informative.
Traceback:
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
<ipython-input-22-f80a4f9b0fcd> in <module>()
1 nparr = np.random.random(size=(100, 100))
2 darr = da.ones((100, 100))
----> 3 darr.mean(axis=0).compute()
/src/anaconda/lib/python2.7/site-packages/dask/array/core.pyc in compute(self, **kwargs)
721 @wraps(compute)
722 def compute(self, **kwargs):
--> 723 result, = compute(self, **kwargs)
724 return result
725
/src/anaconda/lib/python2.7/site-packages/dask/array/core.pyc in compute(*args, **kwargs)
514
515 results2 = tuple(concatenate3(x) if arg.shape else unpack_singleton(x)
--> 516 for x, arg in zip(results, args))
517 return results2
518
/src/anaconda/lib/python2.7/site-packages/dask/array/core.pyc in <genexpr>((x, arg))
514
515 results2 = tuple(concatenate3(x) if arg.shape else unpack_singleton(x)
--> 516 for x, arg in zip(results, args))
517 return results2
518
/src/anaconda/lib/python2.7/site-packages/dask/array/core.pyc in concatenate3(arrays)
2035 """
2036 arrays = concrete(arrays)
-> 2037 ndim = ndimlist(arrays)
2038 if not ndim:
2039 return arrays
/src/anaconda/lib/python2.7/site-packages/dask/array/core.pyc in ndimlist(seq)
2014 return 0
2015 else:
-> 2016 return 1 + ndimlist(seq[0])
2017
2018
IndexError: list index out of rangeMetadata
Metadata
Assignees
Labels
No labels
Activity
mrocklin commentedon Jul 11, 2015
Oh yes, indeed. I can see how that would trip up almost any incoming user.
JDWarner commentedon Jul 11, 2015
This definitely didn't just happen to me...
mrocklin commentedon Jul 11, 2015
On it.
JDWarner commentedon Jul 11, 2015
Since it appears
dask_arr.chunkscan dynamically be changed after creation, the best approach is probably to fail gracefully on computation.Raise informative error on chunks=None
mrocklin commentedon Jul 11, 2015
Fixed in #416
Regarding chunks changing after creation, I don't think I've ever seen this happen. I also have a hard time thinking of a situation in which it wouldn't be catastrophic. In my mind
chunksis immutable. This isn't at all enforced but I have yet to encounter a person who has tried to change it. I suppose we could hook this up into a property that callsrechunk, but I'd rather wait until the person comes along who trips on this.JDWarner commentedon Jul 11, 2015
Thanks, @mrocklin!
Re: chunks changing after creation I just tried to do exactly that - the
chunksproperty accepts any tuple then fails in a different, nasty way on.compute().mrocklin commentedon Jul 11, 2015
Sounds like that person just came along. Changing to property + private variable
mrocklin commentedon Jul 11, 2015
Fixed in mrocklin@b1cbc72