Dash: Duplicate Outputs[Feature Request]

Created on 3 Aug 2019  Â·  3Comments  Â·  Source: plotly/dash

Is your feature request related to a problem? Please describe.
Will we ever get the option to reuse Outputs?
I am getting extremely frustrated with having to work around the issue, that every output can only be used once.
Several examples:
I have a filter for data that I want to plot.
I have a text field to add comments to specific plotted tracks.
These comments can be used for further filtering (i.e. don't show tracks with comment 'dead')
I store the adjusted data in a hidden div and retrieve it for my graphs.
Because of the duplicate outputs issue I have to do both filters in a single callback.
Problem:

  1. Requires quite some conditioning.
  2. I cannot revert the previous filter as this will overwrite all the comments.

Second example:
I want to display images based on hoverdata.
I upload a dictionary with keys to filepaths and upload and display them based on hoverdata.
This of course is not very fast, so I would like to each time an image is uploaded update the dictionary with key to uploaded image instead.
Of course this also does not work for the same reason.

Third example:
I would like to be able to change the brightness/contrast of the displayed images.
So i would have a graph displaying the image, and a slider that retrieves the image and selects the max displayed brightness values, that then sends the altered image back to the graph displaying it.
Also can't do this because of the duplicate Outputs issue.

Yes I can think about work arounds for all of these, but that would mean, that each callback will have to be the possibility to do several very different things, getting multiple inputs from completely different objects etc. which just does not make any sense to me.
Allowing for multiple outputs would make life a lot easier.

dash-type-enhancement

Most helpful comment

I think this is a major pain point of Dash. As the number of components (and their callbacks) get large, it becomes unmanageable. We can use the work around of a single callback and using switch statements but the complexity rises rapidly with n^2 where n is the number of inputs.

Having separate independent callbacks that can update the same data (duplicate outputs) is absolutely fundamental to writing moderately complex apps.

All 3 comments

I think this is a major pain point of Dash. As the number of components (and their callbacks) get large, it becomes unmanageable. We can use the work around of a single callback and using switch statements but the complexity rises rapidly with n^2 where n is the number of inputs.

Having separate independent callbacks that can update the same data (duplicate outputs) is absolutely fundamental to writing moderately complex apps.

From what I understand, the problem would be something like this (also stated here and here):
callback1(A, B) → C
callback2(A, D) → C

where one has the same input A modifying the output C in two potentially different ways.
Now, could this be solved with something such as a priority index for callbacks? Or this wouldn’t work or create other types of problems?

There is pattern matching, which indeed helps in many cases now, for example when you go creating new components by user interaction, you just need to set specific patterns for the id keys.

This feature is a must have for large application. There are several reason for having a single piece of data have different point of origin. Right now the options are :

  • Have on big callback with imbricated & complex if / else on the context (which is hard to maintain).
  • Duplicate data with the risk of losing synchronisation between data supposed to be identical.
Was this page helpful?
0 / 5 - 0 ratings

Related issues

mpkuse picture mpkuse  Â·  4Comments

maartenbreddels picture maartenbreddels  Â·  4Comments

hscspring picture hscspring  Â·  4Comments

T4rk1n picture T4rk1n  Â·  3Comments

germayneng picture germayneng  Â·  4Comments