This question is not about chained callbacks, but about somehow accessing the output from a previous execution of the same callback.
I am building a dashboard for our organization that fetches live data from a web API regularly using a dcc.Interval. Some of the metrics relevant to display are the mean, stdev, min, and max values for a handful of time series. These metrics will go into a go.Indicator, but I would like to also display the differences compared to the previously fetched data. In this way the users get an idea of how the data is changing in each update. I could simply double the amounts of API calls and get the previous data, but the API is a bit slow and it takes about 10 seconds to get the data once when done in an async way. We want the dashboard to update as often as possible, and I feel like there should be a way to reuse the already fetched data.
I have attempted several solutions:
-
Write the data to file and load this later to compute the deltas. This does indeed work, but fails when the app is deployed to a kubernetes cluster with replicated pods. Each pod tries to access the same file, which messes up the app. I am sure this can be solved on the architecture side, but I am not so experiences with kubernetes deployment.
-
I tried to chain two
dcc.Storecomponents together, where the first fetches the data and feeds it to theInputof another callback which feeds the data into the seconddcc.Store. But this, perhaps obviously, just leaves me with two separatedcc.Stores with the same set of data, since the callbacks don’t follow the “normal” procedural execution of the code. I placed the second callback (the one which stores the data in the seconddcc.Storeafter the I displayed the figures with the data from the firstdcc.Store, hoping that this would force the seconddcc.Storeto store the “previous” data at the next iteration of the callbacks.
Is there a simple way to compare the outputs from successive callbacks?
All help much appreciated!