Skip to content
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

chore: allow --api-path as option to generate cmd and generate per api/majorversion #3712

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

zhumin8
Copy link
Contributor

@zhumin8 zhumin8 commented Mar 18, 2025

This change allow generator to generate for a specified api-path. When "--api-path" is not specified, fallback to "--library-names", and behavior for existing command should not change.

For now, api-path should only take in path to api/version, e.g. google/cloud/functions/v2

--
Manual tests

python library_generation/cli/entry_point.py generate --output=/path/to/empty/output --generation-input=/path/to/gen-input --api-root=/path/to/googleapis --api-path=google/cloud/alloydb/v1

generate output

├── google-cloud-alloydb
│   ├── pom.xml                                                                            
│   ├── src                                                                                
│   │   ├── main                                                                           
│   │   │   ├──......                                                
│   │   │   │    └── v1  
├── google-cloud-alloydb-bom
├── grpc-google-cloud-alloydb-v1
├── owlbot.py
├── pom.xml
├── proto-google-cloud-alloydb-v1
├── README.md
└── samples

@product-auto-label product-auto-label bot added the size: l Pull request size is large. label Mar 18, 2025
@zhumin8 zhumin8 marked this pull request as ready for review March 24, 2025 21:22
Copy link

Copy link

Quality Gate Passed Quality Gate passed for 'java_showcase_integration_tests'

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarQube Cloud

Copy link
Contributor

@diegomarquezp diegomarquezp left a comment

Choose a reason for hiding this comment

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

Thanks for this PR. It will make local development much easier (no need to modify the gen config yaml anymore).

I left a couple of nits and a minor question.



def __required(config: dict, key: str, level: str = LIBRARY_LEVEL_PARAMETER):
def _required(config: dict, key: str, level: str = LIBRARY_LEVEL_PARAMETER):
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for fixing this. Looks like this is recommended by our style guide. Just curious on any other changes of this kind in this PR?

) -> list[LibraryConfig]:
"""
Retrieves a copy of the LibraryConfig objects that contain the specified
target API path, removed other proto_path versions from LibraryConfig if any.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit:

Suggested change
target API path, removed other proto_path versions from LibraryConfig if any.
target API path, without other proto_path versions that were not specified.

"""
Retrieves a copy of the LibraryConfig objects that contain the specified
target API path, removed other proto_path versions from LibraryConfig if any.
proto_path that is dependency, not another version is kept.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit:

Suggested change
proto_path that is dependency, not another version is kept.
dependency proto_paths are kept.

Hope you also find this wording easier to read. I think it's clear in the previous line that other proto_path versions are not considered.

@@ -105,77 +105,77 @@ def __validate(self) -> None:
)
seen_library_names[library_name] = library.name_pretty

@staticmethod
def from_yaml(path_to_yaml: str) -> "GenerationConfig":
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are there any logical change in this method?

show_default=True,
help="""
Path within the API root (e.g. googleapis) to the API to
generate/build/configure etc. This is expected to be a major-versioned
Copy link
Collaborator

Choose a reason for hiding this comment

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

What's the difference of major-versioned and versioned?

API directory, e.g. google/cloud/functions/v2.

Takes precedence over --library-names when specidied.
If neither this or --api-path specified, all libraries in the
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
If neither this or --api-path specified, all libraries in the
If neither --library-names or --api-path specified, all libraries in the

""",
)
@click.option(
"--api-path",
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this parameter is overlap with library-names and it's fine-gained than it.

Do you plan to remove library-names later?

@@ -31,3 +31,21 @@ def find_versioned_proto_path(proto_path: str) -> str:
idx = proto_path.find(version)
return proto_path[:idx] + version
return proto_path


def ends_with_version(proto_path: str) -> bool:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we need a setter method?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: l Pull request size is large.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants