-
Notifications
You must be signed in to change notification settings - Fork 0
Fix Progress component #145
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
Merged
Merged
Changes from 12 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
0429139
Add demo pannel 10
clarasb 5b4321b
add `visible` property
clarasb 4224898
extend invokeCallback with pendingProcesses
clarasb 5a33592
add `visible` property to `LinearProgress` component
clarasb 13ca6d6
fix vega_test.py
clarasb 63204c5
move everything progress related into helpers/pendingProgress.ts
clarasb 63449c8
update CHANGES.md
clarasb 0bee733
update package-lock.json
clarasb 3f696fd
rename progress component visibility prop to hidden
clarasb 8613f75
follow-up fixes after renaming visible prop to hidden
clarasb 1ffef31
add docstrings, comments, develepment notes, docs entry
clarasb f7f5ac9
update notes
clarasb ea15820
update CHANGES.md
clarasb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| # Progress Implementation Note | ||
|
|
||
| Chartlets progress components are normal components, like all the others. | ||
| `CircularProgress` and `LinearProgress` render when `hidden` is false and | ||
| do not render when `hidden` is true. | ||
|
|
||
| The extra progress logic (`chartlets.js/packages/lib/src/actions/helpers/pendingProgress.ts`) | ||
| exists only to cover a timing problem: a backend callback can return | ||
| component state changes only after it has finished. Without some frontend | ||
| help, a Python callback computes for several seconds cannot show a spinner | ||
| during that same callback. | ||
|
|
||
| ## How Pending Progress Works | ||
|
|
||
| A panel configures a progress component in its layout: | ||
|
|
||
| ```python | ||
| CircularProgress(id="loading_progress", hidden=True) | ||
| ``` | ||
|
|
||
| If a callback's output includes the progress component's `hidden` property, | ||
| chartlets treats it as a pending-progress target: | ||
|
|
||
| ```python | ||
| Output("loading_progress", "hidden") | ||
| ``` | ||
|
|
||
| When the callback is invoked, the frontend does the following before | ||
| sending the backend request: | ||
|
|
||
| 1. Find callback outputs that target `hidden` on a progress component. | ||
| 2. Set those targets to `hidden: false` locally. | ||
| 3. Send the backend callback request. | ||
|
|
||
| When the backend response arrives, normal callback outputs are applied. The | ||
| Python callback should return the final progress state, usually `True` for | ||
| `hidden` so the spinner disappears. | ||
|
|
||
| ```python | ||
| return True, result | ||
| ``` | ||
|
|
||
| ## Why The Output Is Required | ||
|
|
||
| The output declaration is the only signal that connects the callback to the | ||
| progress component. If a panel removes this output: | ||
|
|
||
| ```python | ||
| # Output("loading_progress", "hidden") | ||
| ``` | ||
|
|
||
| then the frontend does not know that this callback should show that spinner. | ||
| The spinner remains in its layout state. | ||
|
|
||
| ## Failure Handling | ||
|
|
||
| If the backend callback fails, no backend output will arrive to hide the | ||
| spinner. In that case, the frontend hides completed pending-progress targets by | ||
| setting `hidden: true`. | ||
|
|
||
| ## Overlapping Callbacks | ||
|
|
||
| Multiple callbacks can target the same progress component. chartlets keeps a | ||
| small pending count per progress target so one finished callback does not hide a | ||
| spinner that is still needed by another pending callback. | ||
|
|
||
| ## Alternative | ||
|
|
||
| The alternative would be to let every panel manage the state of long-running | ||
| callback requests. This would keep the logic out of the frontend, but it would | ||
| make each panel more complicated to set-up and maintain for the contributors. | ||
|
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Please clarify what "such as" means, because that is a vague.
If it is not exactly
Output("progress", "hidden"), how else can it look like?Must exactly this subset be present? Can they be named differently? Are other outputs still possible?
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 suggest you provide a full example or link into the docs.
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.
done.