ServersideOutput data is not seen from Input with dash enrich library

I am trying the example at ServersideOutputTransform with minor modifications to add some debug capabilities.

#! /usr/bin/env python3

import time
import as px
from dash_extensions.enrich import DashProxy, Output, Input, State, ServersideOutput, html, dcc, \

app = DashProxy(transforms=[ServersideOutputTransform()])
app.layout = html.Div(
        html.Button("Query data", id="btn"),
        dcc.Loading(dcc.Store(id="store"), fullscreen=True, type="dot"),

@app.callback(ServersideOutput("store", "data"), Input("btn", "n_clicks"), prevent_initial_call=True)
def query_data(n_clicks):
    time.sleep(3)  # emulate slow database operation
    df =
    return df  # no JSON serialization here

@app.callback(Output("dd", "options"),  Output("dd", "value"), Input("store", "data"), prevent_initial_call=True)
def update_dd(df):
    options = [{"label": column, "value": column} for column in df["year"]]   # no JSON de-serialization here
    return options, options[0]['value']

@app.callback(Output("graph", "figure"), [Input("dd", "value"), State("store", "data")], prevent_initial_call=True)
def update_graph(value, df):
    df = df.query("year == {}".format(value))  # no JSON de-serialization here
    return px.sunburst(df, path=["continent", "country"], values="pop", color="lifeExp", hover_data=["iso_alpha"])

if __name__ == "__main__":
    app.run_server(host='localhost', port=5050, debug=True, threaded=True)

I get the following error

    options = [{"label": column, "value": column} for column in df["year"]]   # no JSON de-serialization here
TypeError: 'NoneType' object is not subscriptable

It appears like the Input is not getting the ServersideOutput

Am I missing something?

Known issue: FYI Upstream Issue with Flask-caching > 1.10.1 (1.11.1 as of writing) · Issue #181 · thedirtyfew/dash-extensions · GitHub

If you downgrade flask-caching to 1.10.1 it works. But apparently that’s a security risk (see comment in the GitHub Issue)

Please try again with dash-extensions==0.1.4. The issue was due to a breaking change in flask-caching. I have now updated to the latest version (flask-caching==2.0.0) and adopted the dash-extensions code accordingly.

Thank you @Emil Works fine now

1 Like