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

Invalid number of output values with pattern matching callbacks and ALL... Expected 0, got 1

$
0
0

I am trying to reset some buttons’ n_clicks values to 0 via callback. These buttons use wildcard pattern-matching, because they are dynamically created.
Shortended example:

@app.callback(
              [Output({'type':'update_everything_btn', 'index': ALL}, 'n_clicks'),
               Output('update_everything_confirmation', 'children')],
              [Input({'type':'update_everything_btn', 'index': ALL}, 'n_clicks_timestamp'),
               ],
              [State({'type':'update_everything_btn', 'index': ALL}, 'n_clicks'),
               ])
def update_everything_callback(a, n_clicks):
    return = [[], [html.Div('Everything updated!')]]

However, I get an error message:

dash.exceptions.InvalidCallbackReturnValue: Invalid number of output values for ..{"index":["ALL"],"type":"update_everything_btn"}.n_clicks...{"index":["ALL"],"type":"update_everything_btn_skip"}.n_clicks...{"index":["ALL"],"type":"update_current_btn"}.n_clicks...{"index":["ALL"],"type":"update_current_btn_skip"}.n_clicks...update_everything_confirmation.children.. item 0.
Expected 0, got 1
output spec: [{'id': {'index': '1', 'type': 'update_everything_btn'}, 'property': 'n_clicks'}]
output value: []

This confuses me greatly - how can the expected number be 0? Furthermore, isn’t an empty list already equivalent to 0 values?

What is the correct way to update n_clicks in this scenario?

Edit:
I suspect that it has something to do with the index not yet existing, since it is created dynamically. But shouldn’t 'index': ALL take care of this? Is this a bug?

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 6271

Trending Articles