Slow reactivity with more than 10 figures

Ehi,

I’m using Bokeh 2.4.2 and I noted that with more than 10 figures together, the reactivity of the elements is exponentially slower. In my case, I cannot use less figures together because they need to change dynamically when I move the sliders (there are 4) or I click a button.

Is it a common issue? Is there a way to optimise the reactivity?

I’m well aware that the powerful interactivity of the Bokeh module must have a price; my intent is to start a discussion that can lead to personal unknown ways to optimise the speed of the code.

Thank you all for the help and the beautiful module!

Things could be affected by the amount of data, or possibly the kind of data, or even potentially the layout. Unfortunately we cannot begin to speculate or diagnose what might be going on in your specific case without a complete Minimal Reproducible Example.

Thanks for the response.

Initially I didn’t think that the code was necessary because I thought that I located the problem (the amount of figures) but by trying to create a minimal reproducible example, I understood that the part of the layout that is slowing the reactivity is changing text of a Div. Sorry for this misinformation.

Searching for a solution, I found this thread; here’s they explain that the problem is due to a function called during div.text that refreshes the display and in the end of the thread, the code for implementing a Div widget without this part is presented.

I tryed implementing the new widget as explained in this Guide. To do so, I did the following steps:

  • create a folder called “custom” inside the bokeh folder in my local conda environment (the path should look like this) “path/to/local_3.8.10/lib/python3.8/site-packages/bokeh/custom”
  • create a file called “custom.ts” and copy-paste the code from the guide. First problem: in the first three lines where the code imports stuff, I don’t know the correct path.
    Here’s the lines:
import {HTMLBox, HTMLBoxView} from "models/layouts/html_box"

import {div} from "core/dom"
import * as p from "core/properties"
  • create a file called “custom.py” and copy-paste the code from the guide. In the first 2 lines, I changed the code from this:
from bokeh.core.properties import String, Instance
from bokeh.models import HTMLBox, Slider

To this:

from ..core.properties import String, Instance
from ..models import HTMLBox, Slider
  • create outside the local environment a simple python file called “test.py” with the code from the guide and run it

The error that I encounter is the following:

RuntimeError: node.js v14.0.0 or higher is needed to allow compilation of custom models ("conda install nodejs" or follow https://nodejs.org/en/download/)

But by running the prompt (I’m using Manjaro Ubuntu, linux):

 $ conda list nodejs
# packages in environment at /path/to/local_3.8.10:
#
# Name                    Version                   Build  Channel
nodejs                    6.11.2               h3db8ef7_0  

I tried different things but nothing’s working.

@DonCammne

This is a familiar problem when using Anaconda, and in prior releases attempting to update nodejs caused problems during the package conflict resolution step.

My workaround at the time was to create an environment explicitly specifying the nodejs version at creation time instead of my normal workflow of cloning the base environment and updating things as required.

Here’s an example of something that worked for me last year. You can change specific versions to be more recent, include additional packages such as numpy, pandas, etc. The key part here is to install nodejs that satisfies the custom-model requirement in the error message shown above and do so at environment create-time to workaround package resolution issues seen in Anaconda.

conda create --name dev python==3.9.4 nodejs>=14.0 bokeh==2.3.2 panel==0.11.3

conda activate dev
1 Like

Ehi _jm,

Thank you for the suggestion.

I’m using Miniconda and I tryed to create a new local venv with the nodejs>=14.0.0 installed from the beginning but conda stops me because there are a list of conflicts. Probably now conda checks conflicts in a different way during creation.

I don’t get if I’m doing something wrong or there is a problem somewhere because I’m unable to perform the simplest example from the guide that should work correctly.

I tried to install the nodejs package with a version greater than 14 but it seems not possible, the conflicts are too many.
Is it essential to have the nodejs>=14.0.0 or there an alternative?
Is it a common or a temporary problem?

Thank you for anyone how can help.