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

Build incremental components through build workflow with loading previous build manifest #4289

Merged
merged 13 commits into from
Jan 4, 2024

Conversation

zelinh
Copy link
Member

@zelinh zelinh commented Dec 14, 2023

Description

This is the last PR to enable incremental build on the Python workflow.

The idea of this PR is to build those components that were detected by rebuild_component from build_incremental class.

Firstly we add a new parameter to the build_recorder class so that it could load existing build manifest if provided; otherwise generate a brand new manifest.

Then similar to how we build in run_build.py, here for incremental build, we are importing the previous build manifest and only build the list of components from buildIncremental.rebuild_plugins().

Issues Resolved

#4210

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: Zelin Hao <zelinhao@amazon.com>
Signed-off-by: Zelin Hao <zelinhao@amazon.com>
Signed-off-by: Zelin Hao <zelinhao@amazon.com>
Copy link

codecov bot commented Dec 14, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (11f9ea4) 91.18% compared to head (c442dab) 91.27%.
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4289      +/-   ##
==========================================
+ Coverage   91.18%   91.27%   +0.08%     
==========================================
  Files         189      189              
  Lines        6146     6163      +17     
==========================================
+ Hits         5604     5625      +21     
+ Misses        542      538       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@zelinh
Copy link
Member Author

zelinh commented Dec 15, 2023

I'm looking to add additional tests to fix the cov.

Signed-off-by: Zelin Hao <zelinhao@amazon.com>
@zelinh
Copy link
Member Author

zelinh commented Dec 15, 2023

PR is ready for review. Seems like some issues with Maven so that the groovy test failed.

src/build_workflow/build_incremental.py Outdated Show resolved Hide resolved
src/build_workflow/build_incremental.py Outdated Show resolved Hide resolved
src/build_workflow/build_incremental.py Outdated Show resolved Hide resolved
Signed-off-by: Zelin Hao <zelinhao@amazon.com>
Copy link
Member

@dblock dblock left a comment

Choose a reason for hiding this comment

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

This is pretty clean. See below, rename/simplify. Document this feature?

src/run_build.py Outdated

logging.info(f"Build {components} incrementally.")

build_manifest_data = BuildManifest.from_path(build_manifest_path).__to_dict__()
Copy link
Member

Choose a reason for hiding this comment

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

Rename this to build_manifest and pass around as BuildManifest, rather than a dict.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks. Working on the changes.

Signed-off-by: Zelin Hao <zelinhao@amazon.com>
self.components_hash: Dict[str, Dict[str, Any]] = {}

if build_manifest:
build_manifest_data = build_manifest.__to_dict__()
self.data = build_manifest_data
Copy link
Member

Choose a reason for hiding this comment

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

I believe you should be able to iterate through components without turning the build manifest into a dictionary first, which would remove the need for the build_manifest_data variable.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think that would require to change the logics in other sections for example to_manifest from build_recorder since it generates the build manifest based on dictionary. Do you think it's necessary or it may be overcomplicated.

Copy link
Member

@dblock dblock Jan 3, 2024

Choose a reason for hiding this comment

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

Whatever you need to add to build_manifest is a good idea. It should look like this here:

self.data = dict(build_manifest)
for component in build_manifest.components:
    self.components_hash[component.name] = dict(component)

or even

self.data = dict(build_manifest)
self.components_hash = dict(build_manifest.components)

Copy link
Member Author

Choose a reason for hiding this comment

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

I see what you mean! Updated in the latest commit. Thanks for suggestion!

Signed-off-by: Zelin Hao <zelinhao@amazon.com>
@zelinh
Copy link
Member Author

zelinh commented Jan 3, 2024

This is pretty clean. See below, rename/simplify. Document this feature?

@dblock Just added some documentations. Please help review it as well. Thanks!

Signed-off-by: Zelin Hao <zelinhao@amazon.com>
Signed-off-by: Zelin Hao <zelinhao@amazon.com>
@peterzhuamazon
Copy link
Member

Just reviewed with @zelinh on this PR.

I have no issues with the implementation and is clear on the details.
Regarding the conflict between --component and --incremental, is it possible to go these two routes:

  1. If both parameters present, error out the build and provide information in console, that user can only use either parameter, not both at the same time.
  2. If both parameters present, output a warning msg in the console, notify user that --component will not take effect when --incremental is presented at the same time.

The 1st route needs more implementation, while the 2nd route requires one more logging.
Please let me know what you think.

Thanks.

@peterzhuamazon
Copy link
Member

peterzhuamazon commented Jan 3, 2024

After discussing again among @gaiksaya @zelinh and I, we have decided to make both --component and --incremental mutually exclusive by following the solution here:
https://github.com/opensearch-project/opensearch-build/blob/main/src/validation_workflow/validation_args.py#L114

Later, we can make both parameters work together, in cases where user want to use --incremental function to verify if there is a change within the component(s) defined by --component parameter.

Thanks.

Signed-off-by: Zelin Hao <zelinhao@amazon.com>
@zelinh
Copy link
Member Author

zelinh commented Jan 4, 2024

Updated based on what @peterzhuamazon @gaiksaya and I discussed earlier.
I make --components and --incremental mutually exclusive for now. We can discuss about the future enhancement later.
If the rebuild list is empty, the whole build process will stop and skip building from everything.

Please help review it again. Thanks! @peterzhuamazon @gaiksaya @dblock

Copy link
Member

@gaiksaya gaiksaya left a comment

Choose a reason for hiding this comment

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

Almost there!

Please add test for skipping the entire build and ensure the graceful exit.
Thanks!

src/run_build.py Outdated Show resolved Hide resolved
src/run_build.py Show resolved Hide resolved
Signed-off-by: Zelin Hao <zelinhao@amazon.com>
@zelinh
Copy link
Member Author

zelinh commented Jan 4, 2024

Almost there!

Please add test for skipping the entire build and ensure the graceful exit. Thanks!

Added new tests. I tried locally and it works.

[opensearch@c81bdd48ecdb opensearch-build]$ ./build.sh manifests/2.12.0/opensearch-2.12.0-inc.yml --incremental
Installing dependencies in . ...
Installing dependencies from Pipfile.lock (fcf5b2)...
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.
Running ./src/run_build.py manifests/2.12.0/opensearch-2.12.0-inc.yml --incremental ...
2024-01-04 00:47:28 INFO     Loading tar/builds/opensearch/manifest.yml
2024-01-04 00:47:29 INFO     Updating ref for https://github.com/opensearch-project/OpenSearch.git from 923aa25367006b830a0b66aca82eb9c47dafba22 to 923aa25367006b830a0b66aca82eb9c47dafba22 (923aa25367006b830a0b66aca82eb9c47dafba22)
2024-01-04 00:47:29 INFO     Updating ref for https://github.com/opensearch-project/common-utils.git from 2.x to 8e2537b6c1cde03449f0818242a1a36089a69522 (refs/heads/2.x)
2024-01-04 00:47:29 INFO     Updating ref for https://github.com/opensearch-project/job-scheduler.git from 2.x to 482c90fccf59a3e02bc5cb60124580c164a9d7c3 (refs/heads/2.x)
2024-01-04 00:47:30 INFO     Updating ref for https://github.com/opensearch-project/geospatial.git from 2.x to 273fa8fe051d469b5a79ee37a1ce203738239ddb (refs/heads/2.x)
2024-01-04 00:47:30 INFO     Updating ref for https://github.com/opensearch-project/security.git from 2.x to 2d7d6702c8aab1fbb25ab660f3432062fa564e10 (refs/heads/2.x)
2024-01-04 00:47:30 INFO     No commit difference found between any components. Skipping the build

Copy link
Member

@gaiksaya gaiksaya left a comment

Choose a reason for hiding this comment

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

LGTM! Great enhancement @zelinh 👏

Copy link
Member

@peterzhuamazon peterzhuamazon left a comment

Choose a reason for hiding this comment

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

Thanks @zelinh , please open the improvement issue related to both parameters when you have time.

Thanks.

@zelinh zelinh merged commit 810f742 into opensearch-project:main Jan 4, 2024
13 checks passed
@zelinh zelinh deleted the build_incremental branch January 4, 2024 01:29
@zelinh
Copy link
Member Author

zelinh commented Jan 4, 2024

Issue created here as we discussed. #4320

@zelinh zelinh self-assigned this Jan 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants