-
Notifications
You must be signed in to change notification settings - Fork 61
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
base: main
Are you sure you want to change the base?
Conversation
|
|
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.
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): |
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.
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. |
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.
nit:
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. |
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.
nit:
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": |
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.
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 |
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.
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 |
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.
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", |
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.
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: |
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.
Why do we need a setter method?
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
generate output