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

no_update is not allowed as an output to set_progress for background progress #2846

Open
lunathanael opened this issue May 3, 2024 · 0 comments · May be fixed by #2901
Open

no_update is not allowed as an output to set_progress for background progress #2846

lunathanael opened this issue May 3, 2024 · 0 comments · May be fixed by #2901
Assignees
Labels
bug something broken P3 backlog

Comments

@lunathanael
Copy link

lunathanael commented May 3, 2024

Describe your context
An easy way to replicate the code is using the provided example from Dash Plotly Website. I slightly modified to code by adding a no_update as a return value

  • replace the result of pip list | grep dash below
dash                 0.42.0
dash-core-components 0.47.0
dash-html-components 0.16.0
dash-renderer        0.23.0
dash-table           3.6.0
  • if frontend related, tell us your Browser, Version and OS

    • OS: [e.g. iOS]
    • Browser [e.g. chrome, safari]
    • Version [e.g. 22]

Describe the bug

Returning dash.no_update as a value in set_progress is not allowed.

Expected behavior

dash.no_update should function as normally intended in callback functions

Screenshots

image

import time
import os

from dash import Dash, DiskcacheManager, CeleryManager, Input, Output, html, callback, no_update

if 'REDIS_URL' in os.environ:
    # Use Redis & Celery if REDIS_URL set as an env variable
    from celery import Celery
    celery_app = Celery(__name__, broker=os.environ['REDIS_URL'], backend=os.environ['REDIS_URL'])
    background_callback_manager = CeleryManager(celery_app)

else:
    # Diskcache for non-production apps when developing locally
    import diskcache
    cache = diskcache.Cache("./cache")
    background_callback_manager = DiskcacheManager(cache)

app = Dash(__name__, background_callback_manager=background_callback_manager)

app.layout = html.Div(
    [
        html.Div(
            [
                html.P(id="paragraph_id", children=["Button not clicked"]),
                html.Progress(id="progress_bar", value="0"),
            ]
        ),
        html.Button(id="button_id", children="Run Job!"),
        html.Button(id="cancel_button_id", children="Cancel Running Job!"),
    ]
)

@callback(
    output=Output("paragraph_id", "children"),
    inputs=Input("button_id", "n_clicks"),
    background=True,
    running=[
        (Output("button_id", "disabled"), True, False),
        (Output("cancel_button_id", "disabled"), False, True),
        (
            Output("paragraph_id", "style"),
            {"visibility": "hidden"},
            {"visibility": "visible"},
        ),
        (
            Output("progress_bar", "style"),
            {"visibility": "visible"},
            {"visibility": "hidden"},
        ),
    ],
    cancel=Input("cancel_button_id", "n_clicks"),
    progress=[Output("progress_bar", "value"), Output("progress_bar", "max")],
    prevent_initial_call=True
)
def update_progress(set_progress, n_clicks):
    total = 5
    for i in range(total + 1):
        set_progress((no_update, str(total)))
        time.sleep(1)

    return f"Clicked {n_clicks} times"


if __name__ == "__main__":
    app.run(debug=True)
@leeagustin leeagustin linked a pull request Jun 24, 2024 that will close this issue
8 tasks
@gvwilson gvwilson added P3 backlog bug something broken labels Aug 13, 2024
@gvwilson gvwilson changed the title [BUG] no_update is not allowed as an output to set_progress for background progress no_update is not allowed as an output to set_progress for background progress Aug 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken P3 backlog
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants