Need advice: updating a widget after initial load of Bokeh app using asynchronous methods.

I have created a Bokeh app and have it hosted using Heroku. The app is viewable here:
https://btac-web-plots.herokuapp.com/avyview

You’ll notice the load-time is fairly slow – this is the problem I am trying to solve.

One potential problem is that I am creating an individual columndatasource for each panel in the plot. I then update each columndatasource when a button widget is changed. Having a single large columndatasource and only creating it once may be faster…

However, another potential solution is this:

I currently have the “Jump to Year” drop-down menu widget set to only go back to 2010. My actual dataset goes back to 1974. I have reduced the years to improve the load speed… if I reduce the data to only one year (i.e. 2016 only), the load speed is reduced to ~3 seconds, which is tolerable.

My question is this:

What methods do I have available to complete an initial load of the Bokeh app with only the current single year loaded, and then load up data for the rest of the years back to 1974 as a secondary process while the user is viewing the initial page? Ideally, the app would update in the background after the initial load, adding years to the dropdown menu.

I have been reading about Lifecycle Hooks. I do have my application running in directory format, but I am unsure if these are really the methods I need, or how to proceed.

Any advice would be much appreciated!

I am programming exclusively in Python, using Pandas for my initial data read, defining variables, and creating a dataframe.

–Patrick

Hi, having been trying to solve a similar situation myself recently, I think the most relevant section in the docs is: http://bokeh.pydata.org/en/latest/docs/user_guide/server.html#updating-from-unlocked-callbacks. The example given there adds a periodic callback, but you can replace that with an unlocked add_next_tick_callback which runs your second data load (on a separate thread). After the data is loaded, you can then lock the document and update your ColumnDataSources, again with add_next_tick_callback.

Best, Andy

···

On Thursday, February 2, 2017 at 12:15:10 PM UTC-5, Patrick Wright wrote:

I have created a Bokeh app and have it hosted using Heroku. The app is viewable here:
https://btac-web-plots.herokuapp.com/avyview

You’ll notice the load-time is fairly slow – this is the problem I am trying to solve.

One potential problem is that I am creating an individual columndatasource for each panel in the plot. I then update each columndatasource when a button widget is changed. Having a single large columndatasource and only creating it once may be faster…

However, another potential solution is this:

I currently have the “Jump to Year” drop-down menu widget set to only go back to 2010. My actual dataset goes back to 1974. I have reduced the years to improve the load speed… if I reduce the data to only one year (i.e. 2016 only), the load speed is reduced to ~3 seconds, which is tolerable.

My question is this:

What methods do I have available to complete an initial load of the Bokeh app with only the current single year loaded, and then load up data for the rest of the years back to 1974 as a secondary process while the user is viewing the initial page? Ideally, the app would update in the background after the initial load, adding years to the dropdown menu.

I have been reading about Lifecycle Hooks. I do have my application running in directory format, but I am unsure if these are really the methods I need, or how to proceed.

Any advice would be much appreciated!

I am programming exclusively in Python, using Pandas for my initial data read, defining variables, and creating a dataframe.

–Patrick