Intermittent TypeError in Panel Dashboard - hard to reproduce

Hi,
I’ve created a panel dashboard that works well, but occasionally raises a TypeError that doesn’t seem to affect the dashboard functioning but does stack up long error messages. I’m able to work around the issues by setting pn.config.console_output = 'disable'. The error doesn’t seem to affect the output, so that is a fix, but I’d like to understand why the error is occurring and more importantly how to debug it.

The code to produce the dashboard is available here. This plot function creates a dashboard with three tabs to plot timeseries curves. The error (at the end of the post) occurs most often when selecting or un-selecting columns or groups of column identifiers on the third tab, which is used to create custom overlays of curves:

It seems like possibly a performance related issue. I haven’t been able to recreate the error by using the underlying plotting functions that the dashboard calls. I also haven’t found any reliable series of interactions with the dashboard to re-create the error.

I think the easiest (admittedly not that easy) way to try to attempt to re-create the issue is to clone the branch linked to above and add ct.plotting.plot(das) to the /docs/examples/concise_capacity_test.ipynb in place of the existing plotting call das.plot(marker='line', width=900, height=250, ncols=1, use_abrev_name=False).

Any suggestions on how to debug this or making it easier to re-create the issue would be much appreciated.

Thanks!

Here is the error message:

Traceback (most recent call last):
  File "/home/ben/miniconda3/envs/pvcaptest/lib/python3.11/site-packages/panel/viewable.py", line 591, in _preprocess
    hook(self, root, changed, old_models)
TypeError: link_axes() takes 2 positional arguments but 4 were given

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ben/miniconda3/envs/pvcaptest/lib/python3.11/site-packages/pyviz_comms/__init__.py", line 340, in _handle_msg
    self._on_msg(msg)
  File "/home/ben/miniconda3/envs/pvcaptest/lib/python3.11/site-packages/panel/viewable.py", line 471, in _on_msg
    doc.unhold()
  File "/home/ben/miniconda3/envs/pvcaptest/lib/python3.11/site-packages/bokeh/document/document.py", line 776, in unhold
    self.callbacks.unhold()
  File "/home/ben/miniconda3/envs/pvcaptest/lib/python3.11/site-packages/bokeh/document/callbacks.py", line 431, in unhold
    self.trigger_on_change(event)
  File "/home/ben/miniconda3/envs/pvcaptest/lib/python3.11/site-packages/bokeh/document/callbacks.py", line 408, in trigger_on_change
    invoke_with_curdoc(doc, event.callback_invoker)
  File "/home/ben/miniconda3/envs/pvcaptest/lib/python3.11/site-packages/bokeh/document/callbacks.py", line 443, in invoke_with_curdoc
    return f()
           ^^^
  File "/home/ben/miniconda3/envs/pvcaptest/lib/python3.11/site-packages/bokeh/util/callback_manager.py", line 185, in invoke
    callback(attr, old, new)
  File "/home/ben/miniconda3/envs/pvcaptest/lib/python3.11/site-packages/panel/reactive.py", line 469, in _comm_change
    state._handle_exception(e)
  File "/home/ben/miniconda3/envs/pvcaptest/lib/python3.11/site-packages/panel/io/state.py", line 436, in _handle_exception
    raise exception
  File "/home/ben/miniconda3/envs/pvcaptest/lib/python3.11/site-packages/panel/reactive.py", line 467, in _comm_change
    self._schedule_change(doc, comm)
  File "/home/ben/miniconda3/envs/pvcaptest/lib/python3.11/site-packages/panel/reactive.py", line 449, in _schedule_change
    self._change_event(doc)
  File "/home/ben/miniconda3/envs/pvcaptest/lib/python3.11/site-packages/panel/reactive.py", line 445, in _change_event
    self._process_events(events)
  File "/home/ben/miniconda3/envs/pvcaptest/lib/python3.11/site-packages/panel/reactive.py", line 384, in _process_events
    self.param.update(**self_events)
  File "/home/ben/miniconda3/envs/pvcaptest/lib/python3.11/site-packages/param/parameterized.py", line 1902, in update
    self_._batch_call_watchers()
  File "/home/ben/miniconda3/envs/pvcaptest/lib/python3.11/site-packages/param/parameterized.py", line 2063, in _batch_call_watchers
    self_._execute_watcher(watcher, events)
  File "/home/ben/miniconda3/envs/pvcaptest/lib/python3.11/site-packages/param/parameterized.py", line 2025, in _execute_watcher
    watcher.fn(*args, **kwargs)
  File "/home/ben/miniconda3/envs/pvcaptest/lib/python3.11/site-packages/panel/param.py", line 869, in _replace_pane
    self._update_inner(new_object)
  File "/home/ben/miniconda3/envs/pvcaptest/lib/python3.11/site-packages/panel/pane/base.py", line 704, in _update_inner
    new_pane, internal = self._update_from_object(
                         ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ben/miniconda3/envs/pvcaptest/lib/python3.11/site-packages/panel/pane/base.py", line 682, in _update_from_object
    old_object.object = object
    ^^^^^^^^^^^^^^^^^
  File "/home/ben/miniconda3/envs/pvcaptest/lib/python3.11/site-packages/param/parameterized.py", line 369, in _f
    return f(self, obj, val)
           ^^^^^^^^^^^^^^^^^
  File "/home/ben/miniconda3/envs/pvcaptest/lib/python3.11/site-packages/param/parameterized.py", line 1252, in __set__
    obj.param._call_watcher(watcher, event)
  File "/home/ben/miniconda3/envs/pvcaptest/lib/python3.11/site-packages/param/parameterized.py", line 2043, in _call_watcher
    self_._execute_watcher(watcher, (event,))
  File "/home/ben/miniconda3/envs/pvcaptest/lib/python3.11/site-packages/param/parameterized.py", line 2025, in _execute_watcher
    watcher.fn(*args, **kwargs)
  File "/home/ben/miniconda3/envs/pvcaptest/lib/python3.11/site-packages/panel/pane/base.py", line 324, in _update_pane
    self._update_object(ref, doc, root, parent, comm)
  File "/home/ben/miniconda3/envs/pvcaptest/lib/python3.11/site-packages/panel/pane/base.py", line 315, in _update_object
    state._views[ref][0]._preprocess(root)
  File "/home/ben/miniconda3/envs/pvcaptest/lib/python3.11/site-packages/panel/viewable.py", line 593, in _preprocess
    hook(self, root)
  File "/home/ben/miniconda3/envs/pvcaptest/lib/python3.11/site-packages/panel/pane/holoviews.py", line 862, in link_axes
    if axis.start > axis.end:
       ^^^^^^^^^^^^^^^^^^^^^
TypeError: The DType <class 'numpy.dtype[datetime64]'> could not be promoted by <class 'numpy.dtype[float64]'>. This means that no common DType exists for the given inputs. For example they cannot be stored in a single array unless the dtype is `object`. The full list of DTypes is: (<class 'numpy.dtype[datetime64]'>, <class 'numpy.dtype[float64]'>)

This seems like a panel bug

Traceback (most recent call last):
  File "/home/ben/miniconda3/envs/pvcaptest/lib/python3.11/site-packages/panel/viewable.py", line 591, in _preprocess
    hook(self, root, changed, old_models)
TypeError: link_axes() takes 2 positional arguments but 4 were given

I’d guess it’s causing this to yield some NaT datetime, which results in:

  File "/home/ben/miniconda3/envs/pvcaptest/lib/python3.11/site-packages/panel/pane/holoviews.py", line 862, in link_axes
    if axis.start > axis.end:
       ^^^^^^^^^^^^^^^^^^^^^

Can you file a bug report on Panel?

@ahuang11, yes, I’ll file a bug report. Any suggestions on how to isolate this bug in a minimal reproducible example?

1 Like

The way I create a minimum reproducible example from a larger complicated one is

  • Start with the large example. Make sure you can reproduce the issue.
  • git add . the code to stage it/ mark it as working.
  • Try removing a part that you don’t believe is causing the issue.
  • Test that you can still reproduce the issue
  • git add . the code to stage it/ mark it as working.
  • continue like this till you have a minimal, reproducible example.

In the end you might have to provide a function that generates a similar dataset via code or loads it from a csv file that can be shared.

Hi Marc,
Thanks for the suggestions! I’ll give that approach a try.
The most challenging thing for me with this bug has been figuring out how to reproduce it reliably. I have not been able to do that yet. If step down a level and plot the same data using the plotting functions the dashboard is using, I can’t reproduce the error. I’m thinking maybe looking for logs or errors in the browser developer tools might help. I may try that next.

1 Like

I opened issue 6642.

I tried for a while this morning to reproduce the error and was able to once, but not while running a screen capture.