Embedding individual models of a server_session

What am I trying to do?

I am running a Bokeh server and embedding it currently with server_document() in a flask environment of an external webpage. My Bokeh document contains two parts, let’s say a slider and a figure; I gave both a name and added them to the bokeh document with add_root().

Now I would like to put each of these roots into a separate div when embedding, to allow the use of flexboxes to achieve a responsive design. Previously, I used Column() or Row() of Bokeh Layout, but Column() looks bad on a landscape screen and Row() looks bad on a mobile device.

What have I tried that did not work as expected?

In the reference documentation (section bokeh.embed) I found that if I use server_session() over server_document(), I can pass a model name to get individual document roots instead of the entire document. However, this does not work. I found this open github issue (Bring back the functionality needed to embed separate Bokeh roots within React · Issue #8499 · bokeh/bokeh · GitHub) that seems to be related but hasn’t seen any activity besides “is there a fix?” for about a year. After looking a bit into the source code (I am no expert by any means), it seems like the problem is the autoload_request_tag.html (bokeh.core.templates — Bokeh 2.4.2 Documentation), which does not make use of the modelid that it receives.

Is there any update on this or a suggestion to achieve my goal in another way? I am restricted to using Bokeh Server (I need Python callbacks), so embedding with components() is not an option; and because I don’t want Bokeh to serve all the content, I believe also the default Jinja2/directory template method does not work for me. I also cannot use multiple documents, because I want the two models to interact with each other, just like the Bokeh sliders example. I appreciate any advice!

@jonas I am afraid this specific scenario is not well-explored, and I can’t actually give you a definite answer beyond noting that this capability is not currently officially maintained under test or in any examples. It’s definitely possible to embed individual document roots in different places in a template when the Bokeh server is serving the page directly (as demonstrated in /examples/app/dash) but I think that server_session may need development work to support this use-case. I have put #8499 in the 2.4 milestone so that it will get some attention after the upcoming 2.3 release.

Thank you very much for the reply and for moving the issue to 2.4! Based on the number of forum/github/stackexchange posts and replies mentioning similar setups/desires I believe quite a number of people are looking forward to that feature. As a temporary solution I serve the specific page containing the bokeh plot entirely with bokeh server, just like in the referenced dash example.