Hi, I am trying to write a dash app for a kind of simulation. I want to let the user set the specifications, then click the button to run the simulation in the background, then output the results. However, I can’t seem to find a way to update (run) the model only when all parameters are set, instead of starting the simulation every time a parameter changes (which is extremely time and resources consuming).
I have tried using dcc.store with two seperate callbacks for the setup and run, but it also updates both callbacks with every small change. Next idea was dash.no_update but I can’t figure out how to use it in this context.
Grateful for any help!
What about using a button click as the trigger to update? I think you will need to make the outputs for the various parameters to be state instead of output and i believe prevent_initial_callback = True
hi @matvei
No worries. What you need to do is figure out the key method that triggers the callback. You can set up a button dedicated to trigger your simulation with input
and reading those parameters from your tuning components with state
.
1 Like
Thank you!! if ctx.triggered[0]['prop_id'].split('.')[0] == 'h2_button': [simulate]
worked!