Quantcast
Channel: 🎛️ Dash - Plotly Community Forum
Viewing all articles
Browse latest Browse all 6271

Would changing the value of the dcc.Store component's clear_data

$
0
0

This one was not addressed in the Sharing Data Between Callbacks video - a minor oversight in a great video,

And it is defined, but not discussed, in the documentation:

clear_data ( boolean ; default False ): Set to True to remove the data contained in data_key .

But it has become important to my attempts to resolve a major issue, notably that the previous session’s data remains cached somewhere in my browser or app, making it impossible to analyze new data.

I spent hours experimenting with gc.collect, clearing lists, deleting variables, closing files, etc…and now I am trying to clear this data by using dcc.Store to contain it and then change the clear_value parameter to True when the Reset button is clicked. The code below - my latest attempt - is not successful.

May I ask, what is wrong with it? Or is my approach misguided here?

Do you know of a solution to this kind of problem?

Here is the code for dcc.Store at the tail end of an Accordion component:

 dcc.Store(id='store-data', data=[], storage_type='memory', clear_data=False) # 'local' or 'session'
]) # Later use callback to chang clear_data to True when final analysis is completed.

Here is the callback in question:

@callback(
    Output('store-data', 'clear_data'),
    [Input("recipe-textarea-reset-button", "n_clicks")],
    prevent_initial_call=True
)
def clear_memory(n_clicks):
    if n_clicks > 0:
        return True

Thank you,

Robert

4 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 6271

Trending Articles