Recently have been using Panel from the Holoviz ecosystem to build a dashboard, and have been experiencing almost regular crashes from Bokeh’s end over the exact same error: AttributeError: 'Document' object has no attribute '_theme'
.
I wish I could say there was something specific I was doing during tests or usage to trigger this, but the truth is it occurs sporadically and very very unpredictably, crashing the entire server and requiring a restart. There is a common denominator, however, that the Attribute error happens when I change pages where each page represents a separate grouping of Bokeh plots. However, it’s like a coin flip because sometimes it works no problem.
I was wondering if anyone had come across such an error and how one could mitigate it, as there is no way I can deploy to production with the instability present now. Some details however, the error originates when attempting to “render” a Holoviews (import holoviews as hv
) chart into a Bokeh one using hv.render(plot_object)
.
This is the relevant execution chain and traceback that occurs during these errors (where I replace the base directory using ~
although the system is on Windows hence the backslashes):
File "~\holoviews\util\__init__.py", line 849, in render
return renderer_obj.get_plot_state(obj)
File "~\holoviews\plotting\renderer.py", line 275, in get_plot_state
obj = self_or_cls.get_plot(obj=obj, renderer=renderer, **kwargs)
File "~\holoviews\plotting\bokeh\renderer.py", line 74, in get_plot
plot.document.theme = self_or_cls.theme
File "~\bokeh\document\document.py", line 225, in theme
if self._theme is theme:
AttributeError: 'Document' object has no attribute '_theme'