-
Notifications
You must be signed in to change notification settings - Fork 1.7k
test: verify read_gbq_colab label preservation in anywidget display mode #17887
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
Changes from 3 commits
d0b590e
dc53247
a8a07ba
c563483
9185cdd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -68,8 +68,15 @@ def create_job_configs_labels( | |
| job_configs_labels = dict(job_configs_labels) | ||
|
|
||
| if api_methods and "bigframes-api" not in job_configs_labels: | ||
| job_configs_labels["bigframes-api"] = api_methods[0] | ||
| del api_methods[0] | ||
| api_methods = list(api_methods) | ||
| colab_idx = next( | ||
| (i for i, m in enumerate(api_methods) if "read_gbq_colab" in m), None | ||
| ) | ||
| if colab_idx is not None: | ||
| job_configs_labels["bigframes-api"] = api_methods.pop(colab_idx) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not immediately clear to me why we need to pop at the colab_idx instead of at head. Could you add some explanatory comments here?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have reverted the method-specific popping logic. We used to want to override the label precedence in Python due to the tracking mechanism of dashboard. However, we toss this approach for now, and I will update the change in dashboard instead. |
||
| else: | ||
| job_configs_labels["bigframes-api"] = api_methods[0] | ||
| del api_methods[0] | ||
|
shuoweil marked this conversation as resolved.
Outdated
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand why we need a special case for
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed. We have removed this special case. In this PR, we just make sure session-read_gbq_colab is anyiwdget mode is preserved. I will make the changes from dashboard to loop through all labels. This approach would avoid hardcoded specials cases. |
||
|
|
||
| # Make sure we always populate bigframes-api with _something_, even if we | ||
| # have a code path which doesn't populate the list of api_methods. See | ||
|
|
||
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.
Non-rhetorical question: do we need this line of change? It alters the behavior of the original code, which alters the original list that was passed in at line 73.
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, this shallow copy is intentional as a safety guard. There are two reasons. (1) at line 73, del api_methods[0]
removes the primary API label. Creating a copy ensures this deletion stys local to the helper function and does not mutate the caller's original list if reused or logs elsewhere.
(2) api_methods may sometime pass in tuple. We have a unit test reate_job_configs_labels(labels, ("read_gbq_colab", "head")) will pass tuples to label. In this case, tuple is immutable. This copy is a guard to avoid errors for del api_methods[0].