Updating ranges in a bokeh application


I have been building an application to analyze America’s Cup races with bokeh. My data is organized into dataframes. I have a large multi index dataframe that I read from hdf5 which has information about all of the boats in a race. I select a boat specific dataframe out and then there are subsections of that dataframe (related to when a boat tacks) that I want to display with the app. My app has two widgets, a drop down to chose the boat, and a slider to select the time subsection of the race data to view. I had a previous version that worked where I would create a separate subsectioin dataframe and plot that. I want the app to work by manipulating the x_range. This way I will only have to update the ColumnDataSource for the whole app when I select a different boat. This should make the app significantly faster.

As a more general question, how should more complex apps be designed? The Bokeh and IPYwidgets model are fairly straight forward when you recompute all of your results as a function of all the inputs. They become much more complex to manage when you want to do partial re computation. I run into fragile and complex order of instantiation issues. What are best practices?

How do I update selections programmatically from python in a bokeh app?

Here is the current version where I try to update the x_range

Here is the previous version where I created separate dataframes: