Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Update Outputs in middle of callback. #1052

Closed
toddkarin opened this issue Dec 18, 2019 · 6 comments
Closed

[Feature Request] Update Outputs in middle of callback. #1052

toddkarin opened this issue Dec 18, 2019 · 6 comments
Assignees

Comments

@toddkarin
Copy link

Problem
It would often be helpful to update an element in the middle of a callback. A great example if during a long calculation one would like to show results before the full callback is finished, or use a dbc.Loading element to show progress.

Possible Solution
In the middle of a callback, it would be great to have a function that could be called that would change some element before the function is finished. Something like the following would be very helpful:

@app.callback(
    Output("calculation_result", "children"),
    [Input("input", "value")],
)
def run_long_calculation(input):
    # Do really long calculation
    input_data = parse_input_data(input)
    dash.dependencies.Update_Output(id='display_input',children=input_data)
    dash.dependencies.Update_Output(id='progress_bar',value=30)

    # And some more long calculation
    result = run_long_calculation(input_data)
    dash.dependencies.Update_Output(id='progress_bar', value=100)

    return result

Alternatives
A solution could be to use background processes as suggested here: facultyai/dash-bootstrap-components#137

However this is unnecessarily complicated.

@ghost
Copy link

ghost commented Jan 16, 2020

I'm also encountering the same issue. Have a callback that will take some time to complete (transferring files) and would like to update a progress bar during the callback so I know how far along in the transfer it is.

@MM-Lehmann
Copy link

I think this should be requested directly in https://github.com/plotly/dash rather than here

@ghost
Copy link

ghost commented May 26, 2020

FYI to those who are curious: I wasn't able to achieve what I wanted in Dash directly, but with using Redis and Celery to run asynchronous tasks and periodically read the file transfer status from a database, I was able to do what I needed. It's not a great solution, as I have to have another periodic task check on the transfer to ensure nothing failed.

@marsupialtail
Copy link

is there an update on this issue? Is the workaround still the best way to achieve this right now?

@gvwilson
Copy link
Contributor

@T4rk1n is this one still relevant?

@T4rk1n
Copy link
Contributor

T4rk1n commented May 27, 2024

@gvwilson This can now be done with background callbacks. closing.

@T4rk1n T4rk1n closed this as completed May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants