-
Notifications
You must be signed in to change notification settings - Fork 1.6k
chore: add librarian state.yaml #14108
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| image: google-cloud-python-generator:latest | ||
| libraries: | ||
| - apis: | ||
| - path: google/cloud/language/v1beta2 | ||
| service_config: '' | ||
| - path: google/cloud/language/v2 | ||
| service_config: '' | ||
| - path: google/cloud/language/v1 | ||
| service_config: '' | ||
| id: google-cloud-language | ||
| last_generated_commit: 97a83d76a09a7f6dcab43675c87bdfeb5bcf1cb5 | ||
| preserve_regex: '' | ||
| remove_regex: '' | ||
| sourcePaths: | ||
| - packages/google-cloud-language | ||
| version: 2.17.2 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you file and link an issue here to remove this file once we're done with our local testing?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We won't be deleting state.yaml. The plan is to have an initial state.yaml when we onboard
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think Librarian will be creating the We're only creating this file for the first milestone. Once we've got configure in place, Librarian should create and place the Why do we want an initial handwritten state.yaml (apart from the first milestone)?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Let's sync offline on this. My initial thought is that we will create the initial |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| # 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. | ||
| # | ||
|
|
||
| import json | ||
| from pathlib import Path | ||
| from typing import List | ||
| import yaml | ||
|
|
||
| SCRIPT_DIR = Path(__file__).resolve().parent | ||
| ROOT_DIR = Path(SCRIPT_DIR / ".." / "..").resolve() | ||
| PACKAGES_DIR = ROOT_DIR / "packages" | ||
| PACKAGES_TO_ONBOARD_YAML = SCRIPT_DIR / "packages_to_onboard.yaml" | ||
| LIBRARIAN_DIR = ROOT_DIR / ".librarian" | ||
| LIBRARIAN_YAML = LIBRARIAN_DIR / "state.yaml" | ||
| RELEASE_PLEASE_MANIFEST_JSON = ROOT_DIR / ".release-please-manifest.json" | ||
| GAPIC_METADATA_JSON = "gapic_metadata.json" | ||
|
|
||
|
|
||
| def configure_state_yaml() -> None: | ||
| """ | ||
| This method updates the `state.yaml` file in the directory | ||
| `.librarian`. | ||
| """ | ||
|
|
||
| state_dict = {} | ||
|
|
||
| release_please_manifest = {} | ||
| with open(RELEASE_PLEASE_MANIFEST_JSON, "r") as release_please_manifest_json_file: | ||
| release_please_manifest = json.load(release_please_manifest_json_file) | ||
|
|
||
| packages_to_onboard = {} | ||
| with open(PACKAGES_TO_ONBOARD_YAML, "r") as packages_to_onboard_yaml_file: | ||
| packages_to_onboard = yaml.safe_load(packages_to_onboard_yaml_file) | ||
|
|
||
| state_dict["image"] = "google-cloud-python-generator:latest" | ||
| state_dict["libraries"] = [] | ||
| for package_name in packages_to_onboard["packages_to_onboard"]: | ||
| package_path = Path(PACKAGES_DIR / package_name).resolve() | ||
| api_paths = [] | ||
| for individual_metadata_file in package_path.rglob(f"**/{GAPIC_METADATA_JSON}"): | ||
| with open(individual_metadata_file, "r") as gapic_metadata_json_file: | ||
| gapic_metadata = json.load(gapic_metadata_json_file) | ||
| api_paths.extend( | ||
| [ | ||
| { | ||
| "path": gapic_metadata["protoPackage"].replace(".", "/"), | ||
| "service_config": "", | ||
| } | ||
| ] | ||
| ) | ||
| state_dict["libraries"].append( | ||
| { | ||
| "id": package_name, | ||
| "version": release_please_manifest[f"packages/{package_name}"], | ||
| "last_generated_commit": "97a83d76a09a7f6dcab43675c87bdfeb5bcf1cb5", | ||
| "apis": api_paths, | ||
| "sourcePaths": [f"packages/{package_name}"], | ||
| "preserve_regex": "", | ||
| "remove_regex": "", | ||
| } | ||
| ) | ||
|
|
||
| with open(LIBRARIAN_YAML, "w") as f: | ||
| yaml.dump(state_dict, f) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| configure_state_yaml() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| # 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. | ||
| # | ||
|
|
||
| packages_to_onboard: [ | ||
ohmayr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "google-cloud-language" | ||
| ] | ||
Uh oh!
There was an error while loading. Please reload this page.