Open tchamberlin opened 1 year ago
Note: I can't get this notebook to work https://datashader.org/getting_started/Interactivity.html#holoviews-datashader-bokeh
Not sure what's going on -- perhaps mismatched package versions on my end. But also possible that the example is out of date
Hm the notebook works for me, but I'm still trying to figure out how to have a live Python process running for the interactive updating. I've been looking into Bokeh servers and possibly embedding one into the Django template, for example by using bokeh.client.pull_session
and saving the session script as a context variable (https://holoviews.org/user_guide/Deploying_Bokeh_Apps.html). Though I keep getting errors on IOLoops that I haven't been able to fix yet
I think that's the correct approach. Django and Flask are pretty much the same for the purposes of that example
The IOLoop issue last week was solved by starting the Bokeh server in a separate script, outside of Django.
I ran into another issue earlier this week with Django appending the current session page URL to the CSS resource URLs generated from pull_session
, which caused 404 errors. I tested embedding one of the Bokeh server examples (https://github.com/bokeh/bokeh/blob/3.2.0/examples/server/api/standalone_embed.py), which uses Bokeh's Server()
constructor and Application
s instead of panel.serve()
, and it worked on the session page
I'll be working on trying to put dynamic plots into a pure Bokeh application/server
I now have a Bokeh server embedded in the session detail view, but the session is currently hardcoded. I spent time yesterday reading through Bokeh server documentation, and I'm trying to implement a full server that can process queries with handlers. There don't seem to be concrete examples to work off of, so I'll try to build it up gradually
After several attempts, I was able to start a server using Bokeh's Server
constructor instead of renderer.server_doc
, and I roughly followed an example (https://holoviews.org/reference/apps/bokeh/player.html) to add the Holoviews plot to the Bokeh document. I also used a FunctionHandler
(https://docs.bokeh.org/en/latest/docs/reference/application/handlers/function.html) to create the application and modify the document.
It seems to work when I access the server from a new browser window, but getting the server document through Django caused weird errors that I haven't been able to figure out yet. I'll work on trying to understand/fix them, and if nothing else works, I might try upgrading bokeh to see what changes
I found that I can pass arguments to Bokeh while still using renderer.server_doc
to start the Bokeh server instead of the Server
constructor, so I no longer need to deal with the weird errors from before. In alda's views.py
, I get the Bokeh plot using script = server_document(url=<url>, arguments={"session":session})
).
Instead of the static datashader bitmap, the Session List View (
/disk/sessions
) should display an interactive plot, via Holoviews/bokeh/datashader.This will be a good starting point: https://datashader.org/getting_started/Interactivity.html#holoviews-datashader-bokeh
Here's a working example of the basic behavior that we are looking for: https://nyc-taxi.pyviz.demo.anaconda.com/dashboard