Learn how to use Dash Bio for next-gen sequencing & quality control. 🧬Register for the Oct 27 webinar.

App callback without an output

The missing option to allow users to modify the backend state is what keeps me from going with Dash instead of Jupyter Dahsboards right now. There are many use cases eg collaborative data exploration where having this at least be an option would be tremendously helpful.

I’m curious to learn more about how this is limiting for certain types of examples. Could you post a simple example that demonstrates what you can’t accomplish without modifying the backend state?

For instance, if one user changes a view option in a chart or alters chart data, I’d like the option for that change to be propagated to all users. This would be really helpful for collaborative data exploration for a small team eg 2-5 users. If this can be done without modifying backend, I’d definitely be interested to know.

Ah, I see. Yes, Dash cannot do this right now - each user has independent sessions when viewing dash apps.

I think it would be simple to add an option for users to mirror an existing session upon loading the page instead of creating a new one. The option could be implemented as a GET request so the user just needs to go to a slightly different URL (each session would be assigned a unique ID, and that ID could be stored in a variable that can be optionally added to the page in the Python code).

So, if user A loads a new session @ URL, they can copy and paste the ID from the dashboard and email it to their colleague, who joins @ URL/id=o3ino522

I updated my dash-core-components to the newest version. It seems like from version 0.10.0 upwards there is a new behaviour handling inputs and outputs.
Until version 0.10.0 i was able to store intermediate results into a hidden div and use this div as an input to multiple other callbacks.
Now this isn’t working any more. The result can still be stored into a hidden div but this does not trigger the next input

This was working before, but now it doesn’t (some-value-ui-state is a DIV):

    Output('some-value-ui-state', 'children'),
    [Input('input-folder', 'value')])
def update_some_value_ui_state(folder):
    if folder:
        return some_function(folder)

    Output('input-factors', 'options'),
    [Input('some-value-ui-state', 'children')])
def update_input_factor_options(value):
    return do_something_else()

Saving and loading pre-saved sets of controls is definitely on the roadmap.

@HansG - Could you create a new thread with this issue?

This feature would be great for people like me,

who design HAL interfaces for testing my IOT devices. Like buttons, dials etc…

Callbacks now handle PreventUpdate() exception rising by ignoring the callback output. So the callback can have output set to anything (like some dummy div or even body for kicks) and then just raise PreventUpdate() instead of returning a value.

without getting any input can we display the output to the div?

This would be useful if I just want to print and see what the Input looks like, helps learn how to use the Input. Problem is, only one callback allowed per output, so for every such variable I want to inspect I have to create a new output. Or, input all Inputs in the same callback and and check the context global in the callback…both doable, just tedious

you can prevent the output via raising a exception.

import dash

    dash.dependencies.Output('button', 'style'),
        dash.dependencies.Input('button', 'n_clicks'),

def update(n_clicks):
    if n_clicks == 0:
        raise dash.exceptions.PreventUpdate("cancel the callback")
        return {}

I would like to bump up the topic of callbacks without outputs again because I discovered this to be a common use-case if you use Dash to communicate with other processes.

One example that comes directly into my mind is if you communicate with a Redis server and want to write some values depending on the user input in the Dash app. In a current case I need to control a process that captures the data. The parameters for the capturing like sample time, buffer size and measurement can be controlled by the user via Dash client. So I find myself creating dummy divs for each parameter for being able to transfer them to the Redis server. I know this is the recommended workaround however I think it is not a nice solution and creates unnecessary complexity in the frontend.

I would very much prefer a solution like this:

@app.callback(Output(None), [Input("samplerate_slider", "value"])
def update_samplerate(value: int) -> None:
    redis_client.set("samplerate", value)

Another use-cases I can think of that currently needs dummy divs and could be simplified by this approach:

So maybe we can revive the discussion about callbacks without outputs again :slight_smile: I’m also very willing to offer my help when it comes to implementation.

1 Like

@trav Thanks for the link but I can not see how this addresses the issue at hand :confused:

Necessity of creating a dummy div seems weird. What if I want to do something on timer and don’t need to return anything immediately?

Typically, you would poll updates using an interval component.

You still need an Output e.g. a dummy div for this to work which is not a nice solution if you want to pass information to the Backend (e.g. Redis server).

Yes, but you can just return a blank string. It’s not super elegant, but I don’t see that it does much harm.