Announcing Dash Bio 1.0.0 🎉 : a one-stop-shop for bioinformatics and drug development visualizations.

Try creating a spinner

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.

Thank you for your attention and the time taken to read this message. Thank you for your attention and the time taken to read this message.

Hi,

Welcome to the community!

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…

Some links:

1 Like

Thank you for this quick response.
I was not aware of this circular callback problem.
I just tried dcc.loading and it fits my need perfectly.

Thank you for this help, you have helped me a lot

1 Like