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

Set progress no update #2901

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion dash/_callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,9 @@ def add_context(*args, **kwargs):
progress = callback_manager.get_progress(cache_key)
if progress:
response["progress"] = {
str(x): progress[i] for i, x in enumerate(progress_outputs)
str(x): progress[i]
for i, x in enumerate(progress_outputs)
if not isinstance(progress[i], NoUpdate)
}

output_value = callback_manager.get_result(cache_key, job_id)
Expand Down
12 changes: 8 additions & 4 deletions tests/integration/long_callback/app_progress_delete.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from dash import Dash, Input, Output, State, html, clientside_callback
from dash import Dash, Input, Output, State, html, clientside_callback, no_update
import time

from tests.integration.long_callback.utils import get_long_callback_manager
Expand All @@ -16,6 +16,7 @@
html.Div(0, id="progress-counter"),
]
)
app.test_lock = lock = long_callback_manager.test_lock

clientside_callback(
"function(_, previous) { return parseInt(previous) + 1;}",
Expand All @@ -35,9 +36,12 @@
prevent_initial_call=True,
)
def on_bg_progress(set_progress, _):
set_progress("start")
time.sleep(2)
set_progress("stop")
with lock:
set_progress("start")
time.sleep(0.5)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we pull 0.5 out into a setting somewhere, or is it unlikely to ever change?

set_progress("stop")
time.sleep(0.5)
set_progress(no_update)
return "done"


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ def test_lcbc014_progress_delete(dash_duo, manager):
dash_duo.start_server(app)
dash_duo.find_element("#start").click()
dash_duo.wait_for_text_to_equal("#output", "done")

assert dash_duo.find_element("#progress-counter").text == "2"
with app.test_lock:
assert dash_duo.find_element("#progress-output").text == "stop"
assert dash_duo.find_element("#progress-counter").text == "2"