Need urgent help - Plotly Dash - Callback triggers sometimes & the same callback doesnt trigger sometimes

I am facing issue with callbacks. I have 3 drop downs, one scattermap , one table and one slider on the screen and they all need to work in tandem and i have 5 call backs. When i execute the application all my callbacks associated with these controls execute in random order. After that when i click on scattermap it may or may not work. Say we assume it worked. Then i can navigate all around without any hassle. Then if i execute the application then click on the scattermap then as i mentioned it may or may not work. Say suppose it didn’t work this time. If so is the case it will not work at all no matter what i do and simulaneously one specific dropdown also becomes dysfunctional. However if click any of the other two drop downs then evrything will start functioning as normal.

I have digged really deep into this and figured out that this has nothing to do with my code. The underlying issue is that when the click doesn’t work the reason the reason behind that is the callback isn’t getting triggered. I found out this by applying some debugging techniques and i am 100% sure the callback is not firing. Can anyone help me resolve/understand this please.

Hi @jhassanandani please provide a minimal and standalone Dash app reproducing the issue so that we can help you debugging. It might also be useful to take a look at the graph of callbacks (in the developer tools) to be sure that callbacks do what you think.

The data & code we are using is confidential. Is it alright if i just provide the outline of the callbacks?

Hum probably I will not be able to reproduce the problem if there is just the outline of callbacks, unless of course there is something obvious, we can try. It is likely that it would gain everybody time if you could instead fill the callbacks with minimal dummy data. Thanks!

i am working on getting creating dummy data.

Hi, while i was downsizing the code to share with u i have uncovered something new. I have 4 tabs and all the 4 tabs have exact same controls but different callbacks (but same callback structure) for different functionalities. The problem i described is happening on only and only one of the tabs. The only thing different about this tab is that it has slider extra while other 3 dont have the slider. Rest everything is same. I removed the tabs and just kept the one that has the problem so i can share the code with u however when i remove other tabs the issue doesnt get replicated at all on the tab that i described has issue. Does that indicate something?

Your issue sounds a little like some of the problems that i have experienced with recent versions of Dash,

If this is indeed the case (and since i have not seen the code, i am just making a wild guess), the problem is with Dash, not your code. The good news is that the problem is fixed by the new wildcard callback logic. The bad news is that this code is not released yet, i.e. to get the update right now, you would need to build Dash from source.

@Emil You mean the issue is in the new version and if i try on lower version it should work? Please clarify so i can try this out and see what workaround i can have. Thanks a lot for your response.

@Emmanuelle any thoughts on this?

Yes, you can try to downgrade to 1.6.1 or you could build from source. Assuming that you are on Linux, you should be able to follow the steps sketched in this post,

@Emil Thanks i am on windows but will try this. U can help us on another issue as well. I have put the linkto that above in a comment .

@Emil @Emmanuelle Thanks a lot for helping. I installed Dash 1.6.1 and it resolved the error. All other parts of my application work alright but one part again goes haywire. My radio button on another tab in the application which is fourth tab becomes dysfunctional. For sure thats a dash glitch in 1.6.1. Do you know workaround? I am toggling between two figures using that radio button which are defined in html.div()

found the root cause. The radio button are part of dash core components and i am dash_table another components. They kind of having conflict and dont work well in version 1.6.1. I am providing sample code that illustrates that and opening a new issue.

import chart_studio.plotly as py
import plotly.offline as pyo
import plotly.graph_objs as go
import plotly
import pandas as pd
import chart_studio

import dash
import dash_core_components as dcc
import dash_html_components as html
import numpy as np
from dash.dependencies import Input, Output, State
import dash_table
from dash.exceptions import PreventUpdate
import json
import plotly.express as px

df = pd.read_csv(‘https://raw.githubusercontent.com/plotly/datasets/master/solar.csv’)

app = dash.Dash()

app.layout = html.Div(children = dcc.Tabs(children = [
dcc.Tab(label = ‘Test1’, children =
[dcc.RadioItems(id = “radio_click”,
options=[{‘label’: ‘hello1’, ‘value’: ‘hello1’},
{‘label’: ‘hello2’, ‘value’: ‘hello2’}],
value=‘hello2’,
labelStyle={‘display’: ‘inline-block’, ‘color’:‘skyblue’}
),
html.Div(id = ‘radio1’, children = [“Hello 1”], style = {‘display’:‘none’}),
html.Div(id = ‘radio2’,children = [“Hello 2”], style = {‘display’:‘block’})]),
dcc.Tab(label = ‘Test1’, children = [dash_table.DataTable(
id=‘table’,
columns=[{“name”: i, “id”: i} for i in df.columns],
data=df.to_dict(“rows”),
)])]))

@app.callback([Output(‘radio1’,‘style’), Output(‘radio2’,‘style’)],
[Input(‘radio_click’, ‘value’)])
def callback_a(radioitem_selected):
if radioitem_selected == ‘hello1’:
return {‘display’:‘block’}, {‘display’:‘none’}
elif radioitem_selected == ‘hello2’:
return {‘display’:‘none’}, {‘display’:‘block’}
else:
raise PreventUpdate

import jupyterlab_dash
viewer = jupyterlab_dash.AppViewer()
viewer.show(app)

(we are working on jupyterlab so using jupyterlab_dash appviewer. Please replace with your execution method)

got the resolution. Dash core components in version 1.9.1 are not well compatible with dash table version 4.5.1. I moved to older version of dash_table as well version 4.0.0 and that resolved everything. some tables required minor fix.

correction in above comment … i meant version 1.6.1 not 1.9.1.