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

Compile yaml integration and parse correctly #168

Merged
merged 59 commits into from
Sep 30, 2024
Merged

Conversation

singhd789
Copy link
Collaborator

@singhd789 singhd789 commented Aug 23, 2024

Describe your changes

  • Integrate the am5 model and compile yamls with the model yaml created for fre pp.
  • reworking parsing scripts in fremake to get correct information from a combined yaml

Issue ticket number and link (if applicable)

Associated with issue #141

Checklist before requesting a review

  • I ran my code
  • I tried to make my code readable
  • I tried to comment my code
  • I wrote a new test, if applicable
  • I wrote new instructions/documentation, if applicable
  • I ran pytest and inspected it's output
  • I ran pylint and attempted to implement some of it's feedback

- this is for later organization and parsing when yamls are combined
- another `-e` option was added to represent the experiment name
- combine model, compile, and platform yaml
- parse combined yaml
- added `-e` experiment and `--execute` options
- redefine variables with parsed information
- createCheckout: fix checkout script running if `--execute` used and checkour script already created
- this is done in the separate tool `combine-yamls`
- certain variables were overwritten when bind mode is implemented
- these variables are saved in `BACKUP` variables
@singhd789 singhd789 marked this pull request as ready for review August 30, 2024 14:17
@singhd789
Copy link
Collaborator Author

@singhd789 singhd789 marked this pull request as draft August 30, 2024 14:37
- combine-yamls here if tool wasn't used
- reflects changes in `fre yamltools combine-yamls`
- references defined `init_pp_yamls` class in `combine-yamls` to make combining a default behavior (on top of tool still being available if user wants to combine separately)
- update schema.json for pp combined yaml
- new test for validation of combiend yamls
- new fail test for if compile yaml path not correct
- new fail test for if a value in the compile.yaml is not of right data type
@rem1776 rem1776 mentioned this pull request Sep 16, 2024
7 tasks
# If fre yammltools combine-yamls tools was used, the combined yaml should exist
if Path(combined_path).exists():
full_combined = combined_path
print("\nNOTE: Yamls previously merged.")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can the combined yaml be overwritten each time, maybe with a message?

It seems like fre pp configure-yaml -y am5.yaml should configure the pp workflow based on the am5.yaml but it won't if the combined- file is there.

Copy link
Collaborator Author

@singhd789 singhd789 Sep 20, 2024

Choose a reason for hiding this comment

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

Yeah, I started to look into making it rewrite as a default, but if we wanted to keep the functionality for a user to use the tool by itself first (fre yamltools combine-yaml), the combined yaml will already exist. Maybe we keep the creating/rewriting of the yaml as a default behavior (in compilation and pp), then have the actual tool itself just be a check of some sorts. Like if someone just wanted to see what the combined yaml would output (without doing any compilation or post-processing).

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks, that sounds good. Another option would be to compare the combined- yaml to the one that would be re-created and give a message whether it has changed or is up-to-date.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oooo yeah, we could do that as well! Maybe that could be a small change in another PR. I'm pretty comfortable making it rewrite as a default behavior in this one, then making a small edit to compare yamls in another

- there was a false success with the previous schema
- update paths in test script based on reorganizations
- update test_combine_yamls for validation test, wrong compile file test, wrong data type (invalid yaml) test
Copy link
Member

@thomas-robinson thomas-robinson left a comment

Choose a reason for hiding this comment

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

We need a README.

Address the comments and we should be good.

fre/make/createDocker.py Show resolved Hide resolved
fre/make/createCompile.py Outdated Show resolved Hide resolved
fre/make/createDocker.py Outdated Show resolved Hide resolved
fre/make/createMakefile.py Outdated Show resolved Hide resolved
fre/make/createMakefile.py Outdated Show resolved Hide resolved
Comment on lines +46 to +132
def __init__(self,compileinfo):
"""
Brief: Read get the compile yaml and fill in the missing pieces
Param:
- self the compile Yaml object
- compileinfo dictionary with compile information from the combined yaml
"""
# compile information from the combined yaml
self.yaml = compileinfo

## Check the yaml for required things
## Check for required experiment name
try:
self.yaml["experiment"]
except:
print("You must set an experiment name to compile \n")
raise
## Check for optional libraries and packages for linking in container
try:
self.yaml["container_addlibs"]
except:
self.yaml["container_addlibs"]=""
## Check for optional libraries and packages for linking on bare-metal system
try:
self.yaml["baremetal_linkerflags"]
except:
self.yaml["baremetal_linkerflags"]=""
## Check for required src
try:
self.yaml["src"]
except:
print("You must set a src to specify the sources in modelRoot/"+self.yaml["experiment"]+"\n")
raise
## Loop through the src array
for c in self.yaml['src']:
## Check for required componenet name
try:
c['component']
except:
print("You must set the 'componet' name for each src component")
raise
## Check for required repo url
try:
c['repo']
except:
print("'repo' is missing from the component "+c['component']+" in "+self.yaml["experiment"]+"\n")
raise
# Check for optional branch. Otherwise set it to blank
try:
c['branch']
except:
c['branch']=""
# Check for optional cppdefs. Otherwise set it to blank
try:
c['cppdefs']
except:
c['cppdefs']=""
# Check for optional doF90Cpp. Otherwise set it to False
try:
c['doF90Cpp']
except:
c['doF90Cpp']=False
# Check for optional additional instructions. Otherwise set it to blank
try:
c['additionalInstructions']
except:
c['additionalInstructions']=""
# Check for optional paths. Otherwise set it to blank
try:
c['paths']
except:
c['paths']=[c['component']]
# Check for optional requires. Otherwise set it to blank
try:
c['requires']
except:
c['requires']=[]
# Check for optional overrides. Otherwise set it to blank
try:
c['makeOverrides']
except:
c['makeOverrides']=""
# Check for optional flags. Otherwise set it to blank.
try:
c["otherFlags"]
except:
c["otherFlags"]=""
Copy link
Member

Choose a reason for hiding this comment

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

The sad situation of someone else having to clean up an inexperienced python coder's mess :-(

fre/make/runFremake.py Outdated Show resolved Hide resolved
fre/yamltools/combine_yamls.py Show resolved Hide resolved

with open(combined,'w',encoding='UTF-8') as f:
yaml.safe_dump(full_yaml,f,sort_keys=False)
if use == "compile":
Copy link
Member

Choose a reason for hiding this comment

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

im not convinced this is the best variable name here. maybe we can bring it up at a fre meeting.

fre/yamltools/freyamltools.py Show resolved Hide resolved
@singhd789
Copy link
Collaborator Author

fremake README going to be pushed here: issue #187

@ceblanton
Copy link
Collaborator

All the tests pass, except one with a known cause, and a clear issue to track (#189).

FAILED fre/tests/test_fre_catalog_cli.py::test_cli_fre_catalog_builder - assert False

  • where False = all([True, False])

@ilaflott
Copy link
Member

it's weird that this PR messes with fre/tests/test_fre_cmor_cli.py, is there any aggressive test-file clean up happening in this PR? This test passes in main

@singhd789
Copy link
Collaborator Author

it's weird that this PR messes with fre/tests/test_fre_cmor_cli.py, is there any aggressive test-file clean up happening in this PR? This test passes in main

Not pertaining to test_fre_cmor_cli.py, I don't think. I'm about to check if I have to update my branch from main at all.

@ilaflott
Copy link
Member

looks good, merging!

@ilaflott ilaflott merged commit a283e9a into main Sep 30, 2024
2 checks passed
@ilaflott ilaflott deleted the 141.am5-yaml-integration branch September 30, 2024 13:56
This was linked to issues Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Yaml parsing errors with esm4.yaml Fremake yaml integration
4 participants