Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 42 additions & 1 deletion .generator/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,6 @@ def _clean_up_files_after_post_processing(output: str, library_id: str):
# Safely remove specific files if they exist using pathlib.
Path(f"{output}/{path_to_library}/CHANGELOG.md").unlink(missing_ok=True)
Path(f"{output}/{path_to_library}/docs/CHANGELOG.md").unlink(missing_ok=True)
Path(f"{output}/{path_to_library}/docs/README.rst").unlink(missing_ok=True)

# The glob loops are already safe, as they do nothing if no files match.
for post_processing_file in glob.glob(
Expand Down Expand Up @@ -501,6 +500,47 @@ def _generate_repo_metadata_file(
_write_json_file(output_repo_metadata, metadata_content)


def _copy_readme_to_docs(output: str, library_id: str):
"""Copies the README.rst file for a generated library to docs/README.rst.

This function is robust against various symlink configurations that could
cause `shutil.copy` to fail with a `SameFileError`. It reads the content
from the source and writes it to the destination, ensuring the final
destination is a real file.

Args:
output(str): Path to the directory in the container where code
should be generated.
library_id(str): The library id.
"""
path_to_library = f"packages/{library_id}"
source_path = f"{output}/{path_to_library}/README.rst"
docs_path = f"{output}/{path_to_library}/docs"
destination_path = f"{docs_path}/README.rst"

# If the source file doesn't exist (not even as a broken symlink),
# there's nothing to copy.
if not os.path.lexists(source_path):
return

# Read the content from the source, which will resolve any symlinks.
with open(source_path, "r") as f:
content = f.read()

# Remove any symlinks at the destination to prevent errors.
if os.path.islink(destination_path):
os.remove(destination_path)
elif os.path.islink(docs_path):
os.remove(docs_path)

# Ensure the destination directory exists as a real directory.
os.makedirs(docs_path, exist_ok=True)

# Write the content to the destination, creating a new physical file.
with open(destination_path, "w") as f:
f.write(content)


def handle_generate(
librarian: str = LIBRARIAN_DIR,
source: str = SOURCE_DIR,
Expand Down Expand Up @@ -542,6 +582,7 @@ def handle_generate(
_copy_files_needed_for_post_processing(output, input, library_id)
_generate_repo_metadata_file(output, library_id, source, apis_to_generate)
_run_post_processor(output, library_id)
_copy_readme_to_docs(output, library_id)
_clean_up_files_after_post_processing(output, library_id)
except Exception as e:
raise ValueError("Generation failed.") from e
Expand Down
63 changes: 41 additions & 22 deletions .librarian/state.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
image: us-central1-docker.pkg.dev/cloud-sdk-librarian-prod/images-prod/python-librarian-generator:latest
image: python-librarian-generator:latest
libraries:
- id: google-ads-admanager
version: 0.5.0
Expand Down Expand Up @@ -761,7 +761,7 @@ libraries:
last_generated_commit: d300b151a973ce0425ae4ad07b3de957ca31bec6
apis:
- path: google/cloud/biglake/v1
service_config: ""
service_config: biglake_v1.yaml
source_roots:
- packages/google-cloud-biglake
preserve_regex:
Expand Down Expand Up @@ -2032,9 +2032,9 @@ libraries:
last_generated_commit: d300b151a973ce0425ae4ad07b3de957ca31bec6
apis:
- path: google/cloud/gkehub/v1
service_config: ""
service_config: gkehub_v1.yaml
- path: google/cloud/gkehub/v1beta1
service_config: ""
service_config: gkehub_v1beta1.yaml
source_roots:
- packages/google-cloud-gke-hub
preserve_regex:
Expand All @@ -2057,7 +2057,7 @@ libraries:
last_generated_commit: d300b151a973ce0425ae4ad07b3de957ca31bec6
apis:
- path: google/cloud/gkemulticloud/v1
service_config: ""
service_config: gkemulticloud_v1.yaml
source_roots:
- packages/google-cloud-gke-multicloud
preserve_regex:
Expand All @@ -2071,12 +2071,31 @@ libraries:
remove_regex:
- packages/google-cloud-gke-multicloud
tag_format: '{id}-v{version}'
- id: google-cloud-gkerecommender
version: 0.0.0
last_generated_commit: 979af4bd0c12f882dfeb87e89461aa7ccd1ea4b4
apis:
- path: google/cloud/gkerecommender/v1
service_config: gkerecommender_v1.yaml
source_roots:
- packages/google-cloud-gkerecommender
preserve_regex:
- packages/google-cloud-gkerecommender/CHANGELOG.md
- docs/CHANGELOG.md
- docs/README.rst
- samples/README.txt
- scripts/client-post-processing
- samples/snippets/README.rst
- tests/system
remove_regex:
- packages/google-cloud-gkerecommender
tag_format: '{id}-v{version}'
- id: google-cloud-gsuiteaddons
version: 0.3.18
last_generated_commit: d300b151a973ce0425ae4ad07b3de957ca31bec6
apis:
- path: google/cloud/gsuiteaddons/v1
service_config: ""
service_config: gsuiteaddons_v1.yaml
source_roots:
- packages/google-cloud-gsuiteaddons
preserve_regex:
Expand All @@ -2095,17 +2114,17 @@ libraries:
last_generated_commit: d300b151a973ce0425ae4ad07b3de957ca31bec6
apis:
- path: google/iam/v3
service_config: ""
service_config: iam_v3.yaml
- path: google/iam/v3beta
service_config: ""
service_config: iam_v3beta.yaml
- path: google/iam/admin/v1
service_config: ""
service_config: iam.yaml
- path: google/iam/v2
service_config: ""
service_config: iam_v2.yaml
- path: google/iam/credentials/v1
service_config: ""
service_config: iamcredentials_v1.yaml
- path: google/iam/v2beta
service_config: ""
service_config: iam_v2beta.yaml
source_roots:
- packages/google-cloud-iam
preserve_regex:
Expand Down Expand Up @@ -2520,7 +2539,7 @@ libraries:
last_generated_commit: d300b151a973ce0425ae4ad07b3de957ca31bec6
apis:
- path: google/monitoring/dashboard/v1
service_config: ""
service_config: monitoring.yaml
source_roots:
- packages/google-cloud-monitoring-dashboards
preserve_regex:
Expand Down Expand Up @@ -2619,11 +2638,11 @@ libraries:
last_generated_commit: d300b151a973ce0425ae4ad07b3de957ca31bec6
apis:
- path: google/cloud/networksecurity/v1alpha1
service_config: ""
service_config: networksecurity_v1alpha1.yaml
- path: google/cloud/networksecurity/v1beta1
service_config: ""
service_config: networksecurity_v1beta1.yaml
- path: google/cloud/networksecurity/v1
service_config: ""
service_config: networksecurity_v1.yaml
source_roots:
- packages/google-cloud-network-security
preserve_regex:
Expand Down Expand Up @@ -2764,7 +2783,7 @@ libraries:
last_generated_commit: d300b151a973ce0425ae4ad07b3de957ca31bec6
apis:
- path: google/cloud/oslogin/v1
service_config: ""
service_config: oslogin_v1.yaml
source_roots:
- packages/google-cloud-os-login
preserve_regex:
Expand Down Expand Up @@ -3202,11 +3221,11 @@ libraries:
last_generated_commit: d300b151a973ce0425ae4ad07b3de957ca31bec6
apis:
- path: google/cloud/secretmanager/v1
service_config: ""
service_config: secretmanager_v1.yaml
- path: google/cloud/secretmanager/v1beta2
service_config: ""
service_config: secretmanager_v1beta2.yaml
- path: google/cloud/secrets/v1beta1
service_config: ""
service_config: secretmanager_v1beta1.yaml
source_roots:
- packages/google-cloud-secret-manager
preserve_regex:
Expand Down Expand Up @@ -4553,7 +4572,7 @@ libraries:
last_generated_commit: d300b151a973ce0425ae4ad07b3de957ca31bec6
apis:
- path: grafeas/v1
service_config: ""
service_config: grafeas_v1.yaml
source_roots:
- packages/grafeas
preserve_regex:
Expand All @@ -4575,7 +4594,7 @@ libraries:
last_generated_commit: d300b151a973ce0425ae4ad07b3de957ca31bec6
apis:
- path: google/iam/v1
service_config: ""
service_config: iam_meta_api.yaml
source_roots:
- packages/grpc-google-iam-v1/
preserve_regex: []
Expand Down
13 changes: 13 additions & 0 deletions packages/google-cloud-gkerecommender/.coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[run]
branch = True

[report]
show_missing = True
omit =
google/cloud/gkerecommender/__init__.py
google/cloud/gkerecommender/gapic_version.py
exclude_lines =
# Re-enable the standard pragma
pragma: NO COVER
# Ignore debug-only repr
def __repr__
34 changes: 34 additions & 0 deletions packages/google-cloud-gkerecommender/.flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-
# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
[flake8]
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2333):
# Resolve flake8 lint issues
ignore = E203, E231, E266, E501, W503
exclude =
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2333):
# Ensure that generated code passes flake8 lint
**/gapic/**
**/services/**
**/types/**
# Exclude Protobuf gencode
*_pb2.py

# Standard linting exemptions.
**/.nox/**
__pycache__,
.git,
*.pyc,
conf.py
16 changes: 16 additions & 0 deletions packages/google-cloud-gkerecommender/.repo-metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "google-cloud-gkerecommender",
"name_pretty": "GKE Recommender API",
"api_description": "GKE Recommender API",
"product_documentation": "https://cloud.google.com/kubernetes-engine/docs/how-to/machine-learning/inference-quickstart",
"client_documentation": "https://cloud.google.com/python/docs/reference/google-cloud-gkerecommender/latest",
"issue_tracker": "https://issuetracker.google.com/issues/new?component=1790908",
"release_level": "preview",
"language": "python",
"library_type": "GAPIC_AUTO",
"repo": "googleapis/google-cloud-python",
"distribution_name": "google-cloud-gkerecommender",
"api_id": "gkerecommender.googleapis.com",
"default_version": "v1",
"api_shortname": "gkerecommender"
}
Loading
Loading