Black Lives Matter. Please consider donating to Black Girls Code today.

Running multiple callbacks

Hi all

So while I am running a dash application I click to run a Machine Learning algorithm, and as it may take longer to run, I would like to refresh plots and query other graphics.

The issue is that once the ML is running, if I trigger another callback the ML gets cancel, Is there any way to allow multiple callbacks to run independently within a dash application?

Correct me if i’m wrong, this is what i understood: in callback A you start training a model, then call a callback B that interrupts the training process of your model?

If that’s right, is one of those scenarios possible:

  1. You initialize your model at the beginning of the app, and use it inside your callback A and callback B.
  2. Some input for callback B is also used as an input A.

In the case of scenario (1), I’d recommend taking a look at this tutorial on sharing data between callbacks. If it’s (2), then perhaps you are re-calling callback A when you intended to call callback B. In this case, it might be a good idea to have separate callbacks.

Feel free to share a code snippet to give more detail about your scenario!