Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bokeh server support #959

Merged
merged 30 commits into from
Apr 7, 2017
Merged
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
ab26f51
Added BokehRenderer server mode
philippjfr Oct 31, 2016
c1e2550
Added initial bokeh server stream callback handling
philippjfr Oct 31, 2016
afec80f
Small fixes for bokeh server implementation
philippjfr Oct 31, 2016
312975e
Added initial BokehServerWidgets implementation
philippjfr Oct 31, 2016
6f420b3
Fixes for BokehServerWidgets
philippjfr Oct 31, 2016
3b5d10c
Ensure all subplots have the same plotting classes
philippjfr Nov 4, 2016
c7cedc2
Defined bokeh widget parameters
philippjfr Nov 4, 2016
3b43aab
Added bokeh app examples
philippjfr Feb 3, 2017
7697a2a
Small fix for bokeh widget import
philippjfr Mar 26, 2017
27ee566
Improved handling of boomeranging events in bokeh backend
philippjfr Mar 26, 2017
78a2c2a
Improved bokeh server event queue
philippjfr Mar 26, 2017
c32e2ab
Improved range updates for bokeh server
philippjfr Mar 26, 2017
3f0dca8
Fixed small bugs in bokeh Callbacks
philippjfr Mar 26, 2017
9bf0982
Fixed bokeh event callbacks after change to cb_obj
philippjfr Apr 6, 2017
b099b7e
Implemented UIEvent handling for bokeh server
philippjfr Apr 6, 2017
dbef691
Moved bokeh server example apps
philippjfr Apr 6, 2017
2e9ca71
Completely refactored bokeh Callbacks
philippjfr Apr 6, 2017
d7f5e45
Made callback utilities into classmethods
philippjfr Apr 6, 2017
6ab8861
Minor cleanup on bokeh Callbacks
philippjfr Apr 6, 2017
82074b8
Added tests for bokeh Callbacks
philippjfr Apr 6, 2017
a8a10a5
Small fix for bokeh ServerCallback on_change events
philippjfr Apr 6, 2017
3342b0a
Allow supplying Document to BokehRenderer
philippjfr Apr 6, 2017
c65dcbb
Simplified bokeh Callback initialization
philippjfr Apr 6, 2017
a2fcb0c
Moved bokeh server widget handling onto BokehRenderer
philippjfr Apr 6, 2017
b0e1f52
Factored out class method to create bokeh widgets
philippjfr Apr 6, 2017
d9fe1b7
Small fixes and improvements for bokeh widgets
philippjfr Apr 6, 2017
f0c31c6
Added tests for BokehServerWidgets
philippjfr Apr 6, 2017
171e9ca
Fixed unreferenced variable bugs
philippjfr Apr 6, 2017
4e8073a
Various python3 fixes
philippjfr Apr 7, 2017
957b96b
Improved docstrings for bokeh server features
philippjfr Apr 7, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Improved bokeh server event queue
philippjfr committed Apr 6, 2017
commit 78a2c2a4bb27c3f9b5e73f8db29751a936b1e615
3 changes: 2 additions & 1 deletion holoviews/plotting/bokeh/callbacks.py
Original file line number Diff line number Diff line change
@@ -366,6 +366,7 @@ def trigger(self):
"""
if not self._event_queue:
return
self._event_queue = []
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably worth just calling it queue as the word event is now confusing...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed. There is an _event_queue in the widget class though...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed.


values = {}
for attr, path in self.attributes.items():
@@ -385,7 +386,7 @@ def trigger(self):
attr_val = getattr(attr_val, p, None)
values[attr] = {'id': obj.ref['id'], 'value': attr_val}
self.on_msg(values)
self._event_queue = []
self.plot.document.add_timeout_callback(self.trigger, 50)


def set_onchange(self, handle):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name is misleading now, should be something like set_bokeh_callback

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed - now called set_server_callback.

17 changes: 14 additions & 3 deletions holoviews/plotting/bokeh/widgets.py
Original file line number Diff line number Diff line change
@@ -61,6 +61,7 @@ def __init__(self, plot, renderer=None, **params):
if self.plot.renderer.mode == 'default':
self.attach_callbacks()
self.state = self.init_layout()
self._event_queue = []
Copy link
Contributor

@jlstevens jlstevens Apr 7, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would still rename this from _event_queue to just queue.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, this is for the widgets now.. so it might be ok.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although maybe better for consistency? I'll rename.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is in widgets now so my original comment was addressed. Might be worth renaming here too - up to you.



def get_widgets(self):
@@ -106,8 +107,8 @@ def get_widgets(self):
options=list(zip(values, labels)))
lookup = zip(values, labels)
if label:
label.on_change('value', partial(self.update, dim.pprint_label, 'label'))
widget.on_change('value', partial(self.update, dim.pprint_label, 'widget'))
label.on_change('value', partial(self.on_change, dim.pprint_label, 'label'))
widget.on_change('value', partial(self.on_change, dim.pprint_label, 'widget'))
widgets[dim.pprint_label] = (label, widget)
if lookup:
lookups[dim.pprint_label] = OrderedDict(lookup)
@@ -134,10 +135,20 @@ def attach_callbacks(self):
pass


def update(self, dim, widget_type, attr, old, new):
def on_change(self, dim, widget_type, attr, old, new):
self._event_queue.append((dim, widget_type, attr, old, new))
if self.update not in self.plot.document._session_callbacks:
self.plot.document.add_timeout_callback(self.update, 50)


def update(self):
"""
Handle update events on bokeh server.
"""
if not self._event_queue:
return
dim, widget_type, attr, old, new = self._event_queue[-1]

label, widget = self.widgets[dim]
if widget_type == 'label':
if isinstance(label, AutocompleteInput):