I have a callback function that has seven outputs and two inputs. With this configuration a page refuses to render past a certain point. If I comment out any of the outputs, however, the page got rendered OK.
@app.callback(
output=[
Output('Weight-Matrix', 'data'),
Output('Scenario-Names', 'data'),
#Output('fi-dropdown', 'value'),
Output('mm-dropdown', 'value'),
Output('equity-dropdown', 'value'),
Output('balanced-dropdown', 'value'),
Output('alternative-dropdown', 'value'),
],
inputs=[
Input('upload-data', 'contents'),
Input('manual-weights-btn', 'n_clicks'),
],
state=[
State('Manual-table', 'data'),
State('Manual-table', 'columns'),
State('upload-data', 'filename'),
],
)
def set_new_weights_or_import_file(list_of_contents, n_clicks, table_data, Columns, list_of_names):
"""
Updates and stores the weight matrix based on current table data
if scenario file is imported - processes the import
Inputs (changes trigger callbacks):
- n_clicks: clicks of button with id "manual-weights-btn"
- list_of_contents: content of an imported file
States (changes do not trigger callbacks):
- table_data: current data in the table with id "Manual-table"
- columns: the column dictionary of the table with id "Manual-table"
- list_of_names: list of imported file names
Output:
- updated "weight_matrix"
- updated "names", if the user has changed them
- values of fi-dropdown
- values of mm-dropdown
- values of equity-dropdown
- values of balanced-dropdown
- values of alternative-dropdown
"""
# If button pressed, update the weight matrix and scenario names.
# If not, do not update.
if n_clicks:
n_scen = len(table_data[0]) - 1
keys = [x['Asset'] for x in table_data]
vals = [[x[f'scen-{i + 1}'] for i in range(n_scen)] for x in table_data]
return dict(zip(keys, vals)), [Col['name'][1] for Col in Columns[1:]], dash.no_update, dash.no_update, dash.no_update, dash.no_update, dash.no_update
elif list_of_contents:
return parse_scenario_file(list_of_contents, list_of_names)
else:
return dash.no_update, dash.no_update, dash.no_update, dash.no_update, dash.no_update, dash.no_update, dash.no_update