Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Addclient_info to BigQuery constructor for user-amenable user agent headers#7806

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
tswast merged 2 commits intogoogleapis:masterfromtswast:b116069533-bq-client-info
Apr 30, 2019

Conversation

@tswast
Copy link
Contributor

@tswasttswast commentedApr 25, 2019
edited
Loading

This aligns BigQuery's behavior regarding the User-Agent and
X-Goog-Api-Client headers with that of the GAPIC-based clients.

Old:

X-Goog-API-Client: gl-python/3.7.2 gccl/1.11.2User-Agent: gcloud-python/0.29.1

New:

X-Goog-API-Client: optional-application-id/1.2.3 gl-python/3.7.2 grpc/1.20.0 gax/1.9.0 gapic/1.11.2 gccl/1.11.2User-Agent: optional-application-id/1.2.3 gl-python/3.7.2 grpc/1.20.0 gax/1.9.0 gapic/1.11.2 gccl/1.11.2

In order to set theoptional-application-id/1.2.3, the latest version
ofapi_core is required, but since that's an uncommon usecase and it
doesn't break, just ignore the custom User-Agent if an older version is
used, I didn't update the minimum versionsetup.py.

This PR depends on:

@googlebotgooglebot added the cla: yesThis human has signed the Contributor License Agreement. labelApr 25, 2019
@tswasttswast added the api: bigqueryIssues related to the BigQuery API. labelApr 25, 2019
Copy link
Contributor

@shollymanshollyman left a comment

Choose a reason for hiding this comment

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

Seems reasonable for the BQ changes. There will be a followup change for exposing client_info to the other BQ APIs like dts and storage?

@tswast
Copy link
ContributorAuthor

followup change for exposing client_info to the other BQ APIs like dts and storage?

Already present on those, which was a major factor in going with this design.

Once#7799 goes in, we'll be able to setclient_info.user_agent = "my-application/1.2.3" on all GAPIC clients.

At some point, I do intend to update the BQ magics to set this user agent field, as they create their own clients, and I figure we can track that as using BQ from Jupyter.

_http=http,
)

table=client.get_table(self.TABLE_REF)
Copy link
Contributor

Choose a reason for hiding this comment

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

Lint failure here: thetable variable is never used. You can just invokeclient.get_table without binding the return value, or use_.

tswast reacted with thumbs up emoji
…headersThis aligns BigQuery's behavior regarding the User-Agent andX-Goog-Api-Client headers with that of the GAPIC-based clients.Old:    X-Goog-API-Client: gl-python/3.7.2 gccl/1.11.2    User-Agent: gcloud-python/0.29.1New:    X-Goog-API-Client: optional-application-id/1.2.3 gl-python/3.7.2 grpc/1.20.0 gax/1.9.0 gapic/1.11.2 gccl/1.11.2    User-Agent: optional-application-id/1.2.3 gl-python/3.7.2 grpc/1.20.0 gax/1.9.0 gapic/1.11.2 gccl/1.11.2In order to set the `optional-application-id/1.2.3`, the latest versionof `api_core` is required, but since that's an uncommon usecase and itdoesn't break, just ignore the custom User-Agent if an older version isused, I didn't update the minimum version `setup.py`.
@tswasttswastforce-pushed theb116069533-bq-client-info branch fromd0110ea toec4a491CompareApril 29, 2019 20:48
@tswasttswast marked this pull request as ready for reviewApril 29, 2019 20:48
@tswasttswast requested a review froma teamApril 29, 2019 20:48
@tswasttswast merged commit0a55c26 intogoogleapis:masterApr 30, 2019
@tswasttswast deleted the b116069533-bq-client-info branchApril 30, 2019 18:36
:param client: The client that owns the current connection.
"""

def__init__(self,client,client_info=None):
Copy link
Contributor

Choose a reason for hiding this comment

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

@tswast Need to document theclient_info parameter in the class docstring.

Copy link
Contributor

Choose a reason for hiding this comment

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

We should probably hoist this machinery into thegoogle.cloud._http.JSONConnection base class.


@USER_AGENT.setter
defUSER_AGENT(self,value):
self._client_info.user_agent=value
Copy link
Contributor

Choose a reason for hiding this comment

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

These aren't constants, so why uppercase?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

For backwards compatibility.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

There's aUSER_AGENT on the superclass, which we want to override the behavior of.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@shollymanshollymanshollyman approved these changes

+1 more reviewer

@tseavertseavertseaver left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

api: bigqueryIssues related to the BigQuery API.cla: yesThis human has signed the Contributor License Agreement.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@tswast@tseaver@shollyman@googlebot

[8]ページ先頭

©2009-2025 Movatter.jp