I am creating a website with multiple different layouts. I have created a dcc.store component in my main.py file, but when I put this as an output in a callback I get a SchemaDataValidation error. My website still fully works through this even though I get this error before anything loads. I tried putting my dcc.store in a different layout page, and I don’t get the error here, but issue of putting it in a different page is that I can’t access dcc.store from other layouts, unless it is in my main.py. Can someone give me assistance on how to fix this error, thanks.
Hi @user123456 and welcome to the Dash community
Can you make a minimal example that reproduces the SchemaTypeValidationError? It may not be related to what page the dcc.Store is placed in.
Yes here is an example,
@callback(
[
Output(‘map’, ‘figure’),
Output(‘total’, ‘children’),
Output(‘alert’, ‘children’),
],
[
Input(‘submit’, ‘n_clicks’),
Input(‘reset’, ‘n_clicks’),
],
[
State(‘loc’, ‘value’),
State(‘rad’, ‘value’),
],
def update(reset, submit, loc, rad):
“”"pesudocode’‘’
ctx call
check to see if reset was clicked
if reset is clicked more than once
plot map
set count
set message
return(map, count, message)
else
count items
load message
plot map
return(map, count, message)
Hi @user123456
Unfortunately, pseudocode isn’t helpful in this case. We need to have a minimal example that we can run locally and reproduces the error. More info on how to do that here:
Hi I have updated this here, does this make it more clear?
@callback(
[
Output(‘map’, ‘figure’),
Output(‘total’, ‘children’),
Output(‘alert’, ‘children’),
Output(‘store’, ‘data’),
],
[
Input(‘submit’, ‘n_clicks’),
Input(‘reset’, ‘n_clicks’),
],
[
State(‘loc’, ‘value’),
State(‘rad’, ‘value’),
],
def update(reset, submit, loc, rad):
ctx = dash.callback_context
if ctx.triggered[0][‘prop_id’] == “reset.n_clicks”:
if reset > 0:
figure = plot_map ///This is a function to plot a map from lat/long points
count = 'Total: 0"
loading = 'To start select one"
return(figure, count, loading, None)
else:
count = count_events(loc, rad) ///function to count the total
if count == 0:
loading = f"{loc} is safe"
else:
loading = f"There are 5 occurring"
count_final = f’total: {count}
figure = plot_events ///Plots a map different from the function specified above
info = {‘location’: loc, ‘radius’: rad}
return(figure, count, loading, info)
Sorry, still no. I need to be able to copy the code you post, paste it into my IDE and run it. It needs to be a complete (minimal) example with enough sample data to reproduce the error.
Also if you put the code within three back tics it will format it it correctly .