Coder Social home page Coder Social logo

Comments (6)

wellecks avatar wellecks commented on June 3, 2024

Working on this

from declarativewidgets.

wellecks avatar wellecks commented on June 3, 2024

As a first step, I'm working on a basic examples notebook, with an example analogous to this ipywidgets example

Bokeh contains a push_notebook() function that allows a plot's data to be updated from code run in the notebook. The function sends a display_data message that causes the update to happen.

The function is running successfully with urth-core-function and sending the message, but it's not updating the plot. Currently investigating why the update works for ipywidgets interact, but not urth-core-function

from declarativewidgets.

wellecks avatar wellecks commented on June 3, 2024

The cause is that there is no iopub.output callback associated with the comm_msgs that our widgets send. Usually (e.g. with ipywidgets, or normal code execution), the iopub.output callback will inject the display_data message contents into a code cell.

Bokeh's push_notebook() works by sending javascript in the display_data message that updates the plot. Since our widgets don't inject display_data message contents due to lack of the iopub.output callback, the javascript isn't running.

Ipywidgets adds this callback through their View system. Each widget is associated with a client-side View, which has a handle to a cell through view.options.cell. The widget manager then constructs an iopub.output callback associated with that cell (see WidgetManager.prototype.callbacks).

However, our widgets don't use Views. As a potential workaround, we can construct the iopub.output callback using the currently selected code cell. In the case of Bokeh, it doesn't matter which output cell the display_data contents is injected to since it's just javascript that needs a place to execute. In other cases (although we haven't run into these yet), display_data contents will be injected to the currently selected cell.

tl;dr: our widgets don't have a certain callback since we don't use Views, but looks like there may be a workaround

from declarativewidgets.

wellecks avatar wellecks commented on June 3, 2024

I was able to get the plot contents to display and update using urth-core-function. I put together a notebook with two simple examples showing how Bokeh and declarative widgets can be integrated. Next, I want to put together a more complex example; the first step will be choosing the theme / data to work with.

from declarativewidgets.

wellecks avatar wellecks commented on June 3, 2024

It turns out there is an issue with the plot updating when more than one urth widget is declared in a single cell, so I'm looking into that now.

from declarativewidgets.

wellecks avatar wellecks commented on June 3, 2024

The issue was a race condition that occurred when setting the code cell.

We can use the parent header of the execute_input to determine which cell is currently executing, and associate that cell with all of the created widgets, until a new execute_input arrives. I added a new behavior to listen for execute_input, and the current solution is to use a global lastExecutionId to track the currently executing cell. See this branch for the implementation

So far, this successfully supports multiple widgets and Run All

from declarativewidgets.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.