I am hitting a wall for days now and I am not able to find any working solution. I am using dash with the django-plotly-dash wrapper.
As a start, I will isolate my case from the whole app:
def update_test_div_sd(relayoutData, selectedData, *args, **kwargs):
selectedData = [i['x'] for i in selectedData['points']] if selectedData else None
rd_raw_from = relayoutData.get('xaxis.range', None)
rd_raw_to = relayoutData.get('xaxis.range', None)
relayoutData_from = datetime.strptime(rd_raw_from,'%Y-%m-%d %H:%M:%S.%f') if rd_raw_from else None
relayoutData_from = datetime.strptime(rd_raw_from,'%Y-%m-%d') if rd_raw_from else None
relayoutData_to = datetime.strptime(rd_raw_to,'%Y-%m-%d %H:%M:%S.%f') if rd_raw_to else None
relayoutData_to = datetime.strptime(rd_raw_to,'%Y-%m-%d') if rd_raw_to else None
return relayoutData_from, relayoutData_to, selectedData
The above callback generates endless POST request and does not reneder the Dash App.
If I only keep the
selectedData or the
relayoutData independently, it works flawlessly in both cases.
'prio-bar-chart' are generated via callbacks, hence I have
suppress_callback_exceptions=True which, as I said, works, except for the scenario above.
Maybe there is some more verbose debugging I can make use of to understand what the actual problem is.
Any help is much appreciated!
this PR https://github.com/plotly/dash-core-components/pull/621 might solve the problem, you can try it out with next release
This is fantastic, @byronz. I’ll wait then for
dash-core-components 1.1.3 to be release, hoping for it soon, as well in https://pypi.org/project/dash-core-components/ (which I am actually using).
@chriddyp Any idea when
1.1.3 will be released?
Many, many thanks!
@radupm next release targets next week
I’ve updated to the new release. Unfortunately, nothing has changed at all. Still getting the infinite loop…
I really hoped the mentioned PR will solve my issue - and, indeed, it looked like that.
Any idea what I should do next? Should I just drop my expectation of multiple interactions between dash app elements? So far 1:N works, N:N is the pain…
sorry to hear that. looking at your code, why you need this
*args, **kwargs in the function signature? and I’m assuming your output is a div with text string? so the
return relayoutData_from, relayoutData_to, selectedData doesn’t look good.
@radupm if you can share your code by a gist link, that would be more helpful to debug.
*args, **kwargs, I just add them for the case additional arguments are passed to the callback, so I avoid errors.
As for the return vars, why is that not good? Now I feel I wrongly understood Dash…?! Just want to see text output for debug/dev reasons.
I’ve put the full dash app code in here https://gist.github.com/radupm/46913b8b567444785e132f25313b6cfd.
session_state.get('dash_user_scope') is used as I have user context data I need to pass as ORM filters, it’s just an array.
- I know I am not DRY at all with the ORM Queries - I will refactor that once I get the Dash running as needed
Can’t appreciate your help enough!
@radupm my bad on the Output, I thought it was in a list, but your case was not.
So it’s OK to do the return like this.
Quick try with the code, can you also share how to configure the setting with django? I got this
File "/Users/byron/code/.venv/dash130/lib/python3.7/site-packages/django/conf/__init__.py", line 64, in _setup
% (desc, ENVIRONMENT_VARIABLE))
django.core.exceptions.ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
@byronz I fear the set-up with django is a bit more of a hassle. This should help setting it up https://django-plotly-dash.readthedocs.io/en/latest/
To keep it simple, you may want to pull the demo and replace one of the apps with the gist code I’ve put above. The ORM queries output would need to be replaced with some dummy data. If the expected output is not clear from the code itself, I can update the gist with dummy data as a replacement for the ORM queries.