Skip to content

chore(bigframes): Add support for bigframes-only project id env var#16859

Draft
TrevorBergeron wants to merge 1 commit intomainfrom
tbergeron_bigframes_project_var
Draft

chore(bigframes): Add support for bigframes-only project id env var#16859
TrevorBergeron wants to merge 1 commit intomainfrom
tbergeron_bigframes_project_var

Conversation

@TrevorBergeron
Copy link
Copy Markdown
Contributor

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #<issue_number_goes_here> 🦕

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request centralizes the logic for determining the default Google Cloud project ID by introducing a new env configuration module and updating the ClientsProvider to require a project ID. The review feedback highlights critical NameError issues in the new get_default_project_id function and the _get_bqclient_and_project helper, where variables were incorrectly referenced. Additionally, there are suggestions to remove an unused import and add a missing newline at the end of the new configuration file to align with PEP 8 standards.

# 2. Project set in the environment
# 3. Project associated with the default credentials
maybe_from_env = (
config.options.bigquery.project
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

critical

The name config is not defined in this scope, which will cause a NameError. Based on the import from bigframes._config import options, you should use options to access the configuration.

Suggested change
config.options.bigquery.project
options.bigquery.project

requests_transport_adapters=config.options.bigquery.requests_transport_adapters,
)
return clients_provider.bqclient, clients_provider._project
return clients_provider.bqclient, project
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

critical

The variable project is not defined in this scope, which will cause a NameError. You should use project_id, which is defined on line 660.

Suggested change
return clients_provider.bqclient, project
return clients_provider.bqclient, project_id


import os

from google.auth import default as auth_default
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

This import of auth_default is unused and can be removed.

References
  1. PEP 8 suggests removing unused imports to keep the code clean and avoid unnecessary dependencies. (link)

"Try setting `bigframes.options.bigquery.project` first."
)

return creds_project No newline at end of file
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

It is a standard convention to end files with a newline character. Please add a newline at the end of the file.

Suggested change
return creds_project
return creds_project
References
  1. PEP 8 recommends that files should end with a single newline character. (link)

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant