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
Reorganize env and product yaml #6754
Reorganize env and product yaml #6754
Conversation
Hello @yuumasato! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found: There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2021-04-29 13:09:56 UTC |
Changes identified: Show detailsOthers: Recommended tests to execute: |
Does this reorg make sense? |
Skipping CI for Draft Pull Request. |
31fce83
to
3042004
Compare
5b4ccbb
to
0dc3f4b
Compare
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.
Looks good, thank you. This is important work. It seems that it builds correctly.
There are some notices from pep8 bot, could you check it please?
Also there has been another utility merged recently - render-rules.py. Is it also affected?
@@ -54,7 +54,7 @@ def get_env_yaml(build_config_yaml, product_yaml): | |||
if build_config_yaml is None or product_yaml is None: | |||
return None | |||
|
|||
env_yaml = ssg.yaml.open_environment(build_config_yaml, product_yaml) | |||
env_yaml = ssg.environment.open_environment(build_config_yaml, product_yaml) |
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 notice that in other files where you did this change, you also altered the import statement. Here you did not. Nothing seems to break during build, but I rather ask.
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.
The script didn't have an import
for the yaml
module. So I just followed the same format and replaced ssg.yaml
with ssg.environment
.
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 happens because ssg.build_yaml
already imports ssg.{yaml->environment}
and so you don't strictly need to duplicate the import.
0b032aa
to
87b6c3a
Compare
/retest |
Seems that there is a problem with platform called ocp4.8. |
ssg/products.py
Outdated
return result | ||
|
||
|
||
def get_product_yaml(product_yaml_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.
Edit: I can't read, ssg.environment
was added with open_environment
which does what question one asks.
Two One question here:
Does this need to be tempered by the build YAML? If you look at e.g.,:combine_ovals.py
env_yaml = ssg.yaml.open_environment(args.build_config_yaml, args.product_yaml)
- Would something like
load_product_yaml
be clearer? Especially if we add aget_product_yaml_path(product)
-- we could make the product YAML path be inferred by the actual product. Just a thought.
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 like the idea of the two functions.
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 will actually lead to too many changes...I'd like to do this in a subsequent PR, and discuss some of the changes.
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 just renamed the current function to load_product_yaml
.
@@ -171,7 +173,9 @@ def _get_platform_cpes(platform): | |||
raise ValueError | |||
platform_cpes = set() | |||
for p in products: | |||
p_cpes = ProductCPEs(p) | |||
product_yaml_path = os.path.join(ssg_root, p, "product.yml") |
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.
Here's where I was thinking a get_product_yaml(product)
form would be most useful. Then it would be load_product_yaml(path)
elsewhere. My 2c.
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 probably should've batched into a review but then I kept looking :-)
I didn't follow all the changes in build_yaml.py
but otherwise looks good to me. Will let others do the final review and go-ahead, seems like there's still a build failure possibly and some conflicts?
Separate into products.py functions that are related to products, including checking its data and deriving properties. Relocate open_environment() away from yaml.py, this function is more about loading build environment configurations than yaml loading per se. This should ease the life of scripts to only want to load data from the product, but don't care about the environment. (How dare we have scripts that are not eco friendly?) Note: this commit breaks the build as other scripts need to be updated. It is done as a separate commit to help understand the changes.
This commits just follows the previous commit, in which env and product yaml were decoupled.
This moves incorporation of CPE names into the loading process, opposed to during oputput process. We should be information complete once we are "loaded". The product_yaml should contain data for the product being built, accessibility of ProductCPEs from product_yaml makes for cleaner code and more easily expandable.
87b6c3a
to
81d53dc
Compare
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.
Thank you for the review, folks.
I've just rebased to fix the conflict, and addressed the build issue with platform ocp-4.8
ssg/products.py
Outdated
return result | ||
|
||
|
||
def get_product_yaml(product_yaml_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 like the idea of the two functions.
@cipherboy @vojtapolasek This is ready to merge if your reviews are still positive. I'll look into adding |
/retest |
1520544
to
1c856aa
Compare
A rule can be loaded from yaml in any context, even when building unrelated products. A rule is completely loaded, and then its prodtype is assessed against the product being built. This limits the conversion of platform names to cpe names to situations where the rule is compatible with the product.
1c856aa
to
756abee
Compare
/retest |
Since ComplianceAsCode#6754 was merged before ComplianceAsCode#6906's last update (and before ComplianceAsCode#6906 was merged), it missed the move of ssg.yaml.open_environment into ssg.environment.open_environment. This fixes autoprodtyper.py to understand the new location of this function. Signed-off-by: Alexander Scheel <alex.scheel@canonical.com>
Description:
env_yaml
and theproduct_yaml
.product_cpes
toget_product_yaml()
.Rationale:
open_environment()