I’m using dash 2.0. ( with bootstrap 1.1.0 ) and have an app deployed with WGSI atop Nginx.
The app runs a simulation and plots the results.
There are callbacks which set and select (sliders, inputs, dropdowns) different parameters, triggering the simulation, as well as other callbacks which simply plot a line or change the plotted domain displayed without rerunning the simulation.
The app tests as well as it should within a local testing environment but when deployed in production, triggering any callback will randomly show some previously displayed plot. It happens with maybe 30% of the callbacks, and is independent of the simulation; e.g. changing the plotted domain will show a plot from a different (but previously called) set of input parameters.
These are specifically previously shown plots; it does not show random garbage. This makes me think there is something with the caching, and maybe this is handled differently in a prod environment.
How can i suppress this behaviour, or get it to work as expected?
Firstly, it was resolved by moving the object out of the callback. Thanks for the reminder! ^^
The simulations aren’t so large to cause a major bottleneck when updating the plots with non-simulation related actions,
so it seems okay to just rerun them even if it is redundant.
Re your latter comment, I effectively want to update (and store) some data object with the user- and model-parameters and simulation data; the data is plotted and presented as a table, and should be otherwise downloadable; moreover i want this to be unique and separate to a given session, ie user.
Can I achieve this by following Ex. 4 on Part 5. Sharing Data Between Callbacks?
I haven’t seen the code, but it sounds like you might still be using global variables (as a side note that is OK, if the variables are read-only). As you have experienced, it works sometimes (in your case locally, but not in production). Note that while it might seem to work now, you app might still break if/when you change deployment settings (this comment is obviously only relevant, if you are indeed using global variables).
Yes, that would be the general approach. You could also use a ServersideOutput (from dash-extensions) if you like the dash-component syntax better.