-
Notifications
You must be signed in to change notification settings - Fork 6.6k
feat(bigquery): create cloud-client samples #13147
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
feat(bigquery): create cloud-client samples #13147
Conversation
- Samples must be moved back to this directory.
Here is the summary of changes. You are about to add 6 region tags.
This comment is generated by snippet-bot.
|
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.
LGTM
- Change function name and region tag from '_policies' to '_policy', to match documentation - Add more explanation to how the Access policy is retreived as a list of Access Entries - Add a validation to check if 'access_entries' has elements
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.
It looks like the conftest was copied from https://github.com/googleapis/python-bigquery/blob/main/samples/snippets/conftest.py
Other samples there will eventually have to be moved here so we can keep it mostly intact to avoid breaking other samples when they land here.
- Change typing imports as per PEP-585 and PEP-604 - Remove dependencies for Python < 3.9 - Refactor overriding values - Remove CLI entry point
- Refactor creating and deleting datasets into a single fixture. - Refactor reading stdout/stderr to returning the dataset and asserting it has the right name. - Validate that the dataset was deleted successfully.
- Assert over an Access policy, not the Dataset itself
# https://cloud.google.com/python/docs/reference/bigquery/latest/google.cloud.bigquery.dataset.AccessEntry | ||
|
||
# Get properties for an AccessEntry | ||
if dataset.access_entries: |
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.
That might be because you're indexing over the first element in the list, so you're trying to iterate over a single value rather than the list itself. Would it work if you try this? (note removing the [0]
)
for key, value in dataset.access_entries:
print(key, value)
- Leave only one way to print access_entries, and refactor with a for to show all list elements. - Remove unnecessary validation for deleting dataset. - Remove unnecessary fixture for a second table when first one could be used to create the view. - Remove magic value for empty policy.
- Works better when there is an empty AccessEntry list.
- Simplify use of fixtures. - Apply diverse feedback from the team.
- Hardcoding the EntityType to simplify the sample.
…nify it to Node.JS one - Allow to revoke access by role or by principal_id.
- Add entity_id - Remove unused comments
- Update principal_id sample with a valid identifier.
- Remove unnecesary code. - Rewrite comments and documentation references. - Add __future__ annotations for Python 3.9
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.
LGTM
- Rename 'bigquery_client' to 'client' to make it consistent across samples. - Add validation for empty bindings list in 'view_table_or_access_policy'. - Add '_id' suffix to placeholder.
Description
Step of Internal: b/394478489
Samples
Checklist
nox -s py-3.13
(see Test Environment Setup)nox -s lint
(see Test Environment Setup)