Skip to content

Commit 2c93542

Browse files
authored
chore: change variable name (#2638)
In this PR: - Change input parameter's name in `entry_point.py`.
1 parent b7ef449 commit 2c93542

File tree

5 files changed

+96
-90
lines changed

5 files changed

+96
-90
lines changed

library_generation/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,8 @@ python -m pip install library_generation/
206206

207207
```bash
208208
python library_generation/entry_point.py generate \
209-
--baseline-generation-config=/path/to/baseline_config_file \
210-
--current-generation-config=/path/to/current_config_file \
209+
--baseline-generation-config-path=/path/to/baseline_config_file \
210+
--current-generation-config-path=/path/to/current_config_file \
211211
--repository-path=path/to/repository
212212
```
213213
If you run `entry_point.py` with the example [configuration](#an-example-of-generation-configuration)

library_generation/cli/entry_point.py

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def main(ctx):
2929

3030
@main.command()
3131
@click.option(
32-
"--baseline-generation-config",
32+
"--baseline-generation-config-path",
3333
required=False,
3434
default=None,
3535
type=str,
@@ -40,7 +40,7 @@ def main(ctx):
4040
""",
4141
)
4242
@click.option(
43-
"--current-generation-config",
43+
"--current-generation-config-path",
4444
required=False,
4545
default=None,
4646
type=str,
@@ -62,8 +62,8 @@ def main(ctx):
6262
""",
6363
)
6464
def generate(
65-
baseline_generation_config: str,
66-
current_generation_config: str,
65+
baseline_generation_config_path: str,
66+
current_generation_config_path: str,
6767
repository_path: str,
6868
):
6969
"""
@@ -87,47 +87,50 @@ def generate(
8787
The commit history, if generated, will be available in
8888
repository_path/pr_description.txt.
8989
"""
90-
default_generation_config = f"{os.getcwd()}/generation_config.yaml"
90+
default_generation_config_path = f"{os.getcwd()}/generation_config.yaml"
9191

92-
if baseline_generation_config is None and current_generation_config is None:
93-
if not os.path.isfile(default_generation_config):
92+
if (
93+
baseline_generation_config_path is None
94+
and current_generation_config_path is None
95+
):
96+
if not os.path.isfile(default_generation_config_path):
9497
raise FileNotFoundError(
95-
f"{default_generation_config} does not exist. "
98+
f"{default_generation_config_path} does not exist. "
9699
"A valid generation config has to be passed in as "
97100
"current_generation_config or exist in the current working "
98101
"directory."
99102
)
100-
current_generation_config = default_generation_config
101-
elif current_generation_config is None:
103+
current_generation_config_path = default_generation_config_path
104+
elif current_generation_config_path is None:
102105
raise FileNotFoundError(
103106
"current_generation_config is not specified when "
104107
"baseline_generation_config is specified. "
105108
"current_generation_config should be the source of truth of "
106109
"library generation."
107110
)
108111

109-
current_generation_config = os.path.abspath(current_generation_config)
112+
current_generation_config_path = os.path.abspath(current_generation_config_path)
110113
repository_path = os.path.abspath(repository_path)
111-
if not baseline_generation_config:
114+
if not baseline_generation_config_path:
112115
# Execute full generation based on current_generation_config if
113116
# baseline_generation_config is not specified.
114117
# Do not generate pull request description.
115118
generate_from_yaml(
116-
config_path=current_generation_config,
117-
config=from_yaml(current_generation_config),
119+
config_path=current_generation_config_path,
120+
config=from_yaml(current_generation_config_path),
118121
repository_path=repository_path,
119122
)
120123
return
121124

122125
# Compare two generation configs and only generate changed libraries.
123126
# Generate pull request description.
124-
baseline_generation_config = os.path.abspath(baseline_generation_config)
127+
baseline_generation_config_path = os.path.abspath(baseline_generation_config_path)
125128
config_change = compare_config(
126-
baseline_config=from_yaml(baseline_generation_config),
127-
current_config=from_yaml(current_generation_config),
129+
baseline_config=from_yaml(baseline_generation_config_path),
130+
current_config=from_yaml(current_generation_config_path),
128131
)
129132
generate_from_yaml(
130-
config_path=current_generation_config,
133+
config_path=current_generation_config_path,
131134
config=config_change.current_config,
132135
repository_path=repository_path,
133136
target_library_names=config_change.get_changed_libraries(),

library_generation/test/cli/entry_point_unit_tests.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ def test_entry_point_with_baseline_without_current_raise_file_exception(self):
3232
# noinspection PyTypeChecker
3333
result = runner.invoke(
3434
generate,
35-
["--baseline-generation-config=path/to/config.yaml", "--repository-path=."],
35+
[
36+
"--baseline-generation-config-path=path/to/config.yaml",
37+
"--repository-path=.",
38+
],
3639
)
3740
self.assertEqual(1, result.exit_code)
3841
self.assertEqual(FileNotFoundError, result.exc_info[0])

library_generation/test/integration_tests.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,8 @@ def __run_entry_point_in_docker_container(
269269
"python",
270270
"/src/cli/entry_point.py",
271271
"generate",
272-
f"--baseline-generation-config=/workspace/config-{repo}/{baseline_config}",
273-
f"--current-generation-config=/workspace/config-{repo}/{current_config}",
272+
f"--baseline-generation-config-path=/workspace/config-{repo}/{baseline_config}",
273+
f"--current-generation-config-path=/workspace/config-{repo}/{current_config}",
274274
f"--repository-path=/workspace/{repo}",
275275
]
276276
)

0 commit comments

Comments
 (0)