Hello.
I am confused by this error message. I have watched the Sharing Information Between Callbacks many times. and I thought I followed the directions to the letter. I am especially confused by this particular error message because the dcc.Store component is supposed to accept lists as valid data, according to the documentation cited below.
I printed out the data and it is a list of dictionaries.
Can anyone explain what is wrong and what to do about it?
Thank you,
Robert
1. Documentation:
data
( dict | list | number | string | boolean ; optional): The stored data for the id.
2. dcc.Store component
dcc.Store(id=‘store-data’, data= , storage_type=‘memory’, clear_data=False)
The idea here was to contain the data in the data_key and and clear it after every session by changing the clear_data value to True when the session ends, triggered by the production of the final report.
3. Here is the callback:
The user approves a datatable of information - an intermediary step that allows the user to edit and approve the data to be analyzed, after the initial processing, but before the final analysis. The approved data is then stored in dcc.Store.
If I comment out the callback, the rest of the code functions fine.
@callback(
Output('store-data', 'data'),
Input('nutrients-review-datatable-submit-button', 'n_clicks'),
prevent_initial_call=True
)
def store_approved_data(n_clicks):
if n_clicks > 0:
with open("./json/edited_recipe_data.json", "r") as data_store:
data = json.loads(data_store.read())
return data.to_dict('records')
4. Here is the error message:
I printed out the data and it is one list of dictionaries. I have also - out of desperation - tried to use a for loop to return each dictionary inside the list, which did not work. No big surprise there.