Skip to content

chore: migrate config change functions to common module #3311

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

Merged
merged 25 commits into from
Oct 30, 2024

Conversation

JoeWang1127
Copy link
Collaborator

@JoeWang1127 JoeWang1127 commented Oct 24, 2024

In this PR:

  • Migrate config change functions to common module.
  • Library generation will accept library names directly.

@product-auto-label product-auto-label bot added the size: m Pull request size is medium. label Oct 24, 2024
@product-auto-label product-auto-label bot added size: l Pull request size is large. and removed size: m Pull request size is medium. labels Oct 24, 2024
@JoeWang1127 JoeWang1127 marked this pull request as ready for review October 28, 2024 19:07
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.

LGTM with a few suggestions - hope they are useful.

Comment on lines 53 to 55
Compare baseline generation config with current generation config and
generate changed library names (a comma separated string) based on current
generation config.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Compare baseline generation config with current generation config and
generate changed library names (a comma separated string) based on current
generation config.
Compares baseline generation config with current generation config and
generates changed library names (a comma separated string) based on current
generation config.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

current_generation_config_path = os.path.abspath(current_generation_config_path)
if not os.path.isfile(current_generation_config_path):
raise FileNotFoundError(
f"{current_generation_config_path} does not exist. "
Copy link
Contributor

@diegomarquezp diegomarquezp Oct 28, 2024

Choose a reason for hiding this comment

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

nit: maybe abstract this duplicated exception message into a function/template? edit: not sure if the message is too small to not justify the effort.

commit = commit_parents[0]
shutil.rmtree(tmp_dir, ignore_errors=True)
with tempfile.TemporaryDirectory() as tmp_dir:
# we only need commit history, thus shadow clone is enough.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# we only need commit history, thus shadow clone is enough.
# we only need commit history, thus a shallow clone is enough.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

@@ -92,6 +92,12 @@ pushd "${api_def_dir}"
git checkout "${googleapis_commitish}"
popd

# generate changed libraries
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 generate changed libraries is a little confusing, I thought we are actually generating libraries when I first read it, but we are actually comparing two configs and figuring out the libraries to generate.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed to get changed library list

Copy link
Collaborator

Choose a reason for hiding this comment

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

I would avoid using the term generation in this file. generate_repo and generate_pr_description make sense because we are actually generating something as files. generate_changed_library though is not really generating something as files, it is an intermediate step to generate_repo and generate_pr_description. The file name could be just get_changed_libraries.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

from common.utils.generation_config_comparator import compare_config


@click.group(invoke_without_command=False)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since this file is not supposed to be called directly, does it still have to be a cli? Maybe cli is still easier, but if not, can we call it as a Python function directly?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We need to use this function in shell script, so I add a CLI to simplify the call.

The result is passed to entry_point.py.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This function is used in shell script so I add a CLI to simplify the call.

def _parse_library_name_from(
includes: str, generation_config: GenerationConfig
) -> Optional[list[str]]:
if includes is None or _needs_full_repo_generation(generation_config):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this _needs_full_repo_generation(generation_config) a logic change?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, this is an existing logic.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It was not here before, is it moved from somewhere?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This function determines whether we want a full generation, i.e., we want a full generation if it's a split repo or sdk-platform-java.

The logic is there before but I moved it here to help create the library name list. If the user doesn't specify --library-names or we do want a full generation, returns None, which means full generation.

)
@click.option(
"--current-generation-config-path",
"--generation-config-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 means our library generation would not need internet access anymore?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think so.

@JoeWang1127 JoeWang1127 requested a review from blakeli0 October 29, 2024 22:32
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 SonarCloud

@JoeWang1127 JoeWang1127 merged commit 4d4c798 into main Oct 30, 2024
49 checks passed
@JoeWang1127 JoeWang1127 deleted the chore/separte-config-change branch October 30, 2024 20:43
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