# Function that grabs latest data from FTP server
df = ftpfile.grabDF()
# Set app.layout as a function (Part 1): Advised in Live Updates link
def serve_layout():
return html.Div(.......)
# Reassigning dataframe to a new variable in callback : Advised in Sharing Data between Callbacks link
@app.callback(
[Output("pie", "figure"), Output("bar", "figure")],
[Input("checkbox1", "value"), Input("bu-checkbox2", "value")],)
def update_output_div(valueA, valueB):
dff = df[:]
#Set app.layout as a function (Part 2): Advised in Live Updates link
app.layout = serve_layout
But the above doesn’t work as intended, the df is not obtained from the data source upon page refresh.
Ah, I’ve seen that response of yours from another thread ( did do my homework)
Is repeatedly querying the source for every callback the way to go? Or can we query once per page refresh, and work with that extract until next visit / refresh. Would that be under sharing data between callbacks?
You can do both. If you want to save the data for some time before querying the again, you would need to do some kind of caching, either client side using Dash components (e.g Store) or server side. For the latter, you could try out a decorator I recently wrote,