Hello,
I’m trying to build a dash app with machine learning models. To visually show that the model is being trained I just wanted to add a spinner while loading. So I coded the following callbacks. When we click on the Run button, I run loading_gru which chained update_graph. However once my model-forecast-gru is updated, the loading_gru function is not called when I put model-forecast-gru as input. I am still new to dash and I don’t understand why it is not working. If you have an explanation or an alternative, I am interested.
I believe you should have got a “circular callback” error, at least in debug=True mode… In a nutshell, you have an endless loop between the two callbacks, since the output in one triggers (via the input) the other and vice-versa.
The easiest approach is to use the spinner as a dcc.Loading component: just wrap the component with id “model-forecast-gru” (a chart, I guess…) in the dbc.Spinner, so it will show the spinner while the chart is updated via the callback that trains the model. Just note that there is a risk of timeout if the training takes longer than 30 seconds…