I’m wondering the best practice for exporting figures from a bokeh server app webpage to a separate static html document. In particular, I’m wondering how to avoid this error:
RuntimeError(“Sub-model (id=’…’, …) of the root model Column(id=‘layout’, …) is already owned by another document (Models must be owned by only a single document). This may indicate a usage error.”,)
To be more specific, my bokeh server app has a widget button which, when pressed, triggers the displayed figures on the app’s webpage to be downloaded to a separate html document. I believe the line in my code that trips this error is:
html = be.file_html(layout, resources=br.CDN, template=template)
where be is bokeh.embed, br is bokeh.resources, and layout is a bokeh.layouts.column containing a list of bokeh.plotting.figure.
Based on the error, it seems the figures cannot be associated with both curdoc() and this new bokeh.embed document. But is there any other way to do this?
On a related note, I’m also wondering if it’s possible to export these figures to the separate html document as pngs, rather than bokeh models. In other words, is there a way in code to create/access pngs of models, similar to the pngs that are downloaded with the save tool?