-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #248 from NOAA-GFDL/223.fre-make-makefile-test
223.fre make makefile test
- Loading branch information
Showing
5 changed files
with
102 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
""" | ||
Test fre make create-makefile | ||
""" | ||
import os | ||
import shutil | ||
from pathlib import Path | ||
from fre.make import createMakefile | ||
|
||
# SET-UP | ||
test_dir = Path("fre/make/tests") | ||
NM_EXAMPLE = Path("null_example") | ||
YAMLFILE = "null_model.yaml" | ||
BM_PLATFORM = ["ncrc5.intel23"] | ||
CONTAINER_PLATFORM = ["hpcme.2023"] | ||
TARGET = ["debug"] | ||
EXPERIMENT = "null_model_full" | ||
|
||
# Create output location | ||
out = f"{test_dir}/makefile_out" | ||
if Path(out).exists(): | ||
# remove | ||
shutil.rmtree(out) | ||
# create output directory | ||
Path(out).mkdir(parents=True,exist_ok=True) | ||
else: | ||
Path(out).mkdir(parents=True,exist_ok=True) | ||
|
||
# Set output directory as home for fre make output | ||
#os.environ["HOME"]=str(Path(out)) | ||
|
||
def test_modelyaml_exists(): | ||
""" | ||
Check the model yaml exists | ||
""" | ||
assert Path(f"{test_dir}/{NM_EXAMPLE}/{YAMLFILE}").exists() | ||
|
||
def test_compileyaml_exists(): | ||
""" | ||
Check the compile yaml exists | ||
""" | ||
assert Path(f"{test_dir}/{NM_EXAMPLE}/compile.yaml").exists() | ||
|
||
def test_platformyaml_exists(): | ||
""" | ||
Check the platform yaml exists | ||
""" | ||
assert Path(f"{test_dir}/{NM_EXAMPLE}/platforms.yaml").exists() | ||
|
||
def test_bm_makefile_creation(): | ||
""" | ||
Check the makefile is created when a bare-metal platform is used | ||
""" | ||
# Set output directory as home for fre make output | ||
os.environ["HOME"]=str(Path(out)) | ||
|
||
bm_plat = BM_PLATFORM[0] | ||
targ = TARGET[0] | ||
yamlfile_path = f"{test_dir}/{NM_EXAMPLE}/{YAMLFILE}" | ||
|
||
createMakefile.makefile_create(yamlfile_path,BM_PLATFORM,TARGET) | ||
|
||
assert Path(f"{out}/fremake_canopy/test/{EXPERIMENT}/{bm_plat}-{targ}/exec/Makefile").exists() | ||
|
||
def test_container_makefile_creation(): | ||
""" | ||
Check the makefile is created when the container platform is used | ||
""" | ||
container_plat = CONTAINER_PLATFORM[0] | ||
yamlfile_path = f"{test_dir}/{NM_EXAMPLE}/{YAMLFILE}" | ||
createMakefile.makefile_create(yamlfile_path,CONTAINER_PLATFORM,TARGET) | ||
|
||
assert Path(f"tmp/{container_plat}/Makefile").exists() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,46 @@ | ||
""" | ||
Test configure_script_yaml | ||
""" | ||
import os | ||
from pathlib import Path | ||
from fre.pp import configure_script_yaml as csy | ||
|
||
# Set what would be click options | ||
experiment = "c96L65_am5f7b12r1_amip" | ||
platform = "gfdl.ncrc5-intel22-classic" | ||
target = "prod-openmp" | ||
EXPERIMENT = "c96L65_am5f7b12r1_amip" | ||
PLATFORM = "gfdl.ncrc5-intel22-classic" | ||
TARGET = "prod-openmp" | ||
|
||
# Set example yaml paths, input directory | ||
CWD = Path.cwd() | ||
test_dir = Path("fre/pp/tests") | ||
test_yaml = Path(f"AM5_example/am5.yaml") | ||
|
||
# Set home for ~/cylc-src location in script | ||
os.environ["HOME"]=str(Path(f"{CWD}/{test_dir}/configure_yaml_out")) | ||
test_yaml = Path("AM5_example/am5.yaml") | ||
|
||
def test_combinedyaml_exists(): | ||
""" | ||
Make sure combined yaml file exists | ||
""" | ||
assert Path(f"{CWD}/{test_dir}/{test_yaml}").exists() | ||
assert Path(f"{test_dir}/{test_yaml}").exists() | ||
|
||
def test_configure_script(): | ||
""" | ||
Tests success of confgure yaml script | ||
Creates rose-suite, regrid rose-app, remap rose-app | ||
TO-DO: will break this up for better tests | ||
""" | ||
os.chdir(f"{CWD}/{test_dir}/AM5_example") | ||
# Set home for ~/cylc-src location in script | ||
os.environ["HOME"]=str(Path(f"{test_dir}/configure_yaml_out")) | ||
|
||
# Set output directory | ||
out_dir = Path(f"{os.getenv('HOME')}/cylc-src/{experiment}__{platform}__{target}") | ||
out_dir = Path(f"{os.getenv('HOME')}/cylc-src/{EXPERIMENT}__{PLATFORM}__{TARGET}") | ||
Path(out_dir).mkdir(parents=True,exist_ok=True) | ||
|
||
# Define combined yaml | ||
model_yaml = str(Path(f"{CWD}/{test_dir}/{test_yaml}")) | ||
model_yaml = str(Path(f"{test_dir}/{test_yaml}")) | ||
|
||
# Invoke configure_yaml_script.py | ||
csy._yamlInfo(model_yaml,experiment,platform,target) | ||
csy.yamlInfo(model_yaml,EXPERIMENT,PLATFORM,TARGET) | ||
|
||
# Check for configuration creation and final combined yaml | ||
assert all([Path(f"{out_dir}/{experiment}.yaml").exists(), | ||
assert all([Path(f"{out_dir}/{EXPERIMENT}.yaml").exists(), | ||
Path(f"{out_dir}/rose-suite.conf").exists(), | ||
Path(f"{out_dir}/app/regrid-xy/rose-app.conf").exists(), | ||
Path(f"{out_dir}/app/remap-pp-components/rose-app.conf").exists()]) | ||
|
||
# Go back to original directory | ||
os.chdir(CWD) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters