holoviz-topics / EarthSim

Tools for working with and visualizing environmental simulations.
https://earthsim.holoviz.org
BSD 3-Clause "New" or "Revised" License
65 stars 21 forks source link

Plot options has broken some examples #280

Closed kcpevey closed 3 years ago

kcpevey commented 5 years ago

I've run across this in several of my workflows, and I just ran across it in the earthsim/topics/GrabCutDemo on the website http://earthsim.pyviz.org/topics/GrabCut.html . That website just gives a long traceback.

When I run the notebook locally (with dev releases) I get:

WARNING:root:StamenLabels: Use of __call__ to set options will be deprecated in future. Use the equivalent opts method or use the recommended .options method instead.
WARNING:root:<bound method SelectRegionPanel.callback of SelectRegionPanel(height=700, magnification=1, name='SelectRegionPanel05199', tile_server='https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{Z}/{Y}/{X}', width=900, zoom_level=7)>: Callable raised "AttributeError("'NoneType' object has no attribute 'key'",)".
Invoked as <bound method SelectRegionPanel.callback of SelectRegionPanel(height=700, magnification=1, name='SelectRegionPanel05199', tile_server='https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{Z}/{Y}/{X}', width=900, zoom_level=7)>()
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
~/miniconda3/envs/goatt/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:

~/miniconda3/envs/goatt/lib/python3.6/site-packages/panel/viewable.py in _repr_mimebundle_(self, include, exclude)
    107         doc = Document()
    108         comm = self._comm_manager.get_server_comm()
--> 109         model = self._get_root(doc, comm)
    110         Viewable._views[model.ref['id']] = (self, model)
    111         return render_mimebundle(model, doc, comm)

~/miniconda3/envs/goatt/lib/python3.6/site-packages/panel/viewable.py in _get_root(self, doc, comm)
     84           Optional pyviz_comms when working in notebook
     85         """
---> 86         root = self._get_model(doc, comm=comm)
     87         self._preprocess(root)
     88         return root

~/miniconda3/envs/goatt/lib/python3.6/site-packages/panel/layout.py in _get_model(self, doc, root, parent, comm)
    130         model = self._bokeh_model()
    131         root = model if root is None else root
--> 132         objects = self._get_objects(model, [], doc, root, comm)
    133 
    134         # HACK ALERT: Insert Spacer if last item in Column has no height

~/miniconda3/envs/goatt/lib/python3.6/site-packages/panel/layout.py in _get_objects(self, model, old_objects, doc, root, comm)
    123                 child = pane._models[root.ref['id']]
    124             else:
--> 125                 child = pane._get_model(doc, root, model, comm)
    126             new_models.append(child)
    127         return new_models

~/miniconda3/envs/goatt/lib/python3.6/site-packages/panel/holoviews.py in _get_model(self, doc, root, parent, comm)
    112         """
    113         ref = root.ref['id']
--> 114         plot = self._render(doc, comm, root)
    115         child_pane = Pane(plot.state, _temporary=True)
    116         model = child_pane._get_model(doc, root, parent, comm)

~/miniconda3/envs/goatt/lib/python3.6/site-packages/panel/holoviews.py in _render(self, doc, comm, root)
     98         if comm:
     99             kwargs['comm'] = comm
--> 100         plot = renderer.get_plot(self.object, **kwargs)
    101         ref = root.ref['id']
    102         if ref in self._plots:

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

~/miniconda3/envs/goatt/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):

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

~/miniconda3/envs/goatt/lib/python3.6/site-packages/holoviews/core/spaces.py in __getitem__(self, key)
   1309         # Not a cross product and nothing cached so compute element.
   1310         if cache is not None: return cache
-> 1311         val = self._execute_callback(*tuple_key)
   1312         if data_slice:
   1313             val = self._dataslice(val, data_slice)

~/miniconda3/envs/goatt/lib/python3.6/site-packages/holoviews/core/spaces.py in _execute_callback(self, *args)
   1082 
   1083         with dynamicmap_memoization(self.callback, self.streams):
-> 1084             retval = self.callback(*args, **kwargs)
   1085         return self._style(retval)
   1086 

~/miniconda3/envs/goatt/lib/python3.6/site-packages/holoviews/core/spaces.py in __call__(self, *args, **kwargs)
    689         kwarg_hash = kwargs.pop('_memoization_hash_', ())
    690         (self.args, self.kwargs) = (args, kwargs)
--> 691         if not args and not kwargs and not any(kwarg_hash): return self.callable()
    692         inputs = [i for i in self.inputs if isinstance(i, DynamicMap)]
    693         streams = []

~/miniconda3/envs/goatt/lib/python3.6/site-packages/holoviews/core/spaces.py in dynamic_mul(*args, **kwargs)
    288             if isinstance(self, DynamicMap):
    289                 def dynamic_mul(*args, **kwargs):
--> 290                     element = self[args]
    291                     if reverse:
    292                         return other * element

~/miniconda3/envs/goatt/lib/python3.6/site-packages/holoviews/core/spaces.py in __getitem__(self, key)
   1309         # Not a cross product and nothing cached so compute element.
   1310         if cache is not None: return cache
-> 1311         val = self._execute_callback(*tuple_key)
   1312         if data_slice:
   1313             val = self._dataslice(val, data_slice)

~/miniconda3/envs/goatt/lib/python3.6/site-packages/holoviews/core/spaces.py in _execute_callback(self, *args)
   1082 
   1083         with dynamicmap_memoization(self.callback, self.streams):
-> 1084             retval = self.callback(*args, **kwargs)
   1085         return self._style(retval)
   1086 

~/miniconda3/envs/goatt/lib/python3.6/site-packages/holoviews/core/spaces.py in __call__(self, *args, **kwargs)
    719 
    720         try:
--> 721             ret = self.callable(*args, **kwargs)
    722         except KeyError:
    723             # KeyError is caught separately because it is used to signal

~/miniconda3/envs/goatt/lib/python3.6/site-packages/param/parameterized.py in _depends(*args, **kw)
    232     @wraps(func)
    233     def _depends(*args,**kw):
--> 234         return func(*args,**kw)
    235 
    236     # storing here risks it being tricky to find if other libraries

~/ers/gitHub/earthsim/master/EarthSim/earthsim/grabcut.py in callback(self)
    364     @param.depends('tile_server')
    365     def callback(self):
--> 366         return (gv.WMTS(self.tile_server) * gv.tile_sources.StamenLabels())
    367 
    368     @property

~/miniconda3/envs/goatt/lib/python3.6/site-packages/holoviews/core/dimension.py in __call__(self, options, **kwargs)
   1312                          'the recommended .options method instead.')
   1313 
-> 1314         return self.opts(options, **kwargs)
   1315 
   1316 

~/miniconda3/envs/goatt/lib/python3.6/site-packages/holoviews/core/options.py in __call__(self, *args, **kwargs)
    108         """
    109         if self.mode is None:
--> 110             return self._base_opts(*args, **kwargs)
    111         elif self.mode == 'holomap':
    112             return self._holomap_opts(*args, **kwargs)

~/miniconda3/envs/goatt/lib/python3.6/site-packages/holoviews/core/options.py in _base_opts(self, *args, **kwargs)
    187 
    188         kwargs['clone'] = False if clone is None else clone
--> 189         return self.obj.options(*args, **kwargs)
    190 
    191 

~/miniconda3/envs/goatt/lib/python3.6/site-packages/holoviews/core/dimension.py in options(self, *args, **kwargs)
   1380             expanded = {}
   1381         else:
-> 1382             expanded = opts._expand_options(options, backend)
   1383         return self.opts(expanded, backend=backend, clone=clone)
   1384 

~/miniconda3/envs/goatt/lib/python3.6/site-packages/holoviews/util/__init__.py in _expand_options(cls, options, backend)
    263         expanded = {}
    264         if isinstance(options, list):
--> 265             options = merge_options_to_dict(options)
    266 
    267         for objspec, options in options.items():

~/miniconda3/envs/goatt/lib/python3.6/site-packages/holoviews/core/util.py in merge_options_to_dict(options)
    219             new_opts = obj
    220         else:
--> 221             new_opts = {obj.key: obj.kwargs}
    222 
    223         merged_options = merge_option_dicts(merged_options, new_opts)

AttributeError: 'NoneType' object has no attribute 'key'
philippjfr commented 5 years ago

That's quite worrying, the options changes should have been fully backward compatible.

philippjfr commented 5 years ago

Actually I see the issue, I'll make the fix in geoviews in a bit and then push out 1.6.1.

philippjfr commented 5 years ago

Fixed in https://github.com/pyviz/geoviews/pull/274

kcpevey commented 5 years ago

This page is still broken: http://earthsim.pyviz.org/topics/GrabCut.html

philippjfr commented 5 years ago

Thanks, we're releasing hv 1.11.1 tonight and then I'll trigger a rebuild.

kcpevey commented 3 years ago

Resolved