-
Notifications
You must be signed in to change notification settings - Fork 6.6k
BigQuery - REST samples for adding labels. #764
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
Conversation
I'm looking into the Travis failure.
Strange that it worked on my machine. I guess maybe because Travis is using a service account and I was using |
I'll add a scope argument to the |
yep, that should do it. |
}) | ||
|
||
# Check the response for errors. | ||
if response.status_code != 200: |
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.
use response.raise_for_status()
.
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.
project_id = default_project_id | ||
|
||
# Send a PATCH request to add or modify a label. | ||
session = google.auth.transport.requests.AuthorizedSession(credentials) |
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.
put session
in the auth section (two lines above)
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.
@@ -0,0 +1,84 @@ | ||
#!/usr/bin/env python |
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.
Would it make sense to combine these into one single file named labels
?
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, it would. Combined.
4570bbe
to
2b18184
Compare
See docs: https://cloud.google.com/bigquery/docs/labeling-datasets
These samples uses raw REST calls because adding labels is not yet supported in the cloud client libraries.