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
Show file tree
Hide file tree
Changes from 53 commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
eec3239
#141 Add fremake model yaml info to standard model yaml created (for…
singhd789 Aug 14, 2024
b7df975
#141 Put compile info under `compile` section
singhd789 Aug 14, 2024
c4248e3
#141 Redefine `fre_properties` using reusable yaml variables
singhd789 Aug 14, 2024
0350674
#141 Change `-e` option to `--execute`
singhd789 Aug 14, 2024
1b445e9
#141 Fix combining and parsing yamls
singhd789 Aug 14, 2024
eb67d23
#141 Rework code that saves parsed yaml info
singhd789 Aug 14, 2024
43de62d
Merge branch 'main' of github.com:NOAA-GFDL/fre-cli into 141.am5-yaml…
singhd789 Aug 23, 2024
32ad88b
#141 Remove combining yamls functionality from `yamlfre.py`
singhd789 Aug 26, 2024
a4c8df1
#141 Update parsing information from combined yaml
singhd789 Aug 26, 2024
86e5b72
#141 Update runscript for container
singhd789 Aug 26, 2024
975094b
#141 Update platforms yaml path
singhd789 Aug 26, 2024
b612f80
#141 Add test yaml files
singhd789 Aug 26, 2024
03db8ba
#141 Fix up pylint messages
singhd789 Aug 27, 2024
31bc40c
Merge branch 'main' of github.com:NOAA-GFDL/fre-cli into 141.am5-yaml…
singhd789 Aug 27, 2024
c9cf806
#141 Add freVars object
singhd789 Aug 30, 2024
96bfcf3
#141 Use freVars object to parse and fill in missing info
singhd789 Aug 30, 2024
cf8c89c
#141 Update README
singhd789 Aug 30, 2024
36860a9
#141 Update schema for combined yaml
singhd789 Sep 4, 2024
309b59f
#141 Reference class or use of combine-yamls tool
singhd789 Sep 4, 2024
be9e821
#141 Add validation of yaml
singhd789 Sep 4, 2024
999d70d
#141 Update example yamls
singhd789 Sep 4, 2024
f553b20
#141 Add yaml validation
singhd789 Sep 4, 2024
86cbc87
#141 Fix combining yamls and validation
singhd789 Sep 4, 2024
d36233f
#141 Update messages and where validation happens
singhd789 Sep 4, 2024
ac18852
#141 Fix where validation happens
singhd789 Sep 4, 2024
569de41
#141 Create classes for combining yamls
singhd789 Sep 4, 2024
c03a35b
#141 Clean `createDocker.py`
singhd789 Sep 4, 2024
ba2fa1a
#141 Update outfile for `configire_script_yaml`
singhd789 Sep 4, 2024
5ddfefd
#141 Fix `configure_script_yaml` test
singhd789 Sep 4, 2024
7069840
#141 Add combine yamls functionality in `runFremake` tool
singhd789 Sep 4, 2024
721395c
#141 Add parenthesis
singhd789 Sep 4, 2024
82c8a3a
#141 Remove `-e`,`--experiment` from compile tools
singhd789 Sep 5, 2024
62362d3
#141 Make `build` a separate section
singhd789 Sep 5, 2024
5257265
#141 Combine compile and platform yamls without `experiment`
singhd789 Sep 5, 2024
6923b63
#141 Create `--use` functionality
singhd789 Sep 5, 2024
ff90e16
#141 Update `fre yamltools combine-yamls` test
singhd789 Sep 5, 2024
b4d456a
#141 Symlink runscript to more general location in container
singhd789 Sep 9, 2024
644e64d
#141 Remove README for now (will update)
singhd789 Sep 10, 2024
1256ec5
#141 Create separate function to combine yamls
singhd789 Sep 10, 2024
417c326
#141 Remove unnecessary comments
singhd789 Sep 10, 2024
043136f
#141 Fix combining in configure_script_yaml
singhd789 Sep 10, 2024
ad44ce2
#141 Add comments and change `print` statements to `raise Exception`
singhd789 Sep 10, 2024
cf5bc42
#141 Make variable and comments more helpful
singhd789 Sep 10, 2024
b036488
#141 Initialize the init_compile_yaml and init_pp_yaml objects befor…
Sep 10, 2024
ec63d02
#141 Reorganize test yamls
singhd789 Sep 13, 2024
9976464
#141 Fix paths and add test cases
singhd789 Sep 13, 2024
579f34e
#141 Fix error checking
singhd789 Sep 13, 2024
dd6cff8
#141 Fix location
singhd789 Sep 13, 2024
3d330f0
#141 Combine yamls/rewrite combined yaml as default behavior
singhd789 Sep 23, 2024
7c79554
#141 Update schema for validation (compilation yamls)
singhd789 Sep 23, 2024
f333294
#141 Reorganize test yamls and update tests
singhd789 Sep 23, 2024
77e123c
#141 Wrap code in function and add error check
singhd789 Sep 25, 2024
5736653
#141 Set acceptable values for click option
singhd789 Sep 25, 2024
fd2d8fc
Add pathlib import
singhd789 Sep 27, 2024
1b809ac
Merge remote-tracking branch 'origin/main' into 141.am5-yaml-integration
Sep 27, 2024
e1424e0
Merge remote-tracking branch 'origin/main' into 141.am5-yaml-integration
Sep 27, 2024
e2cfbea
Merge branch 'main' of github.com:NOAA-GFDL/fre-cli into 141.am5-yaml…
singhd789 Sep 27, 2024
f48c7ab
#141 Update yaml test to chdir back to original pytest directory.
Sep 27, 2024
d27a4bc
#141 Add one more chdir back to original working directory
Sep 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
155 changes: 0 additions & 155 deletions fre/make/README.md

This file was deleted.

45 changes: 32 additions & 13 deletions fre/make/createCheckout.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
#!/usr/bin/python3

import os
import subprocess
import logging
import sys
import click
from pathlib import Path
from .gfdlfremake import varsfre, platformfre, yamlfre, checkout, targetfre
import fre.yamltools.combine_yamls as cy

@click.command()
def checkout_create(yamlfile,platform,target,no_parallel_checkout,jobs,execute,verbose):
# Define variables
yml = yamlfile
ps = platform
ts = target
name = yamlfile.split(".")[0]
run = execute
jobs = str(jobs)
pcheck = no_parallel_checkout
Expand All @@ -34,11 +36,16 @@ def checkout_create(yamlfile,platform,target,no_parallel_checkout,jobs,execute,v
plist = platform
tlist = target

# Combine model, compile, and platform yamls
# Default behavior - combine yamls / rewrite combined yaml
comb = cy.init_compile_yaml(yml,platform,target)
full_combined = cy.get_combined_compileyaml(comb)

## Get the variables in the model yaml
freVars = varsfre.frevars(yml)
freVars = varsfre.frevars(full_combined)

## Open the yaml file and parse as fremakeYaml
modelYaml = yamlfre.freyaml(yml,freVars)
## Open the yaml file, validate the yaml, and parse as fremakeYaml
modelYaml = yamlfre.freyaml(full_combined,freVars)
fremakeYaml = modelYaml.getCompileYaml()

## Error checking the targets
Expand All @@ -53,7 +60,7 @@ def checkout_create(yamlfile,platform,target,no_parallel_checkout,jobs,execute,v
if modelYaml.platforms.hasPlatform(platformName):
pass
else:
raise SystemExit (platformName + " does not exist in " + modelYaml.platformsfile)
raise ValueError (platformName + " does not exist in platforms.yaml")
(compiler,modules,modulesInit,fc,cc,modelRoot,iscontainer,mkTemplate,containerBuild,ContainerRun,RUNenv)=modelYaml.platforms.getPlatformFromName(platformName)

## Create the source directory for the platform
Expand All @@ -67,22 +74,34 @@ def checkout_create(yamlfile,platform,target,no_parallel_checkout,jobs,execute,v
freCheckout = checkout.checkout("checkout.sh",srcDir)
freCheckout.writeCheckout(modelYaml.compile.getCompileYaml(),jobs,pc)
freCheckout.finish(pc)
click.echo("\nCheckout script created at " + srcDir + "/checkout.sh" + "\n")
click.echo("\nCheckout script created in "+ srcDir + "/checkout.sh \n")

# Run the checkout script
if run:
freCheckout.run()
# Run the checkout script
if run == True:
freCheckout.run()
else:
sys.exit()
thomas-robinson marked this conversation as resolved.
Show resolved Hide resolved
else:
sys.exit()
print("\nCheckout script PREVIOUSLY created in "+ srcDir + "/checkout.sh \n")
if run == True:
os.chmod(srcDir+"/checkout.sh", 0o744)
try:
subprocess.run(args=[srcDir+"/checkout.sh"], check=True)
except:
print("\nThere was an error with the checkout script "+srcDir+"/checkout.sh.",
"\nTry removing test folder: " + modelRoot +"\n")
raise
else:
sys.exit()

else:
## Run the checkout script
image="ecpe4s/noaa-intel-prototype:2023.09.25"
bldDir = modelRoot + "/" + fremakeYaml["experiment"] + "/exec"
tmpDir = "tmp/"+platformName
freCheckout = checkout.checkoutForContainer("checkout.sh", srcDir, tmpDir)
freCheckout.writeCheckout(modelYaml.compile.getCompileYaml(),jobs,pc)
freCheckout.finish(pc)
click.echo("\nCheckout script created at " + srcDir + "/checkout.sh" + "\n")
click.echo("\nCheckout script created at " + tmpDir + "/checkout.sh" + "\n")
singhd789 marked this conversation as resolved.
Show resolved Hide resolved


if __name__ == "__main__":
Expand Down
20 changes: 14 additions & 6 deletions fre/make/createCompile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
import os
import sys
import logging
from pathlib import Path
from multiprocessing.dummy import Pool

import click
from .gfdlfremake import varsfre, platformfre, yamlfre, targetfre, buildBaremetal
import fre.yamltools.combine_yamls as cy

@click.command()
def compile_create(yamlfile,platform,target,jobs,parallel,execute,verbose):
# Define variables
yml = yamlfile
ps = platform
ts = target
name = yamlfile.split(".")[0]
nparallel = parallel
jobs = str(jobs)
run = execute
Expand All @@ -31,11 +31,18 @@ def compile_create(yamlfile,platform,target,jobs,parallel,execute,verbose):
plist = platform
tlist = target

# Combined compile yaml file
combined = Path(f"combined-{name}.yaml")

## If combined yaml exists, note message of its existence
## If combined yaml does not exist, combine model, compile, and platform yamls
full_combined = cy.combined_compile_existcheck(combined,yml,platform,target)

## Get the variables in the model yaml
freVars = varsfre.frevars(yml)
freVars = varsfre.frevars(full_combined)

## Open the yaml file and parse as fremakeYaml
modelYaml = yamlfre.freyaml(yml,freVars)
modelYaml = yamlfre.freyaml(full_combined,freVars)
fremakeYaml = modelYaml.getCompileYaml()

## Error checking the targets
Expand All @@ -50,7 +57,8 @@ def compile_create(yamlfile,platform,target,jobs,parallel,execute,verbose):
if modelYaml.platforms.hasPlatform(platformName):
pass
else:
raise SystemExit (platformName + " does not exist in " + modelYaml.platformsfile)
raise ValueError (platformName + " does not exist in " + modelYaml.combined.get("compile").get("platformYaml"))

(compiler,modules,modulesInit,fc,cc,modelRoot,iscontainer,mkTemplate,containerBuild,ContainerRun,RUNenv)=modelYaml.platforms.getPlatformFromName(platformName)
## Make the bldDir based on the modelRoot, the platform, and the target
srcDir = modelRoot + "/" + fremakeYaml["experiment"] + "/src"
Expand Down
39 changes: 19 additions & 20 deletions fre/make/createDocker.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,35 @@

import os
import sys
from pathlib import Path
import click
from .gfdlfremake import varsfre, targetfre, makefilefre, platformfre, yamlfre, buildDocker
import fre.yamltools.combine_yamls as cy

@click.command()
def dockerfile_create(yamlfile, platform, target, execute):
def dockerfile_create(yamlfile,platform,target,execute):
srcDir="src"
checkoutScriptName = "checkout.sh"
baremetalRun = False # This is needed if there are no bare metal runs
## Split and store the platforms and targets in a list
plist = platform
tlist = target
yml = yamlfile
name = yamlfile.split(".")[0]
run = execute

# Combined compile yaml file
combined = Path(f"combined-{name}.yaml")

## If combined yaml exists, note message of its existence
## If combined yaml does not exist, combine model, compile, and platform yamls
full_combined = cy.combined_compile_existcheck(combined,yml,platform,target)

singhd789 marked this conversation as resolved.
Show resolved Hide resolved
## Get the variables in the model yaml
freVars = varsfre.frevars(yml)
freVars = varsfre.frevars(full_combined)

## Open the yaml file and parse as fremakeYaml
modelYaml = yamlfre.freyaml(yml,freVars)
modelYaml = yamlfre.freyaml(full_combined,freVars)
fremakeYaml = modelYaml.getCompileYaml()

fremakeBuildList = []
Expand All @@ -30,7 +41,7 @@ def dockerfile_create(yamlfile, platform, target, execute):
if modelYaml.platforms.hasPlatform(platformName):
pass
else:
raise SystemExit (platformName + " does not exist in " + modelYaml.platformsfile)
raise ValueError (platformName + " does not exist in " + modelYaml.combined.get("compile").get("platformYaml"))

(compiler,modules,modulesInit,fc,cc,modelRoot,iscontainer,mkTemplate,containerBuild,containerRun,RUNenv)=modelYaml.platforms.getPlatformFromName(platformName)

Expand All @@ -42,33 +53,21 @@ def dockerfile_create(yamlfile, platform, target, execute):
bldDir = modelRoot + "/" + fremakeYaml["experiment"] + "/exec"
tmpDir = "tmp/"+platformName

freMakefile = makefilefre.makefileContainer(exp = fremakeYaml["experiment"],
libs = fremakeYaml["container_addlibs"],
srcDir = srcDir,
bldDir = bldDir,
mkTemplatePath = mkTemplate,
tmpDir = tmpDir)

# Loop through components and send the component name and requires for the Makefile
for c in fremakeYaml['src']:
freMakefile.addComponent(c['component'],c['requires'],c['makeOverrides'])
freMakefile.writeMakefile()

dockerBuild = buildDocker.container(base = image,
exp = fremakeYaml["experiment"],
libs = fremakeYaml["container_addlibs"],
RUNenv = RUNenv,
target = targetObject)
dockerBuild.writeDockerfileCheckout("checkout.sh", tmpDir+"/checkout.sh")
dockerBuild.writeDockerfileMakefile(freMakefile.getTmpDir() + "/Makefile", freMakefile.getTmpDir()+"/linkline.sh")
dockerBuild.writeDockerfileMakefile(tmpDir+"/Makefile", tmpDir+"/linkline.sh")

for c in fremakeYaml['src']:
dockerBuild.writeDockerfileMkmf(c)

dockerBuild.writeRunscript(RUNenv,containerRun,tmpDir+"/execrunscript.sh")

currDir = os.getcwd()
click.echo("\ntmpDir created at " + currDir + "/tmp")
click.echo("Dockerfile created at " + currDir + "\n")
click.echo("\ntmpDir created in " + currDir + "/tmp")
click.echo("Dockerfile created in " + currDir +"\n")

if run:
dockerBuild.build(containerBuild, containerRun)
Expand Down
Loading
Loading