Callback error updating when using derived_virtual_data from DataTable

Hi everybody,

I have created a class to create column-wise totals of another DataTable:

class SmartDataTable(object):

def __init__(self, object_id):
    self.id = object_id

def visual_smart_data_table(self, df, filter_action='native'):
    return dash_table.DataTable(
        id=self.id,
        columns=[{"name": i, "id": i} for i in df.columns],
        data=df.to_dict('records'),
        filter_action=filter_action,
        fixed_rows={'headers': True, 'data': 0},
        style_cell={'width': '150px'},
        sort_action="native",
    )


@staticmethod
def call_back_summary(summary_dict_list):
    def summary_update(data):
        temp_data = pd.DataFrame(data)
        summarized_df = pd.DataFrame()
        for summary_dict in summary_dict_list:
            temp_result_list = []
            for method in summary_dict['method']:
                temp_result_list.append(method(temp_data[summary_dict['data_column']]))
            summarized_df[summary_dict['column_name']] = [temp_result_list]
        return summarized_df.to_dict('records')
    return summary_update

In my dashboard i use the callback with the ‘derived_virtual_data’ from another DataTable.
The first time the whole dashboard loads i get the following error message:

When i change some filter in my dashboard etc. the error won’t happen again.

I suspect that this has something to do with the order the callback functions are executed the first time the dashboard loads. The callback functions behaves in a way like the derived virtual data from the other DataTable is not there yet.

Is there a way to tell this specific callback function to be executed last?

Thank you very much in advance.

Is it getting called multiple times, first without all the right data, then again once that data is available? That happens sometimes, it’s something we’re aware of and it’s on our list to improve. You could try just bailing out of the callback if it’s missing the right data, something like:

if not derived_virtual_data:
    raise dash.exceptions.PreventUpdate

or if that’s not specific enough,

if 'avg_price' not in temp_data