-
Notifications
You must be signed in to change notification settings - Fork 53
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
feat: add entry point #2616
feat: add entry point #2616
Changes from 10 commits
95b66a8
964d81a
5b303cb
4f6cedd
531244d
a6811d5
14cdfb9
24f2070
853b70c
923f149
1cd3859
ffc16ee
87c7d1c
9d723b0
fd7897a
ca902ec
4895971
87c0bdd
69fd09b
d2b3963
b4b907b
ce25efa
8d1d3f6
e155ea0
8de0c3d
e518d3f
22eb127
c25e2bd
cc137b0
5dbcd2c
3d3522b
280cee5
881b557
4de89de
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,94 @@ | ||
# Copyright 2024 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 | ||
# | ||
# https://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 os | ||
|
||
import click as click | ||
from library_generation.generate_pr_description import generate_pr_descriptions | ||
from library_generation.generate_repo import generate_from_yaml | ||
from library_generation.model.generation_config import from_yaml | ||
from library_generation.utils.generation_config_comparator import compare_config | ||
|
||
|
||
@click.group(invoke_without_command=False) | ||
@click.pass_context | ||
@click.version_option(message="%(version)s") | ||
def main(ctx): | ||
pass | ||
|
||
|
||
@main.command() | ||
@click.option( | ||
"--baseline-generation-config", | ||
required=True, | ||
type=str, | ||
help=""" | ||
Path to generation_config.yaml that contains the metadata about | ||
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. Absolute path? 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. Relative path is fine because all path will be converted to absolute path later. 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. So either relative path or absolute path should work? If that's the case, let's document it here as well. 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. Done. |
||
library generation. | ||
The googleapis commit in the configuration is the baseline commit, | ||
exclusively, from which the commit message is considered. | ||
""", | ||
) | ||
@click.option( | ||
"--latest-generation-config", | ||
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 we all it something more generic?Because theoretically we can compare any two configs, not always compare with the latest. In addition, what if the 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 these two names are intuitive, do you have other candidates?
The problem is we don't the relationship between two commitish without traversing from one to another. The worst scenario is the description has too many characters (due to lots of commits) and 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 decided to use The googleapis commitish in |
||
required=True, | ||
type=str, | ||
help=""" | ||
Path to generation_config.yaml that contains the metadata about | ||
library generation. | ||
The googleapis commit in the configuration is the latest commit, | ||
inclusively, to which the commit message is considered. | ||
""", | ||
) | ||
@click.option( | ||
"--repository-path", | ||
type=str, | ||
default=".", | ||
show_default=True, | ||
help=""" | ||
The repository path to which the generated files | ||
will be sent. | ||
If not specified, the repository will be generated to the current working | ||
directory. | ||
""", | ||
) | ||
def generate( | ||
baseline_generation_config: str, | ||
latest_generation_config: str, | ||
repository_path: str, | ||
): | ||
# convert paths to absolute paths, so they can be correctly referenced in | ||
# downstream scripts | ||
baseline_generation_config = os.path.abspath(baseline_generation_config) | ||
latest_generation_config = os.path.abspath(latest_generation_config) | ||
repository_path = os.path.abspath(repository_path) | ||
config_change = compare_config( | ||
baseline_config=from_yaml(baseline_generation_config), | ||
latest_config=from_yaml(latest_generation_config), | ||
) | ||
# generate libraries | ||
generate_from_yaml( | ||
config=config_change.latest_config, | ||
repository_path=repository_path, | ||
target_library_names=config_change.get_changed_libraries(), | ||
) | ||
# generate pull request description | ||
generate_pr_descriptions( | ||
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 probably want to rename |
||
config=config_change.latest_config, | ||
baseline_commit=config_change.baseline_config.googleapis_commitish, | ||
description_path=repository_path, | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
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.
Can we make the interface as simple as possible? For example, both of the configs can be optional. We can use the existence of baseline config to decide if we want to to generate PR descriptions, and assume the current config to be exist in the current folder?
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 both are optional, then we have:
generation_config.yaml
in the current dir and do not generate pr description.current-generation-config
to generate repo and generate pr description.