I started using bokeh few weeks ago, it’s great! I like the idea of not dealing with JS for plotting, but it feels a bit like I’m breaking something.
I understand that this maybe is not a designed use case for bokeh and I’m wiling to put some effort (and contribute some code) to make it work.
This is scenario from user’s point of view:
Given there is a form with some input fields
And form is partially generated based on data from a REST endpoint
And there is a submit button
When user clicks on submit button
Then new job gets started on server side
and results are streamed into bokeh data source
and results are streamed through websocket
and presented to user.
Here are some approaches I tried by now:
I considered using bokeh server for serving whole application but I need some REST-like endpoints for building web frontend elements in mentioned form. I didn’t find any nice way for adding new endpoints to bokeh application so I abandoned this approach.
I also considered approach where I use flask for servirng REST content and extending bokeh server (well, subclassing it and using it from flask), but I find this approach too cumbersome and too complicated for maintenance.
Finally, I settled down with using combination of both flask and bokeh serve on backend side.
I see two ways of embedding plots on client side:
using components() from bokeh.embed:
Using components() resulted with nicely embeded plots but it wasn’t interactive (there was no communication through websocket).
I managed to run it, but now CSS seems to be broken (toolbar icons are huge, not styled and in the wrong place). Also, websocket connection seems to be opened but I don’t see any plots.
I have to mention that backend side is probably fine because I can serve it with bokeh serve. It streams and plots new data as expected.
So, my questions are:
What’s recommended approach for embeding plots into single page application, like Angular based application?
Is it expected that streaming doesn’t work when I embed tags generated with components() function?
Any suggestions how to make this whole thing less hacky? What about merging backend into one process? I don’t like idea of running both flask and bokeh serve, but I can live with that.
Feel free to ask me to provide relevant parts of code. I wasn’t sure what could be of help.
Thank you in advance!
Atlantic777 (Nikola Hardi)