-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix: Respect display.progress_bar=None in background threads #16715
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
Open
shuoweil
wants to merge
36
commits into
main
Choose a base branch
from
shuowei-anywidget-extraneous-output
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 22 commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
d887714
fix: Respect display.progress_bar=None in background threads
shuoweil 42e4a50
refactor: Refactor BQ event progress bar config
shuoweil d6757bc
Refactor BQ event progress bar config and add system test
shuoweil 3e8ddde
refactor: refactor code
shuoweil be825b5
Merge branch 'main' into shuowei-anywidget-extraneous-output
shuoweil 96aaff3
docs: add ignore
shuoweil bfba719
format file
shuoweil 4ffd647
format file
shuoweil ffbc397
Roll back .pre-commit-config.yaml changes
shuoweil 27010d3
Merge branch 'main' into shuowei-anywidget-extraneous-output
shuoweil a6c42af
chore: format files
shuoweil 9742165
Merge branch 'main' into shuowei-anywidget-extraneous-output
shuoweil cdcbf0c
rename _FALLBACK_TO_GLOBAL to _DEFAULT
shuoweil c20751b
Merge branch 'main' into shuowei-anywidget-extraneous-output
shuoweil a139c65
format: format code
shuoweil 85bf48f
Merge branch 'main' into shuowei-anywidget-extraneous-output
shuoweil 67c16c6
Apply review comments in events.py
shuoweil 13b75e7
format code
shuoweil 7b9f249
format code
shuoweil dd69a8d
fix mypy
shuoweil a3e4ac5
update code for lint
shuoweil f393a0d
format code
shuoweil 193d33c
Merge branch 'main' into shuowei-anywidget-extraneous-output
shuoweil d001a9b
refactor: remove progress_bar from events
shuoweil 6377840
refactor: use EventEnvelope for progress_bar context
shuoweil 5584531
style: fix line length lints in formatting_helpers and __init__
shuoweil a7d0171
Merge branch 'main' into shuowei-anywidget-extraneous-output
shuoweil d372472
format file
shuoweil 8879473
Merge branch 'main' into shuowei-anywidget-extraneous-output
shuoweil 457cf84
fix lint
shuoweil 2339d17
format code
shuoweil 44dd6de
format code
shuoweil 5e4dcd8
reformat stubs and fix flake8 E704
shuoweil 26420bf
Merge branch 'main' into shuowei-anywidget-extraneous-output
shuoweil e46c163
chore: add clarifying comment for on_event envelope check
shuoweil 27bba29
chore: add clarifying comment for formatting_helpers envelope check
shuoweil 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
Some comments aren't visible on the classic Files Changed page.
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
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
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
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.
"progress_bar" isn't really state about the event, is it? Could you describe to me again what this is trying to solve?
Consider an alternative where the progress bar type is attached to the subscriber, instead, as that seems to be more appropriate. Or another alternative in which we wrap the events with some sort of "CellState" that gives an indicator of the current execution context, of which the progress_bar could be a property of that.
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.
Hi Tim, thanks for the suggestions.
I looked into the first alternative (attaching the progress bar type to the subscriber), but it doesn't quite work for what we are trying to solve. The progress_bar option is thread-local and needs to be captured from the initiating thread at the moment the query starts. Since subscribers are typically long-lived (session-scoped), they cannot easily capture this per-query context. Furthermore, the callbacks from the BigQuery client library run in a background thread where the initiating thread's local storage is not accessible.
Therefore, I took your second alternative: I removed progress_bar from the event classes and instead wrapped the events in an EventEnvelope (acting as the execution context/'CellState' you suggested). This envelope is created in the callback (which captures the initiating thread's option via a closure) and carries the progress_bar setting along with the event to the subscribers.
This keeps the events clean of display preferences while solving the cross-thread propagation issue. Thanks a lot.