Advanced (?) bokeh server example

Hello!

I’m trying to build a dashboard to allow a user to specify a list of devices and a type of report and hit a “generate” button that would then pull data from a server and present multiple plots.

I’ve used http://stackoverflow.com/questions/38548442/dynamically-add-remove-plot-using-bokeh-serve-bokeh-0-12-0 as a basis for my work, except instead of a toggle I have a periodic callback running every 5s to check the state of the document - i.e. has a plot been requested and if so has a plot been rendered and if not, grab the data and render it.

After a user entered a device ID and a date, I have the user hit a generate button which sets a flag to true and then in the periodic callback it will check to see if the flag is true and then call a function to pull the data from a remote server and pushes it into a ColumnDataSource, and then generate the plot and add it to the children as per the link above.

However, sometimes if I have multiple device’s plots being generated at the same time then it can take > 5s for the server/data processing to finish and at that point I believe the client and server get out of sync with errors like

2017-03-26 10:24:54,551 error handling message Message ‘PATCH-DOC’ (revision 1): RuntimeError(‘Cannot apply patch to c533e616-0a6d-4b04-9eec-7a3b106f29ba which is not in the document’,)

2017-03-26 10:24:54,661 error handling message Message ‘PATCH-DOC’ (revision 1): DeserializationError(“Instance(Plot) failed to deserialize reference to {u’subtype’: u’Figure’, u’type’: u’Plot’, u’id’: u’03397330-615c-40a3-ad13-3ffacf4d4125’}”,)

I’ve tried following http://bokeh.pydata.org/en/latest/docs/user_guide/server.html#updating-from-threads but I’m new to server/client architectures.

I’m thinking clicking the “generate” button should launch a new thread that would pull the data from the server and append it to the CDS, and then at the end of the new thread add a tick callback to add the graph? Note that the data is around 20-30k points potentially with a max around 86k (1 point per second for a 24 hour period).

Thank you in advance. Bokeh rocks!

Hmm, trying the above generate launches a thread change I still get the same behaviour as I have multiple threads calling add_next_tick_callbacks. I suppose I need to mutex that call?

Sidebar: a lot of examples I see do not call remove_next_tick_callback, from reading the documentation it’s not clear if this is required or not.

···

On Sunday, 26 March 2017 17:51:32 UTC-4, Christopher Olekas wrote:

Hello!

I’m trying to build a dashboard to allow a user to specify a list of devices and a type of report and hit a “generate” button that would then pull data from a server and present multiple plots.

I’ve used http://stackoverflow.com/questions/38548442/dynamically-add-remove-plot-using-bokeh-serve-bokeh-0-12-0 as a basis for my work, except instead of a toggle I have a periodic callback running every 5s to check the state of the document - i.e. has a plot been requested and if so has a plot been rendered and if not, grab the data and render it.

After a user entered a device ID and a date, I have the user hit a generate button which sets a flag to true and then in the periodic callback it will check to see if the flag is true and then call a function to pull the data from a remote server and pushes it into a ColumnDataSource, and then generate the plot and add it to the children as per the link above.

However, sometimes if I have multiple device’s plots being generated at the same time then it can take > 5s for the server/data processing to finish and at that point I believe the client and server get out of sync with errors like

2017-03-26 10:24:54,551 error handling message Message ‘PATCH-DOC’ (revision 1): RuntimeError(‘Cannot apply patch to c533e616-0a6d-4b04-9eec-7a3b106f29ba which is not in the document’,)

2017-03-26 10:24:54,661 error handling message Message ‘PATCH-DOC’ (revision 1): DeserializationError(“Instance(Plot) failed to deserialize reference to {u’subtype’: u’Figure’, u’type’: u’Plot’, u’id’: u’03397330-615c-40a3-ad13-3ffacf4d4125’}”,)

I’ve tried following http://bokeh.pydata.org/en/latest/docs/user_guide/server.html#updating-from-threads but I’m new to server/client architectures.

I’m thinking clicking the “generate” button should launch a new thread that would pull the data from the server and append it to the CDS, and then at the end of the new thread add a tick callback to add the graph? Note that the data is around 20-30k points potentially with a max around 86k (1 point per second for a 24 hour period).

Thank you in advance. Bokeh rocks!

Updating to 12.4 with mutexing the add_next_tick_callback appears to work.

···

On Monday, 27 March 2017 10:51:57 UTC-4, Christopher Olekas wrote:

Hmm, trying the above generate launches a thread change I still get the same behaviour as I have multiple threads calling add_next_tick_callbacks. I suppose I need to mutex that call?

Sidebar: a lot of examples I see do not call remove_next_tick_callback, from reading the documentation it’s not clear if this is required or not.

On Sunday, 26 March 2017 17:51:32 UTC-4, Christopher Olekas wrote:

Hello!

I’m trying to build a dashboard to allow a user to specify a list of devices and a type of report and hit a “generate” button that would then pull data from a server and present multiple plots.

I’ve used http://stackoverflow.com/questions/38548442/dynamically-add-remove-plot-using-bokeh-serve-bokeh-0-12-0 as a basis for my work, except instead of a toggle I have a periodic callback running every 5s to check the state of the document - i.e. has a plot been requested and if so has a plot been rendered and if not, grab the data and render it.

After a user entered a device ID and a date, I have the user hit a generate button which sets a flag to true and then in the periodic callback it will check to see if the flag is true and then call a function to pull the data from a remote server and pushes it into a ColumnDataSource, and then generate the plot and add it to the children as per the link above.

However, sometimes if I have multiple device’s plots being generated at the same time then it can take > 5s for the server/data processing to finish and at that point I believe the client and server get out of sync with errors like

2017-03-26 10:24:54,551 error handling message Message ‘PATCH-DOC’ (revision 1): RuntimeError(‘Cannot apply patch to c533e616-0a6d-4b04-9eec-7a3b106f29ba which is not in the document’,)

2017-03-26 10:24:54,661 error handling message Message ‘PATCH-DOC’ (revision 1): DeserializationError(“Instance(Plot) failed to deserialize reference to {u’subtype’: u’Figure’, u’type’: u’Plot’, u’id’: u’03397330-615c-40a3-ad13-3ffacf4d4125’}”,)

I’ve tried following http://bokeh.pydata.org/en/latest/docs/user_guide/server.html#updating-from-threads but I’m new to server/client architectures.

I’m thinking clicking the “generate” button should launch a new thread that would pull the data from the server and append it to the CDS, and then at the end of the new thread add a tick callback to add the graph? Note that the data is around 20-30k points potentially with a max around 86k (1 point per second for a 24 hour period).

Thank you in advance. Bokeh rocks!