I have an app that works the first time but crashes with the included error on second tries. I have isolated it to the hvplot object. I have tried wrapping it, returning from a function and all sorts of workarounds but for some weird reason when I execute the plot function a second time I get the error below.
Here is the most recent code that I have :
def get_output(event):
if len(files_select.value) == 0:
out_pane.clear()
out_pane.append(
pn.pane.Str(f'Empty-{select_field.value}-{cmap_sel.value}')
)
else:
xd = fstd2nc.Buffer(files_select.value).to_xarray()
xds = xd[select_field.value]
out_pane.clear()
out_pane.append(
xds.hvplot(
kind="quadmesh",
rasterize=True,
data_aspect=1,
frame_height=500,
cmap=cmap_sel.value,
crs=ccrs.PlateCarree(),
projection=ccrs.PlateCarree(),
project=True,
geo=True,
coastline=True,
global_extent=True,
widget_location='bottom',
title=f'{select_field.value}-{cmap_sel.value}'
)
)
out_button.on_click(get_output)
where the out_pane
is a pn.Column
although I have tried pn.pane.Bokeh
or simply not instanciating it and having a pn.bind
on the file select widget that was supposed to update but also gave me similar errors.
Traceback (most recent call last):
File "PATH_TO_ENV/pyviz_comms/__init__.py", line 346, in _handle_msg
self._on_msg(msg)
File "PATH_TO_ENV/panel/viewable.py", line 293, in _on_msg
patch.apply_to_document(doc, comm.id if comm else None)
File "PATH_TO_ENV/bokeh/protocol/messages/patch_doc.py", line 115, in apply_to_document
invoke_with_curdoc(doc, lambda: doc.apply_json_patch(self.content, setter))
File "PATH_TO_ENV/bokeh/document/callbacks.py", line 408, in invoke_with_curdoc
return f()
File "PATH_TO_ENV/bokeh/protocol/messages/patch_doc.py", line 115, in <lambda>
invoke_with_curdoc(doc, lambda: doc.apply_json_patch(self.content, setter))
File "PATH_TO_ENV/bokeh/document/document.py", line 391, in apply_json_patch
DocumentPatchedEvent.handle_json(self, event_json, references, setter)
File "PATH_TO_ENV/bokeh/document/events.py", line 259, in handle_json
handler(doc, event_json, references, setter)
File "PATH_TO_ENV/bokeh/document/events.py", line 300, in _handle_json
cb(event_json["msg_data"])
File "PATH_TO_ENV/bokeh/document/callbacks.py", line 355, in trigger_json_event
model._trigger_event(event)
File "PATH_TO_ENV/bokeh/util/callback_manager.py", line 119, in _trigger_event
self.document.callbacks.notify_event(cast(Model, self), event, invoke)
File "PATH_TO_ENV/bokeh/document/callbacks.py", line 247, in notify_event
invoke_with_curdoc(doc, callback_invoker)
File "PATH_TO_ENV/bokeh/document/callbacks.py", line 408, in invoke_with_curdoc
return f()
File "PATH_TO_ENV/bokeh/util/callback_manager.py", line 115, in invoke
cast(EventCallbackWithEvent, callback)(event)
File "PATH_TO_ENV/panel/reactive.py", line 415, in _comm_event
state._handle_exception(e)
File "PATH_TO_ENV/panel/io/state.py", line 391, in _handle_exception
raise exception
File "PATH_TO_ENV/panel/reactive.py", line 413, in _comm_event
self._process_bokeh_event(doc, event)
File "PATH_TO_ENV/panel/reactive.py", line 350, in _process_bokeh_event
self._process_event(event)
File "PATH_TO_ENV/panel/widgets/button.py", line 184, in _process_event
self.clicks += 1
File "PATH_TO_ENV/param/parameterized.py", line 367, in _f
instance_param.__set__(obj, val)
File "PATH_TO_ENV/param/parameterized.py", line 369, in _f
return f(self, obj, val)
File "PATH_TO_ENV/param/__init__.py", line 625, in __set__
super(Dynamic,self).__set__(obj,val)
File "PATH_TO_ENV/param/parameterized.py", line 369, in _f
return f(self, obj, val)
File "PATH_TO_ENV/param/parameterized.py", line 1248, in __set__
obj.param._call_watcher(watcher, event)
File "PATH_TO_ENV/param/parameterized.py", line 2039, in _call_watcher
self_._execute_watcher(watcher, (event,))
File "PATH_TO_ENV/param/parameterized.py", line 2021, in _execute_watcher
watcher.fn(*args, **kwargs)
File "/tmp/yor000/16839/ipykernel_19512/244807359.py", line 40, in get_output
out_pane.append(
File "PATH_TO_ENV/panel/layout/base.py", line 290, in append
self.objects = new_objects
File "PATH_TO_ENV/param/parameterized.py", line 367, in _f
instance_param.__set__(obj, val)
File "PATH_TO_ENV/param/parameterized.py", line 369, in _f
return f(self, obj, val)
File "PATH_TO_ENV/param/parameterized.py", line 1248, in __set__
obj.param._call_watcher(watcher, event)
File "PATH_TO_ENV/param/parameterized.py", line 2039, in _call_watcher
self_._execute_watcher(watcher, (event,))
File "PATH_TO_ENV/param/parameterized.py", line 2021, in _execute_watcher
watcher.fn(*args, **kwargs)
File "PATH_TO_ENV/panel/reactive.py", line 308, in _param_change
self._apply_update(named_events, msg, model, ref)
File "PATH_TO_ENV/panel/reactive.py", line 240, in _apply_update
self._update_model(events, msg, root, model, doc, comm)
File "PATH_TO_ENV/panel/layout/base.py", line 87, in _update_model
msg[self._rename['objects']] = self._get_objects(model, old, doc, root, comm)
File "PATH_TO_ENV/panel/layout/base.py", line 131, in _get_objects
child = pane._get_model(doc, root, model, comm)
File "PATH_TO_ENV/panel/layout/base.py", line 146, in _get_model
objects = self._get_objects(model, [], doc, root, comm)
File "PATH_TO_ENV/panel/layout/base.py", line 131, in _get_objects
child = pane._get_model(doc, root, model, comm)
File "PATH_TO_ENV/panel/pane/holoviews.py", line 265, in _get_model
plot = self._render(doc, comm, root)
File "PATH_TO_ENV/panel/pane/holoviews.py", line 342, in _render
return renderer.get_plot(self.object, **kwargs)
File "PATH_TO_ENV/holoviews/plotting/bokeh/renderer.py", line 70, in get_plot
plot = super().get_plot(obj, doc, renderer, **kwargs)
File "PATH_TO_ENV/holoviews/plotting/renderer.py", line 217, in get_plot
initialize_dynamic(obj)
File "PATH_TO_ENV/holoviews/plotting/util.py", line 256, in initialize_dynamic
dmap[dmap._initial_key()]
File "PATH_TO_ENV/holoviews/core/spaces.py", line 1217, in __getitem__
val = self._execute_callback(*tuple_key)
File "PATH_TO_ENV/holoviews/core/spaces.py", line 984, in _execute_callback
retval = self.callback(*args, **kwargs)
File "PATH_TO_ENV/holoviews/core/spaces.py", line 582, in __call__
ret = self.callable(*args, **kwargs)
File "PATH_TO_ENV/holoviews/util/__init__.py", line 996, in dynamic_operation
key, obj = resolve(key, kwargs)
File "PATH_TO_ENV/holoviews/util/__init__.py", line 985, in resolve
return key, map_obj[key]
File "PATH_TO_ENV/holoviews/core/spaces.py", line 1217, in __getitem__
val = self._execute_callback(*tuple_key)
File "PATH_TO_ENV/holoviews/core/spaces.py", line 984, in _execute_callback
retval = self.callback(*args, **kwargs)
File "PATH_TO_ENV/holoviews/core/spaces.py", line 582, in __call__
ret = self.callable(*args, **kwargs)
File "PATH_TO_ENV/holoviews/core/spaces.py", line 283, in dynamic_mul
element = self[args]
File "PATH_TO_ENV/holoviews/core/spaces.py", line 1217, in __getitem__
val = self._execute_callback(*tuple_key)
File "PATH_TO_ENV/holoviews/core/spaces.py", line 984, in _execute_callback
retval = self.callback(*args, **kwargs)
File "PATH_TO_ENV/holoviews/core/spaces.py", line 582, in __call__
ret = self.callable(*args, **kwargs)
File "PATH_TO_ENV/holoviews/util/__init__.py", line 996, in dynamic_operation
key, obj = resolve(key, kwargs)
File "PATH_TO_ENV/holoviews/util/__init__.py", line 985, in resolve
return key, map_obj[key]
File "PATH_TO_ENV/holoviews/core/spaces.py", line 1217, in __getitem__
val = self._execute_callback(*tuple_key)
File "PATH_TO_ENV/holoviews/core/spaces.py", line 984, in _execute_callback
retval = self.callback(*args, **kwargs)
File "PATH_TO_ENV/holoviews/core/spaces.py", line 582, in __call__
ret = self.callable(*args, **kwargs)
File "PATH_TO_ENV/holoviews/util/__init__.py", line 997, in dynamic_operation
return apply(obj, *key, **kwargs)
File "PATH_TO_ENV/holoviews/util/__init__.py", line 989, in apply
processed = self._process(element, key, kwargs)
File "PATH_TO_ENV/holoviews/util/__init__.py", line 971, in _process
return self.p.operation.process_element(element, key, **kwargs)
File "PATH_TO_ENV/holoviews/core/operation.py", line 194, in process_element
return self._apply(element, key)
File "PATH_TO_ENV/holoviews/core/operation.py", line 141, in _apply
ret = self._process(element, key)
File "PATH_TO_ENV/geoviews/operation/projection.py", line 439, in _process
element = element.map(op.instance(projection=self.p.projection),
File "PATH_TO_ENV/holoviews/core/data/__init__.py", line 204, in pipelined_fn
result = method_fn(*args, **kwargs)
File "PATH_TO_ENV/holoviews/core/data/__init__.py", line 1216, in map
return super(Dataset, self).map(*args, **kwargs)
File "PATH_TO_ENV/holoviews/core/dimension.py", line 701, in map
return map_fn(self) if applies else self
File "PATH_TO_ENV/holoviews/core/operation.py", line 220, in __call__
return element.apply(self, **kwargs)
File "PATH_TO_ENV/holoviews/core/accessors.py", line 45, in pipelined_call
result = __call__(*args, **kwargs)
File "PATH_TO_ENV/holoviews/core/accessors.py", line 202, in __call__
new_obj = apply_function(self._obj, **inner_kwargs)
File "PATH_TO_ENV/holoviews/core/operation.py", line 214, in __call__
return self._apply(element)
File "PATH_TO_ENV/holoviews/core/operation.py", line 141, in _apply
ret = self._process(element, key)
File "PATH_TO_ENV/geoviews/operation/projection.py", line 40, in _process
return element.map(self._process_element, self.supported_types)
File "PATH_TO_ENV/holoviews/core/data/__init__.py", line 204, in pipelined_fn
result = method_fn(*args, **kwargs)
File "PATH_TO_ENV/holoviews/core/data/__init__.py", line 1216, in map
return super(Dataset, self).map(*args, **kwargs)
File "PATH_TO_ENV/holoviews/core/dimension.py", line 701, in map
return map_fn(self) if applies else self
File "PATH_TO_ENV/geoviews/operation/projection.py", line 289, in _process_element
zs[mask] = np.NaN
ValueError: assignment destination is read-only