-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
base: dev
Are you sure you want to change the base?
Set progress no update #2901
Conversation
@@ -36,7 +36,9 @@ | |||
) | |||
def on_bg_progress(set_progress, _): | |||
set_progress("start") | |||
time.sleep(2) | |||
time.sleep(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be better to change this to lock to make sure it's not reset.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm assuming you meant to write look instead of lock. Would 7437e2b work?
The final results for this test (tests/integration/long_callback/test_basic_long_callback014.py) would be:
In dev
, the #progress-counter
is 3 because the value gets incremented every time set_progress
is called, but it's correctly being left as 2 with this PR's changes.
As for why #progress-output
is set back to start in dev
, I am not sure 🤔. However, it's correctly being left as stop in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think @T4rk1n was referring to multiprocessing.Lock
, which you can find in some of the other Dash tests. This can remove the need for any explicit sleep
statements, which not only makes the tests faster but also more robust on CI where you never know what else is running on the same hardware and can lead to unexpected delays that will intermittently break tests based on sleep
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I was talking about a multiprocessing.Lock
.
Basically you would do in the callback
with lock:
set_progress(no_update)
Then in the test you can also request the lock and do the assertions, so you can be sure the call to set_progress is done before the assertions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ohh I see, that makes sense. I added the lock in 21bc4b2 🔒
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one question about style but otherwise good to go
set_progress("stop") | ||
with lock: | ||
set_progress("start") | ||
time.sleep(0.5) |
There was a problem hiding this comment.
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?
Fixes #2846.
While I wasn't able to replicate the error from the issue, I did find that
set_progress((no_update, str(total)))
sets the progress to 0:This is because the progress bar's value is being set to
"[object Object]"
, which is probably being interpreted as 0. The progress bar's HTML being:<progress id="progress_bar" value="[object Object]" max="5" style="visibility: visible;"></progress>
.I modified it so that if
set_progress
hasno_update
for a component's output, that component will not be updated, but the other components—assuming they are notno_update
—will be updated.Contributor Checklist
optionals
CHANGELOG.md