question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[FEATURE] Add a `PythonCallback` similar to `CustomJS`

See original GitHub issue

Add a new model to allow a python-side callback that’s called from the browser. If this is possible, I didn’t find any way to do that in the docs. Note that this can also simplify the event-mechanism as there will not be longer be a need for both on_event and js_on_event.

Looking briefly on the code, I have an implementation suggestion (tell me what you think about it): In the python side, it just wraps a callback. On the browser side, this could be implemented by triggering a new type of event on calling CallbackLike<..>.execute, which, in turn, triggers a wrapper in the python-side that calls the given callback.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
bryevdvcommented, Oct 13, 2020
  • It’s more complicated, not less. You can just currently define a function and pass to on_event with no imports. To use some PythonCallback you have to: import it (know to import it), define a function and configure it, or subclass is and define a method, then configure that result on the model. That is strictly always more work, not less (and more and more ways to have to document)

  • This could only work with a Bokeh server because the Bokeh server is the Python process that will execute python code. (I hope that is understood here but I am not sure). It cannot work at all with standalone output (i.e. output_file + show) but it seems like it would be very easy for users to be confused on this point, which directly translates into an inctreased support burden.

Also, all the tools that have a callback property (there are quite a few),

There are only three left. CustomAction, TapTool, and HoverTool It used to be the case there there were lots but the plan (which has been ongoing) is to get rid of all of the old ad-hoc callback properties and have only the one consistent on_event / js_on_event mechanism everywhere. These will all be deprecated some day.

This is duplicative of existing functionality but will require more work to develop, maintain, document, and explain. We should continue the work to unify everything event-related under common on_event / js_on_event which is easier to explain via parallel comparison. If we need new events, we can add them. But I am a strong -1 on a differentPythonCallback that needs to be maintained (and explained) differently. .

0reactions
bryevdvcommented, Oct 16, 2020

FYI I will go ahead and close this with noaction if others feel strongly please make a case to re-open

Read more comments on GitHub >

github_iconTop Results From Across the Web

JavaScript callbacks — Bokeh 2.4.3 Documentation
Any Bokeh models that are configured in args (on the “Python side”) will ... These CustomJS callbacks can be attached to property change...
Read more >
Bokeh: CustomJS and Callbacks - YouTube
In order for a widget to be useful, it needs to be able to perform some action. Using the Bokeh server, it is...
Read more >
Bokeh widgets call CustomJS and Python callback for single ...
With certain events, I'd like to execute some JavaScript code before making the callback to the Python function. Is this possible? In this...
Read more >
Lesson 30: JavaScript for stand-alone Bokeh apps
The callbacks, which are functions that get executed to update information about the plot based on changes in the widgets (such as computing...
Read more >
Panel - JSCallback function - HoloViz Discourse
There is no easy way to call a jscallback from python, I think, but I am not sure. stackoverflow.com · austintpg. Bokeh callbacks...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found