Skip to content
Merged
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
16 changes: 16 additions & 0 deletions .librarian/state.yaml
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
Copy link
Contributor

Choose a reason for hiding this comment

The 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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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

Copy link
Contributor

Choose a reason for hiding this comment

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

I think Librarian will be creating the state.yaml file and maintaining it once we have configure implemented. Ideally, state.yaml shouldn't have any manual edits.

We're only creating this file for the first milestone. Once we've got configure in place, Librarian should create and place the state.yaml file in the /.librarian folder.

Why do we want an initial handwritten state.yaml (apart from the first milestone)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think Librarian will be creating the state.yaml file

Let's sync offline on this. My initial thought is that we will create the initial state.yaml, and update it as needed, and Librarian will fully take over state.yaml only once we've completed the migration from owlbot->librarian.

80 changes: 80 additions & 0 deletions scripts/configure_state_yaml/configure_state_yaml.py
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()
18 changes: 18 additions & 0 deletions scripts/configure_state_yaml/packages_to_onboard.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: [
"google-cloud-language"
]
Loading