Quadmesh numba issue?

I’m trying to use a AWS SageMaker notebook with a FargateCluster, and hvplot is generally working, but with a 15 worker/60cpu cluster, this:

ds_sst.analysed_sst.sel(time='2005-01-01').hvplot.quadmesh(x='lon', y='lat', geo=True, 
                rasterize=True, cmap='rainbow', tiles='EsriImagery')

is giving this warning

WARNING:param.dynamic_operation: Callable raised "TypingError('Failed in nopython mode pipeline (step: nopython frontend)\nnon-precise type pyobject\n[1] During: typing of argument at <extend_cpu> (4)\n\nFile "<extend_cpu>", line 4:\n<source missing, REPL/exec in use?>\n\nThis error may have been caused by the following argument(s):\n- argument 4: cannot determine Numba type of <class \'dask.array.core.Array\'>\n\nThis is not usually a problem with Numba itself but instead often caused by\nthe use of unsupported features or an issue in resolving types.\n\nTo see Python/NumPy features supported by the latest release of Numba visit:\nhttp://numba.pydata.org/numba-doc/latest/reference/pysupported.html\nand\nhttp://numba.pydata.org/numba-doc/latest/reference/numpysupported.html\n\nFor more information about typing errors and how to debug them visit:\nhttp://numba.pydata.org/numba-doc/latest/user/troubleshoot.html#my-code-doesn-t-compile\n\nIf you think your code should work with Numba, please report the error message\nand traceback, along with a minimal reproducer at:\nhttps://github.com/numba/numba/issues/new\n\nThis error may have been caused by the following argument(s):\n- argument 4: cannot determine Numba type of <class \'dask.array.core.Array\'>\n\nThis is not usually a problem with Numba itself but instead often caused by\nthe use of unsupported features or an issue in resolving types.\n\nTo see Python/NumPy features supported by the latest release of Numba visit:\nhttp://numba.pydata.org/numba-doc/latest/reference/pysupported.html\nand\nhttp://numba.pydata.org/numba-doc/latest/reference/numpysupported.html\n\nFor more information about typing errors and how to debug them visit:\nhttp://numba.pydata.org/numba-doc/latest/user/troubleshoot.html#my-code-doesn-t-compile\n\nIf you think your code should work with Numba, please report the error message\nand traceback, along with a minimal reproducer at:\nhttps://github.com/numba/numba/issues/new\n',)".
Invoked as dynamic_operation(numpy.datetime64('2005-01-01T09:00:00.000000000'), height=400, scale=1.0, width=400, x_range=None, y_range=None)
WARNING:param.dynamic_mul: Callable raised "TypingError('Failed in nopython mode pipeline (step: nopython frontend)\nnon-precise type pyobject\n[1] During: typing of argument at <extend_cpu> (4)\n\nFile "<extend_cpu>", line 4:\n<source missing, REPL/exec in use?>\n\nThis error may have been caused by the following argument(s):\n- argument 4: cannot determine Numba type of <class \'dask.array.core.Array\'>\n\nThis is not usually a problem with Numba itself but instead often caused by\nthe use of unsupported features or an issue in resolving types.\n\nTo see Python/NumPy features supported by the latest release of Numba visit:\nhttp://numba.pydata.org/numba-doc/latest/reference/pysupported.html\nand\nhttp://numba.pydata.org/numba-doc/latest/reference/numpysupported.html\n\nFor more information about typing errors and how to debug them visit:\nhttp://numba.pydata.org/numba-doc/latest/user/troubleshoot.html#my-code-doesn-t-compile\n\nIf you think your code should work with Numba, please report the error message\nand traceback, along with a minimal reproducer at:\nhttps://github.com/numba/numba/issues/new\n\nThis error may have been caused by the following argument(s):\n- argument 4: cannot determine Numba type of <class \'dask.array.core.Array\'>\n\nThis is not usually a problem with Numba itself but instead often caused by\nthe use of unsupported features or an issue in resolving types.\n\nTo see Python/NumPy features supported by the latest release of Numba visit:\nhttp://numba.pydata.org/numba-doc/latest/reference/pysupported.html\nand\nhttp://numba.pydata.org/numba-doc/latest/reference/numpysupported.html\n\nFor more information about typing errors and how to debug them visit:\nhttp://numba.pydata.org/numba-doc/latest/user/troubleshoot.html#my-code-doesn-t-compile\n\nIf you think your code should work with Numba, please report the error message\nand traceback, along with a minimal reproducer at:\nhttps://github.com/numba/numba/issues/new\n',)".
Invoked as dynamic_mul(numpy.datetime64('2005-01-01T09:00:00.000000000'))
WARNING:param.dynamic_operation: Callable raised "TypingError('Failed in nopython mode pipeline (step: nopython frontend)\nnon-precise type pyobject\n[1] During: typing of argument at <extend_cpu> (4)\n\nFile "<extend_cpu>", line 4:\n<source missing, REPL/exec in use?>\n\nThis error may have been caused by the following argument(s):\n- argument 4: cannot determine Numba type of <class \'dask.array.core.Array\'>\n\nThis is not usually a problem with Numba itself but instead often caused by\nthe use of unsupported features or an issue in resolving types.\n\nTo see Python/NumPy features supported by the latest release of Numba visit:\nhttp://numba.pydata.org/numba-doc/latest/reference/pysupported.html\nand\nhttp://numba.pydata.org/numba-doc/latest/reference/numpysupported.html\n\nFor more information about typing errors and how to debug them visit:\nhttp://numba.pydata.org/numba-doc/latest/user/troubleshoot.html#my-code-doesn-t-compile\n\nIf you think your code should work with Numba, please report the error message\nand traceback, along with a minimal reproducer at:\nhttps://github.com/numba/numba/issues/new\n\nThis error may have been caused by the following argument(s):\n- argument 4: cannot determine Numba type of <class \'dask.array.core.Array\'>\n\nThis is not usually a problem with Numba itself but instead often caused by\nthe use of unsupported features or an issue in resolving types.\n\nTo see Python/NumPy features supported by the latest release of Numba visit:\nhttp://numba.pydata.org/numba-doc/latest/reference/pysupported.html\nand\nhttp://numba.pydata.org/numba-doc/latest/reference/numpysupported.html\n\nFor more information about typing errors and how to debug them visit:\nhttp://numba.pydata.org/numba-doc/latest/user/troubleshoot.html#my-code-doesn-t-compile\n\nIf you think your code should work with Numba, please report the error message\nand traceback, along with a minimal reproducer at:\nhttps://github.com/numba/numba/issues/new\n',)".
Invoked as dynamic_operation(numpy.datetime64('2005-01-01T09:00:00.000000000'))

then failing with

---------------------------------------------------------------------------
TypingError                               Traceback (most recent call last)
~/SageMaker/myenvs/pangeo/lib/python3.6/site-packages/IPython/core/formatters.py in __call__(self, obj, include, exclude)
    968 
    969             if method is not None:
--> 970                 return method(include=include, exclude=exclude)
    971             return None
    972         else:

~/SageMaker/myenvs/pangeo/lib/python3.6/site-packages/holoviews/core/dimension.py in _repr_mimebundle_(self, include, exclude)
   1292         combined and returned.
   1293         """
-> 1294         return Store.render(self)
   1295 
   1296 

~/SageMaker/myenvs/pangeo/lib/python3.6/site-packages/holoviews/core/options.py in render(cls, obj)
   1366         data, metadata = {}, {}
   1367         for hook in hooks:
-> 1368             ret = hook(obj)
   1369             if ret is None:
   1370                 continue

~/SageMaker/myenvs/pangeo/lib/python3.6/site-packages/holoviews/ipython/display_hooks.py in pprint_display(obj)
    279     if not ip.display_formatter.formatters['text/plain'].pprint:
    280         return None
--> 281     return display(obj, raw_output=True)
    282 
    283 

~/SageMaker/myenvs/pangeo/lib/python3.6/site-packages/holoviews/ipython/display_hooks.py in display(obj, raw_output, **kwargs)
    255     elif isinstance(obj, (HoloMap, DynamicMap)):
    256         with option_state(obj):
--> 257             output = map_display(obj)
    258     elif isinstance(obj, Plot):
    259         output = render(obj)

~/SageMaker/myenvs/pangeo/lib/python3.6/site-packages/holoviews/ipython/display_hooks.py in wrapped(element)
    144         try:
    145             max_frames = OutputSettings.options['max_frames']
--> 146             mimebundle = fn(element, max_frames=max_frames)
    147             if mimebundle is None:
    148                 return {}, {}

~/SageMaker/myenvs/pangeo/lib/python3.6/site-packages/holoviews/ipython/display_hooks.py in map_display(vmap, max_frames)
    204         return None
    205 
--> 206     return render(vmap)
    207 
    208 

~/SageMaker/myenvs/pangeo/lib/python3.6/site-packages/holoviews/ipython/display_hooks.py in render(obj, **kwargs)
     66         renderer = renderer.instance(fig='png')
     67 
---> 68     return renderer.components(obj, **kwargs)
     69 
     70 

~/SageMaker/myenvs/pangeo/lib/python3.6/site-packages/holoviews/plotting/bokeh/renderer.py in components(self, obj, fmt, comm, **kwargs)
    248         # Bokeh has to handle comms directly in <0.12.15
    249         comm = False if bokeh_version < '0.12.15' else comm
--> 250         return super(BokehRenderer, self).components(obj,fmt, comm, **kwargs)
    251 
    252 

~/SageMaker/myenvs/pangeo/lib/python3.6/site-packages/holoviews/plotting/renderer.py in components(self, obj, fmt, comm, **kwargs)
    319             plot = obj
    320         else:
--> 321             plot, fmt = self._validate(obj, fmt)
    322 
    323         data, metadata = {}, {}

~/SageMaker/myenvs/pangeo/lib/python3.6/site-packages/holoviews/plotting/renderer.py in _validate(self, obj, fmt, **kwargs)
    218         if isinstance(obj, tuple(self.widgets.values())):
    219             return obj, 'html'
--> 220         plot = self.get_plot(obj, renderer=self, **kwargs)
    221 
    222         fig_formats = self.mode_formats['fig'][self.mode]

~/SageMaker/myenvs/pangeo/lib/python3.6/site-packages/holoviews/plotting/bokeh/renderer.py in get_plot(self_or_cls, obj, doc, renderer, **kwargs)
    133             curdoc().theme = self_or_cls.theme
    134         doc.theme = self_or_cls.theme
--> 135         plot = super(BokehRenderer, self_or_cls).get_plot(obj, renderer, **kwargs)
    136         plot.document = doc
    137         return plot

~/SageMaker/myenvs/pangeo/lib/python3.6/site-packages/holoviews/plotting/renderer.py in get_plot(self_or_cls, obj, renderer, **kwargs)
    184 
    185         # Initialize DynamicMaps with first data item
--> 186         initialize_dynamic(obj)
    187 
    188         if not isinstance(obj, Plot):

~/SageMaker/myenvs/pangeo/lib/python3.6/site-packages/holoviews/plotting/util.py in initialize_dynamic(obj)
    248             continue
    249         if not len(dmap):
--> 250             dmap[dmap._initial_key()]
    251 
    252 

~/SageMaker/myenvs/pangeo/lib/python3.6/site-packages/holoviews/core/spaces.py in __getitem__(self, key)
   1325         # Not a cross product and nothing cached so compute element.
   1326         if cache is not None: return cache
-> 1327         val = self._execute_callback(*tuple_key)
   1328         if data_slice:
   1329             val = self._dataslice(val, data_slice)

~/SageMaker/myenvs/pangeo/lib/python3.6/site-packages/holoviews/core/spaces.py in _execute_callback(self, *args)
   1098 
   1099         with dynamicmap_memoization(self.callback, self.streams):
-> 1100             retval = self.callback(*args, **kwargs)
   1101         return self._style(retval)
   1102 

~/SageMaker/myenvs/pangeo/lib/python3.6/site-packages/holoviews/core/spaces.py in __call__(self, *args, **kwargs)
    732 
    733         try:
--> 734             ret = self.callable(*args, **kwargs)
    735         except KeyError:
    736             # KeyError is caught separately because it is used to signal

~/SageMaker/myenvs/pangeo/lib/python3.6/site-packages/holoviews/util/__init__.py in dynamic_operation(*key, **kwargs)
    943                 if map_obj._posarg_keys and not key:
    944                     key = tuple(kwargs[k] for k in map_obj._posarg_keys)
--> 945                 return self._process(map_obj[key], key, kwargs)
    946         if isinstance(self.p.operation, Operation):
    947             return OperationCallable(dynamic_operation, inputs=[map_obj],

~/SageMaker/myenvs/pangeo/lib/python3.6/site-packages/holoviews/core/spaces.py in __getitem__(self, key)
   1325         # Not a cross product and nothing cached so compute element.
   1326         if cache is not None: return cache
-> 1327         val = self._execute_callback(*tuple_key)
   1328         if data_slice:
   1329             val = self._dataslice(val, data_slice)

~/SageMaker/myenvs/pangeo/lib/python3.6/site-packages/holoviews/core/spaces.py in _execute_callback(self, *args)
   1098 
   1099         with dynamicmap_memoization(self.callback, self.streams):
-> 1100             retval = self.callback(*args, **kwargs)
   1101         return self._style(retval)
   1102 

~/SageMaker/myenvs/pangeo/lib/python3.6/site-packages/holoviews/core/spaces.py in __call__(self, *args, **kwargs)
    732 
    733         try:
--> 734             ret = self.callable(*args, **kwargs)
    735         except KeyError:
    736             # KeyError is caught separately because it is used to signal

~/SageMaker/myenvs/pangeo/lib/python3.6/site-packages/holoviews/core/overlay.py in dynamic_mul(*args, **kwargs)
     29             from .spaces import Callable
     30             def dynamic_mul(*args, **kwargs):
---> 31                 element = other[args]
     32                 return self * element
     33             callback = Callable(dynamic_mul, inputs=[self, other])

~/SageMaker/myenvs/pangeo/lib/python3.6/site-packages/holoviews/core/spaces.py in __getitem__(self, key)
   1325         # Not a cross product and nothing cached so compute element.
   1326         if cache is not None: return cache
-> 1327         val = self._execute_callback(*tuple_key)
   1328         if data_slice:
   1329             val = self._dataslice(val, data_slice)

~/SageMaker/myenvs/pangeo/lib/python3.6/site-packages/holoviews/core/spaces.py in _execute_callback(self, *args)
   1098 
   1099         with dynamicmap_memoization(self.callback, self.streams):
-> 1100             retval = self.callback(*args, **kwargs)
   1101         return self._style(retval)
   1102 

~/SageMaker/myenvs/pangeo/lib/python3.6/site-packages/holoviews/core/spaces.py in __call__(self, *args, **kwargs)
    732 
    733         try:
--> 734             ret = self.callable(*args, **kwargs)
    735         except KeyError:
    736             # KeyError is caught separately because it is used to signal

~/SageMaker/myenvs/pangeo/lib/python3.6/site-packages/holoviews/util/__init__.py in dynamic_operation(*key, **kwargs)
    943                 if map_obj._posarg_keys and not key:
    944                     key = tuple(kwargs[k] for k in map_obj._posarg_keys)
--> 945                 return self._process(map_obj[key], key, kwargs)
    946         if isinstance(self.p.operation, Operation):
    947             return OperationCallable(dynamic_operation, inputs=[map_obj],

~/SageMaker/myenvs/pangeo/lib/python3.6/site-packages/holoviews/util/__init__.py in _process(self, element, key, kwargs)
    924         elif isinstance(self.p.operation, Operation):
    925             kwargs = {k: v for k, v in kwargs.items() if k in self.p.operation.param}
--> 926             return self.p.operation.process_element(element, key, **kwargs)
    927         else:
    928             return self.p.operation(element, **kwargs)

~/SageMaker/myenvs/pangeo/lib/python3.6/site-packages/holoviews/core/operation.py in process_element(self, element, key, **params)
    141         """
    142         self.p = param.ParamOverrides(self, params)
--> 143         return self._apply(element, key)
    144 
    145 

~/SageMaker/myenvs/pangeo/lib/python3.6/site-packages/holoviews/core/operation.py in _apply(self, element, key)
    119         for hook in self._preprocess_hooks:
    120             kwargs.update(hook(self, element))
--> 121         ret = self._process(element, key)
    122         for hook in self._postprocess_hooks:
    123             ret = hook(self, ret, **kwargs)

~/SageMaker/myenvs/pangeo/lib/python3.6/site-packages/holoviews/operation/datashader.py in _process(self, element, key)
    946             op = transform.instance(**op_params)
    947             op._precomputed = self._precomputed
--> 948             element = element.map(op, predicate)
    949             self._precomputed = op._precomputed
    950         return element

~/SageMaker/myenvs/pangeo/lib/python3.6/site-packages/holoviews/core/dimension.py in map(self, map_fn, specs, clone)
    702             return deep_mapped
    703         else:
--> 704             return map_fn(self) if applies else self
    705 
    706 

~/SageMaker/myenvs/pangeo/lib/python3.6/site-packages/holoviews/core/operation.py in __call__(self, element, **kwargs)
    159                                       for k, el in element.items()])
    160             elif isinstance(element, ViewableElement):
--> 161                 return self._apply(element)
    162         elif 'streams' not in kwargs:
    163             kwargs['streams'] = self.p.streams

~/SageMaker/myenvs/pangeo/lib/python3.6/site-packages/holoviews/core/operation.py in _apply(self, element, key)
    119         for hook in self._preprocess_hooks:
    120             kwargs.update(hook(self, element))
--> 121         ret = self._process(element, key)
    122         for hook in self._postprocess_hooks:
    123             ret = hook(self, ret, **kwargs)

~/SageMaker/myenvs/pangeo/lib/python3.6/site-packages/holoviews/operation/datashader.py in _process(self, element, key)
    882 
    883         vdim = getattr(agg_fn, 'column', element.vdims[0].name)
--> 884         agg = cvs.quadmesh(data[vdim], x.name, y.name, agg_fn)
    885         xdim, ydim = list(agg.dims)[:2][::-1]
    886         if xtype == "datetime":

~/SageMaker/myenvs/pangeo/lib/python3.6/site-packages/datashader/core.py in quadmesh(self, source, x, y, agg)
    770                 dims=list(xarr.dims)))
    771 
--> 772         return bypixel(source, self, glyph, agg)
    773 
    774     # TODO re 'untested', below: Consider replacing with e.g. a 3x3

~/SageMaker/myenvs/pangeo/lib/python3.6/site-packages/datashader/core.py in bypixel(source, canvas, glyph, agg)
   1159     with np.warnings.catch_warnings():
   1160         np.warnings.filterwarnings('ignore', r'All-NaN (slice|axis) encountered')
-> 1161         return bypixel.pipeline(source, schema, canvas, glyph, agg)
   1162 
   1163 

~/SageMaker/myenvs/pangeo/lib/python3.6/site-packages/datashader/utils.py in __call__(self, head, *rest, **kwargs)
     91         typ = type(head)
     92         if typ in lk:
---> 93             return lk[typ](head, *rest, **kwargs)
     94         for cls in getmro(typ)[1:]:
     95             if cls in lk:

~/SageMaker/myenvs/pangeo/lib/python3.6/site-packages/datashader/data_libraries/xarray.py in xarray_pipeline(df, schema, canvas, glyph, summary)
     17 def xarray_pipeline(df, schema, canvas, glyph, summary):
     18     cuda = cupy and isinstance(df[glyph.name].data, cupy.ndarray)
---> 19     return glyph_dispatch(glyph, df, schema, canvas, summary, cuda)
     20 
     21 

~/SageMaker/myenvs/pangeo/lib/python3.6/site-packages/datashader/utils.py in __call__(self, head, *rest, **kwargs)
     94         for cls in getmro(typ)[1:]:
     95             if cls in lk:
---> 96                 return lk[cls](head, *rest, **kwargs)
     97         raise TypeError("No dispatch for {0} type".format(typ))
     98 

~/SageMaker/myenvs/pangeo/lib/python3.6/site-packages/datashader/data_libraries/pandas.py in default(glyph, source, schema, canvas, summary, cuda)
     43 
     44     bases = create((height, width))
---> 45     extend(bases, source, x_st + y_st, x_range + y_range)
     46 
     47     return finalize(bases,

~/SageMaker/myenvs/pangeo/lib/python3.6/site-packages/datashader/glyphs/quadmesh.py in extend(aggs, xr_ds, vt, bounds)
    186                 do_extend = extend_cpu
    187 
--> 188             do_extend(xs, ys, *aggs_and_cols)
    189 
    190         return extend

~/SageMaker/myenvs/pangeo/lib/python3.6/site-packages/numba/dispatcher.py in _compile_for_args(self, *args, **kws)
    399                 e.patch_message(msg)
    400 
--> 401             error_rewrite(e, 'typing')
    402         except errors.UnsupportedError as e:
    403             # Something unsupported is present in the user code, add help info

~/SageMaker/myenvs/pangeo/lib/python3.6/site-packages/numba/dispatcher.py in error_rewrite(e, issue_type)
    342                 raise e
    343             else:
--> 344                 reraise(type(e), e, None)
    345 
    346         argtypes = []

~/SageMaker/myenvs/pangeo/lib/python3.6/site-packages/numba/six.py in reraise(tp, value, tb)
    666             value = tp()
    667         if value.__traceback__ is not tb:
--> 668             raise value.with_traceback(tb)
    669         raise value
    670 

TypingError: Failed in nopython mode pipeline (step: nopython frontend)
non-precise type pyobject
[1] During: typing of argument at <extend_cpu> (4)

File "<extend_cpu>", line 4:
<source missing, REPL/exec in use?>

This error may have been caused by the following argument(s):
- argument 4: cannot determine Numba type of <class 'dask.array.core.Array'>

This is not usually a problem with Numba itself but instead often caused by
the use of unsupported features or an issue in resolving types.

To see Python/NumPy features supported by the latest release of Numba visit:
http://numba.pydata.org/numba-doc/latest/reference/pysupported.html
and
http://numba.pydata.org/numba-doc/latest/reference/numpysupported.html

For more information about typing errors and how to debug them visit:
http://numba.pydata.org/numba-doc/latest/user/troubleshoot.html#my-code-doesn-t-compile

If you think your code should work with Numba, please report the error message
and traceback, along with a minimal reproducer at:
https://github.com/numba/numba/issues/new

This error may have been caused by the following argument(s):
- argument 4: cannot determine Numba type of <class 'dask.array.core.Array'>

This is not usually a problem with Numba itself but instead often caused by
the use of unsupported features or an issue in resolving types.

To see Python/NumPy features supported by the latest release of Numba visit:
http://numba.pydata.org/numba-doc/latest/reference/pysupported.html
and
http://numba.pydata.org/numba-doc/latest/reference/numpysupported.html

For more information about typing errors and how to debug them visit:
http://numba.pydata.org/numba-doc/latest/user/troubleshoot.html#my-code-doesn-t-compile

If you think your code should work with Numba, please report the error message
and traceback, along with a minimal reproducer at:
https://github.com/numba/numba/issues/new


:DynamicMap   [time]

Afaik the datashader quadmesh renderer does not yet support dask arrays (see the table here). I guess for now we should warn and load the data into memory?

Thanks for that table. Very useful! But I’m confused. I have used quadmesh with xarray and dask with many other dask clusters, and I’ve never had this problem. Or perhaps I don’t understand the issue?

Are you sure? It’s possible that it previously loaded the array into memory (and therefore converted to a numpy array) and while adding cupy support this was removed. That seems somewhat unlikely to me though. In any case it would be good to raise this as an issue with datashader.

@philippfr, that’s super useful information! I bet my other data visualizations have fit into memory, so even though I was using dask, the dask worker containers didn’t need the holoviz packages. If I’m trying to execute this command:

ds_sst.analysed_sst.sel(time='2005-01-01').hvplot.quadmesh(x='lon', y='lat', geo=True, 
                rasterize=True, cmap='rainbow', tiles='EsriImagery')

what would be the requirements for the dask worker container environments?

Just datashader and holoviews?