-
Notifications
You must be signed in to change notification settings - Fork 1.6k
chore: librarian update image pull request: 20251216T231917Z #14974
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
…prod/images-prod/python-librarian-generator@sha256:b8058df4c45e9a6e07f6b4d65b458d0d059241dd34c814f151c8bf6b89211209
Summary of ChangesHello @parthea, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request updates the underlying librarian image used for generating Python client libraries. This update brings significant changes to how Python version and dependency compatibility are enforced at runtime, and refactors the logic for handling mTLS client certificates across multiple BigQuery Storage and Discovery Engine services. The removal of several keyword fixup scripts indicates an improvement in the code generation process, making these manual adjustments obsolete. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This pull request updates the librarian generator image and applies the resulting code changes. The changes primarily involve:
- Adding Python and dependency version checks in
__init__.pyfiles. - Refactoring mTLS client certificate handling for consistency and to support automatic mTLS enablement from
google-auth. - Removing obsolete
fixupscripts.
The changes are mostly automated and look good. I've identified a couple of minor issues in the newly generated version-checking code that are present across multiple packages. I've added comments on each occurrence for completeness, but the issues are the same:
- The
_package_labelvariable is defined within atryblock but used in the correspondingexceptblock, which could lead to aNameErrorand mask the original exception. - The custom
parse_version_to_tuplefunction does not correctly handle pre-release versions, which could result in missed warnings for users.
Addressing these in the generator would prevent them from propagating to other libraries. Otherwise, the refactoring of mTLS logic and test updates are solid improvements.
| try: | ||
| import sys | ||
| import warnings | ||
|
|
||
| _py_version_str = sys.version.split()[0] | ||
| _package_label = "google.cloud.bigquery_storage_v1" |
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.
The _package_label variable is defined inside the try block but is also used in the except block. If an exception occurs before _package_label is assigned (e.g., during an import), a NameError will be raised within the except block, which can hide the original error. To make the error handling more robust, it's better to define _package_label before the try block. This issue is present in other __init__.py files in this PR.
| try: | |
| import sys | |
| import warnings | |
| _py_version_str = sys.version.split()[0] | |
| _package_label = "google.cloud.bigquery_storage_v1" | |
| _package_label = "google.cloud.bigquery_storage_v1" | |
| try: | |
| import sys | |
| import warnings | |
| _py_version_str = sys.version.split()[0] |
| def parse_version_to_tuple(version_string: str): | ||
| """Safely converts a semantic version string to a comparable tuple of integers. | ||
| Example: "4.25.8" -> (4, 25, 8) | ||
| Ignores non-numeric parts and handles common version formats. | ||
| Args: | ||
| version_string: Version string in the format "x.y.z" or "x.y.z<suffix>" | ||
| Returns: | ||
| Tuple of integers for the parsed version string. | ||
| """ | ||
| parts = [] | ||
| for part in version_string.split("."): | ||
| try: | ||
| parts.append(int(part)) | ||
| except ValueError: | ||
| # If it's a non-numeric part (e.g., '1.0.0b1' -> 'b1'), stop here. | ||
| # This is a simplification compared to 'packaging.parse_version', but sufficient | ||
| # for comparing strictly numeric semantic versions. | ||
| break | ||
| return tuple(parts) |
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.
The parse_version_to_tuple function is a simplification that doesn't handle pre-release identifiers correctly. For example, a version like "4.25.8b1" would be parsed as (4, 25, 8), which is not less than (4, 25, 8). However, 4.25.8b1 is a pre-release of 4.25.8 and should be considered older. This could lead to missing warnings for users on pre-release versions. Consider using packaging.version.parse for a more robust version comparison. While this might add a dependency, packaging is a standard library for this purpose and is often available in environments with setuptools.
| try: | ||
| import sys | ||
| import warnings | ||
|
|
||
| _py_version_str = sys.version.split()[0] | ||
| _package_label = "google.cloud.bigquery_storage_v1alpha" |
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.
The _package_label variable is defined inside the try block but is also used in the except block. If an exception occurs before _package_label is assigned, a NameError will be raised within the except block. To make the error handling more robust, _package_label should be defined before the try block.
| try: | |
| import sys | |
| import warnings | |
| _py_version_str = sys.version.split()[0] | |
| _package_label = "google.cloud.bigquery_storage_v1alpha" | |
| _package_label = "google.cloud.bigquery_storage_v1alpha" | |
| try: | |
| import sys | |
| import warnings | |
| _py_version_str = sys.version.split()[0] |
| def parse_version_to_tuple(version_string: str): | ||
| """Safely converts a semantic version string to a comparable tuple of integers. | ||
| Example: "4.25.8" -> (4, 25, 8) | ||
| Ignores non-numeric parts and handles common version formats. | ||
| Args: | ||
| version_string: Version string in the format "x.y.z" or "x.y.z<suffix>" | ||
| Returns: | ||
| Tuple of integers for the parsed version string. | ||
| """ | ||
| parts = [] | ||
| for part in version_string.split("."): | ||
| try: | ||
| parts.append(int(part)) | ||
| except ValueError: | ||
| # If it's a non-numeric part (e.g., '1.0.0b1' -> 'b1'), stop here. | ||
| # This is a simplification compared to 'packaging.parse_version', but sufficient | ||
| # for comparing strictly numeric semantic versions. | ||
| break | ||
| return tuple(parts) |
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.
The parse_version_to_tuple function is a simplification that doesn't handle pre-release identifiers correctly. For example, a version like "4.25.8b1" would be parsed as (4, 25, 8), which is not less than (4, 25, 8). However, 4.25.8b1 is a pre-release of 4.25.8 and should be considered older. This could lead to missing warnings for users on pre-release versions. Consider using packaging.version.parse for a more robust version comparison. While this might add a dependency, packaging is a standard library for this purpose and is often available in environments with setuptools.
| try: | ||
| import sys | ||
| import warnings | ||
|
|
||
| _py_version_str = sys.version.split()[0] | ||
| _package_label = "google.cloud.bigquery_storage_v1beta" |
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.
The _package_label variable is defined inside the try block but is also used in the except block. If an exception occurs before _package_label is assigned, a NameError will be raised within the except block. To make the error handling more robust, _package_label should be defined before the try block.
| try: | |
| import sys | |
| import warnings | |
| _py_version_str = sys.version.split()[0] | |
| _package_label = "google.cloud.bigquery_storage_v1beta" | |
| _package_label = "google.cloud.bigquery_storage_v1beta" | |
| try: | |
| import sys | |
| import warnings | |
| _py_version_str = sys.version.split()[0] |
| def parse_version_to_tuple(version_string: str): | ||
| """Safely converts a semantic version string to a comparable tuple of integers. | ||
| Example: "4.25.8" -> (4, 25, 8) | ||
| Ignores non-numeric parts and handles common version formats. | ||
| Args: | ||
| version_string: Version string in the format "x.y.z" or "x.y.z<suffix>" | ||
| Returns: | ||
| Tuple of integers for the parsed version string. | ||
| """ | ||
| parts = [] | ||
| for part in version_string.split("."): | ||
| try: | ||
| parts.append(int(part)) | ||
| except ValueError: | ||
| # If it's a non-numeric part (e.g., '1.0.0b1' -> 'b1'), stop here. | ||
| # This is a simplification compared to 'packaging.parse_version', but sufficient | ||
| # for comparing strictly numeric semantic versions. | ||
| break | ||
| return tuple(parts) |
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.
The parse_version_to_tuple function is a simplification that doesn't handle pre-release identifiers correctly. For example, a version like "4.25.8b1" would be parsed as (4, 25, 8), which is not less than (4, 25, 8). However, 4.25.8b1 is a pre-release of 4.25.8 and should be considered older. This could lead to missing warnings for users on pre-release versions. Consider using packaging.version.parse for a more robust version comparison. While this might add a dependency, packaging is a standard library for this purpose and is often available in environments with setuptools.
| try: | ||
| import sys | ||
| import warnings | ||
|
|
||
| _py_version_str = sys.version.split()[0] | ||
| _package_label = "google.cloud.discoveryengine_v1alpha" |
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.
The _package_label variable is defined inside the try block but is also used in the except block. If an exception occurs before _package_label is assigned, a NameError will be raised within the except block. To make the error handling more robust, _package_label should be defined before the try block.
| try: | |
| import sys | |
| import warnings | |
| _py_version_str = sys.version.split()[0] | |
| _package_label = "google.cloud.discoveryengine_v1alpha" | |
| _package_label = "google.cloud.discoveryengine_v1alpha" | |
| try: | |
| import sys | |
| import warnings | |
| _py_version_str = sys.version.split()[0] |
| def parse_version_to_tuple(version_string: str): | ||
| """Safely converts a semantic version string to a comparable tuple of integers. | ||
| Example: "4.25.8" -> (4, 25, 8) | ||
| Ignores non-numeric parts and handles common version formats. | ||
| Args: | ||
| version_string: Version string in the format "x.y.z" or "x.y.z<suffix>" | ||
| Returns: | ||
| Tuple of integers for the parsed version string. | ||
| """ | ||
| parts = [] | ||
| for part in version_string.split("."): | ||
| try: | ||
| parts.append(int(part)) | ||
| except ValueError: | ||
| # If it's a non-numeric part (e.g., '1.0.0b1' -> 'b1'), stop here. | ||
| # This is a simplification compared to 'packaging.parse_version', but sufficient | ||
| # for comparing strictly numeric semantic versions. | ||
| break | ||
| return tuple(parts) |
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.
The parse_version_to_tuple function is a simplification that doesn't handle pre-release identifiers correctly. For example, a version like "4.25.8b1" would be parsed as (4, 25, 8), which is not less than (4, 25, 8). However, 4.25.8b1 is a pre-release of 4.25.8 and should be considered older. This could lead to missing warnings for users on pre-release versions. Consider using packaging.version.parse for a more robust version comparison. While this might add a dependency, packaging is a standard library for this purpose and is often available in environments with setuptools.
| import sys | ||
| import warnings | ||
|
|
||
| _py_version_str = sys.version.split()[0] | ||
| _package_label = "google.cloud.discoveryengine_v1beta" | ||
| if sys.version_info < (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.
The _package_label variable is defined inside the try block but is also used in the except block. If an exception occurs before _package_label is assigned, a NameError will be raised within the except block. To make the error handling more robust, _package_label should be defined before the try block.
_package_label = "google.cloud.discoveryengine_v1beta"
try:
import sys
import warnings
_py_version_str = sys.version.split()[0]| """Safely converts a semantic version string to a comparable tuple of integers. | ||
| Example: "4.25.8" -> (4, 25, 8) | ||
| Ignores non-numeric parts and handles common version formats. | ||
| Args: | ||
| version_string: Version string in the format "x.y.z" or "x.y.z<suffix>" | ||
| Returns: | ||
| Tuple of integers for the parsed version string. | ||
| """ | ||
| parts = [] | ||
| for part in version_string.split("."): | ||
| try: | ||
| parts.append(int(part)) | ||
| except ValueError: | ||
| # If it's a non-numeric part (e.g., '1.0.0b1' -> 'b1'), stop here. | ||
| # This is a simplification compared to 'packaging.parse_version', but sufficient | ||
| # for comparing strictly numeric semantic versions. | ||
| break | ||
| return tuple(parts) | ||
|
|
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.
The parse_version_to_tuple function is a simplification that doesn't handle pre-release identifiers correctly. For example, a version like "4.25.8b1" would be parsed as (4, 25, 8), which is not less than (4, 25, 8). However, 4.25.8b1 is a pre-release of 4.25.8 and should be considered older. This could lead to missing warnings for users on pre-release versions. Consider using packaging.version.parse for a more robust version comparison. While this might add a dependency, packaging is a standard library for this purpose and is often available in environments with setuptools.
feat: update image to us-central1-docker.pkg.dev/cloud-sdk-librarian-prod/images-prod/python-librarian-generator@sha256:b8058df4c45e9a6e07f6b4d65b458d0d059241dd34c814f151c8bf6b89211209
BEGIN_COMMIT
BEGIN_NESTED_COMMIT
feat: auto-enable mTLS when supported certificates are detected
feat: check Python and dependency versions in generated GAPICs
PiperOrigin-RevId: 845448683
Library-IDs: google-cloud-bigquery-storage,google-cloud-discoveryengine,google-cloud-secret-manager,google-cloud-speech
Source-link: googleapis/googleapis@14967163
END_NESTED_COMMIT
END_COMMIT