I just need to add a progress bar to my app, and reading Dash’s docs, it seems it is mandatory to use long callbacks (and use a callback manager). So, I did it, but I can’t debug anymore the code of my callback since my print outputs aren’t displayed anymore. How come?
My code is the following:
@callback(
output=[Output(component_id="generated-file", component_property="data")],
inputs=[Input(component_id="generate", component_property="n_clicks")],
state=[State(component_id="description", component_property="value"), ...],
running=[(Output("generate", "disabled"), True, False), (Output("cancel", "disabled"), False, True)],
progress=[Output("progress-bar", "value"), Output("progress-bar", "max")],
cancel=[Input("cancel", "n_clicks")],
prevent_initial_call=True,
background=True,
manager=long_callback_manager
)
def generate_callback(set_progress, n_clicks, description, expectations, style):
print(f"Description: {description}") # Not displayed
...
total = 10
for i in range(10):
time.sleep(0.5)
set_progress((str(i + 1), str(total)))
return ""