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

CTests extended validation for C48_ATM and staged C48_S2SW for gfs_fcst and gfs_atmos #3256

Open
wants to merge 215 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 211 commits
Commits
Show all changes
215 commits
Select commit Hold shift + click to select a range
987ae5b
added ctest dir with cmake to create an experment
Dec 6, 2024
61fcf83
added CMakeLists for creating initial case EXPDIR usint ctest
Dec 6, 2024
f5f6595
ready to test getting the job names
Dec 6, 2024
cbe3bab
move all operations of creating EXPDIR cases into configure phase
Dec 6, 2024
6a50e14
got cmake configure to work for EXPDIR
Dec 6, 2024
bcebeca
can not do both file and variable save for execute_process
Dec 6, 2024
be7a890
working cmake config up to output of job names
Dec 6, 2024
2811629
Merge branch 'NOAA-EMC:develop' into ctest_jjobs_framework
TerrenceMcGuinness-NOAA Dec 9, 2024
70a8183
loop over jobnames and create an experment for each
Dec 9, 2024
72e5a9c
update JOB name update in loop
Dec 9, 2024
1f1fcd6
addded debug outputs
Dec 9, 2024
ee27b02
modifying plslot list to be only on a per case
Dec 9, 2024
bc76ddf
filter pslot list for only relevent cases
Dec 9, 2024
38838a6
refining get_job_names
Dec 9, 2024
d18ad01
modigied get_jobs_names to task and metatask names
Dec 9, 2024
ef0e066
got better jobname parcer working
Dec 9, 2024
519a919
Merge branch 'NOAA-EMC:develop' into ctest_jjobs_framework
TerrenceMcGuinness-NOAA Dec 9, 2024
f813a1b
replaced generate_workflows with create_experment
Dec 10, 2024
8238228
removed non-existing ENVIRONMENT setting to consolated COMMAND line
Dec 10, 2024
bf579ee
got cmake script to use creat_experiment
Dec 10, 2024
28ef1af
Merge branch 'NOAA-EMC:develop' into ctest_jjobs_framework
TerrenceMcGuinness-NOAA Dec 12, 2024
374927f
just getting started with addeding a ctest
Dec 12, 2024
8b4fc4f
add in test for configured project
Dec 12, 2024
ce37d86
added ctest and testing
Dec 12, 2024
d4e3266
Merge branch 'NOAA-EMC:develop' into ctest_jjobs_framework
TerrenceMcGuinness-NOAA Dec 13, 2024
bb12cda
moved ctests dir to top HOMEgfs/ci/ctests with its own scripts dir
Dec 13, 2024
f78181c
added all jobs for tests for each case
Dec 13, 2024
46cddb7
added data stagging dependances and started it as a stub script
Dec 14, 2024
d6c3a49
Merge branch 'NOAA-EMC:develop' into ctest_jjobs_framework
TerrenceMcGuinness-NOAA Dec 16, 2024
434f869
added driver for creating ctests from yaml files
Dec 18, 2024
99df88d
added a driver to create ctests from defintions in yaml files
Dec 18, 2024
e186173
added final step to loop over yaml files for creating functiona ctest…
Dec 18, 2024
c4a2780
Merge branch 'NOAA-EMC:develop' into ctest_jjobs_framework
TerrenceMcGuinness-NOAA Dec 19, 2024
0183667
added second yaml case file for testing python driver
Dec 19, 2024
3088bff
added a few comments for each section
Dec 19, 2024
9d06df7
Merge branch 'NOAA-EMC:develop' into ctest_jjobs_framework
TerrenceMcGuinness-NOAA Dec 20, 2024
674f8d6
made CMakeList.txt independent of python script
Dec 20, 2024
68ca6ee
simplified CMakeList to be compatible with manin build, consolated cr…
Dec 20, 2024
f7bbd40
repurposed python script for generating args to man CMakeLists.txt
Dec 20, 2024
36d497e
added lables to run tests in groups and added stubbed scripts
Dec 20, 2024
808a4cf
created script and cases dir to isolate CMakeLists.txt
Dec 20, 2024
81e640f
renamed test to create_experiment
Dec 20, 2024
a1d0f20
missed update to name of test from test_ to create_experiment_
Dec 20, 2024
2cbf4ee
forgot to save contents of the stubbed scripts
Dec 20, 2024
687217f
spelling error on create_experiment
Dec 20, 2024
55766bd
got a few hints on using File Utils directly in case Yaml file
Dec 20, 2024
f69fb68
updated adding functional test as line enteries in CMakeLists.txt dir…
Dec 23, 2024
3cc83c6
Cleaned up names to have Case and job name first
Dec 23, 2024
e1e1858
added file utils copy commands in gfs_fcst for C48_ATM
Dec 23, 2024
5ce988f
started on stage data python script
Dec 24, 2024
cefaccd
added exec line for python staging script
Dec 24, 2024
bec03d9
deleted space in yaml file for copy commands
Dec 24, 2024
5f9451b
Merge branch 'NOAA-EMC:develop' into ctest_jjobs_framework
TerrenceMcGuinness-NOAA Dec 26, 2024
74fbf45
removed extra $ on JOB var
Jan 2, 2025
19600f1
idate needed for PDY
Jan 2, 2025
2caa229
updated stage data with idate for PDY and HH and made sure paths wher…
Jan 2, 2025
749e54f
added copy using FIleHandler
Jan 2, 2025
75450e1
copy command needs quotes
Jan 2, 2025
0fc5d76
added sync() on file handler
Jan 2, 2025
ea01737
got FileUtil to work in stage data
Jan 2, 2025
e9c46f1
got started on execute
Jan 2, 2025
2602166
execute needed shabang and exit 0
Jan 2, 2025
1950af4
almost ready to launch execute.sh
Jan 2, 2025
c691c0e
Merge branch 'NOAA-EMC:develop' into ctest_jjobs_framework
TerrenceMcGuinness-NOAA Jan 3, 2025
276a9bd
added working skeleton bash script for execute using rocotoboot with …
Jan 3, 2025
283000e
added a few ICs that where missed
Jan 3, 2025
b2a6fec
removed extra scripts no longer used
Jan 3, 2025
9525c74
added defulted values and over rides from command line
Jan 3, 2025
74f7268
removed HOMEgfs for path to create expermient
Jan 3, 2025
5cd1c5f
removed another unused script
Jan 3, 2025
c132786
fixed a few path errors with HOMEgfs still hanging around
Jan 3, 2025
87674f2
Merge branch 'NOAA-EMC:develop' into ctest_jjobs_framework
TerrenceMcGuinness-NOAA Jan 6, 2025
e873722
added cmake_parse_arguments with extras and used inline template for …
Jan 6, 2025
32c5f87
added template for cmake tests setup.sh
Jan 6, 2025
128d0e6
had to add ARG_ header to labels names for depenancies for setup worked
Jan 6, 2025
abb2952
added bash wrapper to stage_data.py and made single job per yaml conf…
Jan 6, 2025
1d54caf
added the part to drop in templated inline script for stage.sh
Jan 6, 2025
2532576
getting stage.sh.in args to work for now
Jan 6, 2025
0967f10
still getting args straintened out with staging
Jan 6, 2025
8231519
added args in bash wrapper to stage.py to pick up ARG_CASE and ARG_JOB
Jan 7, 2025
30466b9
updated args to stage.py to simply take yaml input
Jan 7, 2025
3deeb41
had extra ) for updated add_test
Jan 7, 2025
099a2cb
removed reading of pr case file for getting idate
Jan 7, 2025
94dd64e
replaced JOB_CASE in path for inputs to TEST_NAME
Jan 7, 2025
a98d55d
updated path to yaml input to stage
Jan 7, 2025
29517e3
ctest dir is ctests in path to YAML file for stage.py
Jan 7, 2025
60a6136
finilized inputs to make stage.py to work without using CASE+JOB
Jan 7, 2025
b977e52
mnissed a couple or ARGS_ again this time in execute
Jan 7, 2025
95be9f2
ARG are prefixes in execute add test
Jan 7, 2025
e9b0b6a
ARG are prefixes in execute add test 2
Jan 7, 2025
a72827c
ARG are prefixes in execute add test 3
Jan 7, 2025
4f010a4
added MAKE_CURRENT_BINARY_DIR as templated VAR in stage
Jan 7, 2025
b79d445
made execute bash sript a template too
Jan 7, 2025
16cd19f
forgot to save CMakeLists now has updated call to excute from script …
Jan 7, 2025
fffb13d
last bug for working execute phase
Jan 7, 2025
5c5ac0f
ready to test x coders add for waiting for slurm job to complete
Jan 7, 2025
06c8e8f
do not need link to wxflow anymore, added it to PYTHONPATH in bash wr…
Jan 7, 2025
edde418
Merge branch 'NOAA-EMC:develop' into ctest_jjobs_framework
TerrenceMcGuinness-NOAA Jan 8, 2025
d68b02e
path to wxflow in PYTHONPATH was wrong in stage template
Jan 8, 2025
b0602bc
generlized ARG over-ride and added check for exectution success from …
Jan 8, 2025
30b3f3a
should have checked for End not END for success
Jan 8, 2025
42084e7
oops need done at then of loop in execute bash sript
Jan 8, 2025
8d71151
removed C48_S2SW.yaml for functional test as it is not ready yet
Jan 8, 2025
cf7be28
working on shellnorms
Jan 8, 2025
a49a642
working on more shellnorms
Jan 8, 2025
466831d
working on even more shellnorms
Jan 8, 2025
2d18461
working couple more shellnorms
Jan 8, 2025
53b13e3
Merge branch 'NOAA-EMC:develop' into ctest_jjobs_framework
TerrenceMcGuinness-NOAA Jan 10, 2025
4ee8d81
removed scripts used for getting system defaults and added top level …
Jan 10, 2025
b3518ca
added to yaml fun conf file to us jinja string modification TEST_DATE
Jan 10, 2025
54f633b
typos in CMakeLists and module file for adding CMake on Orion
Jan 10, 2025
a182c44
added TEST_DATE as an agrment to adding a test in CMake List file
Jan 10, 2025
fd8a8bc
needed idate in arg to exexcute
Jan 11, 2025
472d89c
just use par_yaml
Jan 11, 2025
45d2901
trying to get args into yaml
Jan 11, 2025
8ca4d7a
added TEST_DATA via data to template
Jan 11, 2025
91d76e3
added TEST_DATE into arg to bash stage
Jan 11, 2025
61e7ce3
changed test_date argument to datetime object so it can be used with …
Jan 13, 2025
1860e05
MACHINE_ID is no longer used (removed from messae)
Jan 13, 2025
e979f75
updated arg to stagy.py for test_date to a str
Jan 13, 2025
91f4331
missed commit (adding test_date arg to stage.py)
Jan 13, 2025
17fd1da
added env vars to starge.py in wrapper via prefixed values to call
Jan 13, 2025
48ec7c6
check if default is not used and needs to be set to valule for error …
Jan 13, 2025
243d47b
did not have updated var name for STAGED_TEST_DIR in yaml file
Jan 13, 2025
c092b10
replaced scraping output file with status from sacct
Jan 13, 2025
41b6aee
added extra step for making sure the submitted job_id is in the sacct…
Jan 13, 2025
42fbc2a
remove white spaces from job_status
Jan 13, 2025
b17ca77
update path to validate stub and reduce first wait on sacct to 30 sec…
Jan 13, 2025
bee8efc
update a few shellnorm suggestions
Jan 13, 2025
613d951
one more shellnorm for true on pipe
Jan 13, 2025
53bfb62
innocuous extra line at end of toplevel CMake file
Jan 13, 2025
c6cfefb
consolated GFS ROOT path for staged data dir on orion
Jan 13, 2025
02a03f1
added some more notes for validate subs
Jan 13, 2025
02e1a92
remove extras from stage.py
Jan 13, 2025
3da4c54
still had path woring to valication stub (has no *.in file)
Jan 13, 2025
c416370
another shellnorm || true
Jan 13, 2025
52c5081
pynomrs spaces
Jan 13, 2025
1b74559
pynomrs line space two
Jan 13, 2025
99defb4
Merge branch 'NOAA-EMC:develop' into ctest_jjobs_framework
TerrenceMcGuinness-NOAA Jan 14, 2025
e965602
added back missing submodels gsi_enkf and gsi_utils
Jan 14, 2025
241392d
updating to correct hash for submodule gsi_enkf
Jan 14, 2025
4669e38
added inline documentation to the stage file python script
Jan 14, 2025
892a6bf
added simple README.md file in the ctest directory
Jan 14, 2025
3dff4d1
Merge branch 'develop' into ctest_jjobs_framework
TerrenceMcGuinness-NOAA Jan 14, 2025
b7f80cb
included instructions on how to add a new test in the README.md file
Jan 14, 2025
898fcfe
Update README.md
TerrenceMcGuinness-NOAA Jan 14, 2025
12cf0cf
Update README.md
TerrenceMcGuinness-NOAA Jan 14, 2025
eeb744f
Update README.md
TerrenceMcGuinness-NOAA Jan 14, 2025
73211bc
Update README.md
TerrenceMcGuinness-NOAA Jan 14, 2025
f18f1ee
Update ctests/scripts/validate.sh
TerrenceMcGuinness-NOAA Jan 14, 2025
b1a9fd2
added validate.sh.in template bash wrapper script
Jan 14, 2025
f058450
added cmake to Hercules gwsetup modulefile
Jan 14, 2025
eede574
updated path to validate.sh
Jan 14, 2025
7da3828
needed to remove bash from the COMMAND line for validate.sh
Jan 15, 2025
5f722e3
Merge branch 'NOAA-EMC:develop' into ctest_jjobs_framework
TerrenceMcGuinness-NOAA Jan 15, 2025
e48ae52
allow the build to continue whe ctests can not be created without the…
Jan 15, 2025
1318858
added folder compair code to capture output of job
Jan 15, 2025
704887d
added to helper file util to copy files
Jan 15, 2025
69469ea
removed full path and only save relative path
Jan 15, 2025
3079028
added pwd to folder where the files are
Jan 15, 2025
ab43e45
added shabang
Jan 15, 2025
137f0b0
use two args for copy files as relative paths
Jan 15, 2025
3798c22
use two args for copy files as relative paths 2
Jan 15, 2025
2328b6f
added basic validation script
Jan 15, 2025
d985542
fixed bugs in validate.sh.in
Jan 15, 2025
1118074
extra / got in yaml
Jan 15, 2025
d7777dc
had to add underscores back in to yaml file
Jan 15, 2025
ea32a7c
had to add more underscores back in to yaml file
Jan 15, 2025
e082fc3
mistakenly had input files in path for mkdir
Jan 15, 2025
fb6bcc2
Merge branch 'NOAA-EMC:develop' into ctest_work
TerrenceMcGuinness-NOAA Jan 16, 2025
36303c1
print ok for each file on verify
Jan 16, 2025
3fdedde
missed a quote on command line of validate.sh.in
Jan 16, 2025
ccd50e7
fixed but name of YAML_FILE and permisions to run pytnon script for v…
Jan 16, 2025
bc107c8
missed spelling of STAGED_TESTS_DIR in yaml and needed check for fail…
Jan 16, 2025
ae626ba
fixed var name on arg and listed only files from test when output che…
Jan 16, 2025
e27f0c3
merged develop into ctest_work
Jan 17, 2025
21b8cad
used bash command to get rocotoboot_dryrun that is in the path
Jan 17, 2025
e212e80
Merge branch 'NOAA-EMC:develop' into ctest_work
TerrenceMcGuinness-NOAA Jan 22, 2025
087bd24
adding case C48_S2SW for JJOB gfs_fcst_seg0
Jan 22, 2025
54a8abf
trying to add 6 hours to TEST_DATE for ocean retart in C48_S3SW stagg…
Jan 22, 2025
df109e1
used add_to_datetime with a time_delta function from the tmetools wxf…
Jan 22, 2025
466b19f
finaly got 6 hour offest to work with TEST_DATE in jinja yaml
Jan 22, 2025
5011dc5
added ice restart in staged data
Jan 22, 2025
76491f8
fixed wrong path to ice restart and added tile6 atmos IC to input_fil…
Jan 23, 2025
a24020d
Merge branch 'NOAA-EMC:develop' into ctest_work
TerrenceMcGuinness-NOAA Jan 23, 2025
105da3a
first pass at adding ctest gfs_atmos_prod_f000
Jan 23, 2025
598f212
added C48_S2SW_gfs_atmos_prod_f000-f003 JJOB
Jan 23, 2025
0de2327
Merge branch 'NOAA-EMC:develop' into ctest_work
TerrenceMcGuinness-NOAA Jan 24, 2025
ad57686
tried to simplfy readablity of input paths by using CYC and PDY and t…
Jan 24, 2025
2f6b42f
added CYC and PDY alias to C48_ATM for readablity
Jan 24, 2025
86d783f
missed alias for PYD on offset
Jan 24, 2025
c3273e9
fixed check for output files in validate to signlal non-fail subbed w…
Jan 24, 2025
3132b8f
update READMe with some finer explinations
Jan 24, 2025
5cd73e5
added some qulifying comments about validation in the yaml files
Jan 24, 2025
4abf286
added Numpydoc doc strings
Jan 24, 2025
9b5b032
needed trailing lines at the end of a couple of files
Jan 24, 2025
9570f8a
still needed trailing line on the CMakefile
Jan 24, 2025
1dd04fe
Update ctests/scripts/validate.py
TerrenceMcGuinness-NOAA Jan 27, 2025
27e083e
Update ctests/scripts/validate.py
TerrenceMcGuinness-NOAA Jan 27, 2025
f930224
Update ctests/scripts/validate.py
TerrenceMcGuinness-NOAA Jan 27, 2025
3b65b38
Update ctests/scripts/validate.py
TerrenceMcGuinness-NOAA Jan 27, 2025
c4c96e2
Merge branch 'NOAA-EMC:develop' into ctests_extended
TerrenceMcGuinness-NOAA Jan 27, 2025
b2bda5a
Update ctests/scripts/validate.py
TerrenceMcGuinness-NOAA Jan 27, 2025
9bfe5e0
Update ctests/scripts/validate.py
TerrenceMcGuinness-NOAA Jan 27, 2025
e58bf3b
Merge branch 'NOAA-EMC:develop' into ctests_extended
TerrenceMcGuinness-NOAA Jan 28, 2025
efd1318
updated staged python script to use to_datetime aswell
Jan 28, 2025
ffb5c7e
made CYC cyc in yaml case files
Jan 28, 2025
9fdd433
fixed main() indentation in the stage python script
Jan 28, 2025
c82b4b7
pynomrs space needced in stage python script before main block
Jan 28, 2025
ecc2a70
fixed bug introduced by suggested commit from reviewer regarding logg…
Jan 28, 2025
470a044
Merge branch 'NOAA-EMC:develop' into ctests_extended
TerrenceMcGuinness-NOAA Jan 29, 2025
5a17753
Update ctests/cases/C48_S2SW_gfs_fcst_seg0.yaml
TerrenceMcGuinness-NOAA Jan 30, 2025
b872311
Update ctests/cases/C48_S2SW_gfs_fcst_seg0.yaml
TerrenceMcGuinness-NOAA Jan 30, 2025
7033b61
added doc-blocks in validate python script
Jan 30, 2025
825de73
Merge branch 'NOAA-EMC:develop' into ctests_extended
TerrenceMcGuinness-NOAA Jan 30, 2025
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
2 changes: 1 addition & 1 deletion ci/platforms/config.orion
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

export GFS_CI_ROOT=/work2/noaa/stmp/GFS_CI_ROOT/ORION
export ICSDIR_ROOT=/work/noaa/global/glopara/data/ICSDIR
export STAGED_TESTS_DIR=${GFS_CI_ROOT}/STAGED_TESTS_DIR
export STAGED_TESTS_DIR=/work/noaa/stmp/GFS_CI_ROOT/ORION/STAGED_TESTS_DIR
export HPC_ACCOUNT=nems
export max_concurrent_cases=5
export max_concurrent_pr=4
Expand Down
14 changes: 13 additions & 1 deletion ctests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function(AddJJOBTest)

# TODO - This is a stub for the validation step
add_test(NAME test_${TEST_NAME}_validate
COMMAND ./validate.sh ${TEST_NAME} ${CASE_YAML}
COMMAND ./validate.sh ${TEST_NAME} ${ARG_TEST_DATE}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/scripts)
set_tests_properties(test_${TEST_NAME}_validate PROPERTIES DEPENDS test_${TEST_NAME}_execute LABELS "${ARG_CASE};${ARG_JOB}")
endfunction()
Expand All @@ -104,3 +104,15 @@ AddJJOBTest(
JOB "gfs_fcst_seg0"
TEST_DATE "2021032312"
)

AddJJOBTest(
CASE "C48_S2SW"
JOB "gfs_fcst_seg0"
TEST_DATE "2021032312"
)

AddJJOBTest(
CASE "C48_S2SW"
JOB "gfs_atmos_prod_f000-f003"
TEST_DATE "2021032312"
)
20 changes: 16 additions & 4 deletions ctests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,33 @@ The CTest framework consists of the following scripts:
- **setup.sh.in**: Prepares the environment and creates the experiment.
- **stage.sh.in**: Stages the input files needed to run a JJOB.
- **execute.sh.in**: Executes the JJOB and monitors its status.
- **validate.sh.in**: (TODO) Validates the results of the JJOB.
- **validate.sh.in**: Validates the results of the JJOB.

**NOTE:** So far only test C48_ATM *gfs_fcst_set0* has `output_files` for the validation step using a basic chksum for testing. Further development using grib and NETCDF comparison tools is pending.

## Usage

### CMake Configuration

To configure the CTest framework using CMake, you need to provide several environment variables or default values. Here is an example of how to configure and build the project:
To configure the **CTest** framework using **CMake**, you need to provide several environment variables. Here is an example of how to configure and build the project:

```bash
# Set environment variables (may also be include at command line with -D)
export HPC_ACCOUNT="your_hpc_account"
export ICSDIR_ROOT="/path/to/icsdir_root"
export STAGED_TESTS_DIR="/path/to/staged_tests_dir"
```
**NOTE**: The the specific values for these three enviroment variables can be found in `$HOMEgfs/ci/platforms/config.$MACHINE_ID` and may also be added to the `cmake` command line with the `-D` option

# Run CMake to configure the ctest framework
cmake -S /path/to/HOMEgfs -B /path/to/build -DRUNTESTS=/path/to/runtests

```shell
cd $HOMEgfs/ctests
mkdir build
cd build
cmake ../..
```


### Running Tests with CTest

Once the project is configured, you can run the tests using CTest. Here are some examples:
Expand All @@ -46,6 +54,10 @@ You can use the `-L` option with CTest to run tests for a specific case. For exa
cd /path/to/build
ctest -L C48_ATM
```
Or simply use the '-R' switch to run any individual test:
```
ctest -R test_C48_S2SW_gfs_fcst_seg0_execute -V
```

To add a new test use the **AddJJOBTest()** function at the end of the `$HOMEgfs/ctest/CMakeLists.txt` file as follows:
```cmake
Expand Down
168 changes: 154 additions & 14 deletions ctests/cases/C48_ATM_gfs_fcst_seg0.yaml

Large diffs are not rendered by default.

136 changes: 136 additions & 0 deletions ctests/cases/C48_S2SW_gfs_atmos_prod_f000-f003.yaml

Large diffs are not rendered by default.

50 changes: 50 additions & 0 deletions ctests/cases/C48_S2SW_gfs_fcst_seg0.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{% set H_offset = "-6H" %}
{% set H_timedelta = H_offset | to_timedelta %}
{% set TEST_DATE_offset = TEST_DATE | add_to_datetime(H_timedelta) %}

{% set cyc = TEST_DATE | strftime('%H') %}
{% set cyc_offset = TEST_DATE_offset | strftime('%H') %}
TerrenceMcGuinness-NOAA marked this conversation as resolved.
Show resolved Hide resolved

{% set PDY = TEST_DATE | to_YMD %}
{% set PDY_offset = TEST_DATE_offset | to_YMD %}
TerrenceMcGuinness-NOAA marked this conversation as resolved.
Show resolved Hide resolved

input_files:
mkdir:
- "{{ 'RUNTESTS' | getenv }}/COMROOT/{{ 'TEST_NAME' | getenv }}/gfs.{{ PDY }}/{{ cyc }}/model/atmos/input"
- "{{ 'RUNTESTS' | getenv }}/COMROOT/{{ 'TEST_NAME' | getenv }}/gfs.{{ PDY }}/{{ cyc }}/model/wave/prep"
- "{{ 'RUNTESTS' | getenv }}/COMROOT/{{ 'TEST_NAME' | getenv }}/gdas.{{ PDY }}/{{cyc_offset}}/model/ocean/restart"
- "{{ 'RUNTESTS' | getenv }}/COMROOT/{{ 'TEST_NAME' | getenv }}/gdas.{{ PDY }}/{{cyc_offset}}/model/ice/restart"
copy:
- ["{{ 'STAGED_TESTS_DIR' | getenv }}/{{ 'TEST_NAME' | getenv }}/input_files/gfs.{{ PDY }}/{{ cyc }}/model/atmos/input/gfs_ctrl.nc", "{{ 'RUNTESTS' | getenv }}/COMROOT/{{ 'TEST_NAME' | getenv }}/gfs.{{ PDY }}/{{ cyc }}/model/atmos/input/gfs_ctrl.nc"]
- ["{{ 'STAGED_TESTS_DIR' | getenv }}/{{ 'TEST_NAME' | getenv }}/input_files/gfs.{{ PDY }}/{{ cyc }}/model/atmos/input/gfs_data.tile1.nc", "{{ 'RUNTESTS' | getenv }}/COMROOT/{{ 'TEST_NAME' | getenv }}/gfs.{{ PDY }}/{{ cyc }}/model/atmos/input/gfs_data.tile1.nc"]
- ["{{ 'STAGED_TESTS_DIR' | getenv }}/{{ 'TEST_NAME' | getenv }}/input_files/gfs.{{ PDY }}/{{ cyc }}/model/atmos/input/gfs_data.tile2.nc", "{{ 'RUNTESTS' | getenv }}/COMROOT/{{ 'TEST_NAME' | getenv }}/gfs.{{ PDY }}/{{ cyc }}/model/atmos/input/gfs_data.tile2.nc"]
- ["{{ 'STAGED_TESTS_DIR' | getenv }}/{{ 'TEST_NAME' | getenv }}/input_files/gfs.{{ PDY }}/{{ cyc }}/model/atmos/input/gfs_data.tile3.nc", "{{ 'RUNTESTS' | getenv }}/COMROOT/{{ 'TEST_NAME' | getenv }}/gfs.{{ PDY }}/{{ cyc }}/model/atmos/input/gfs_data.tile3.nc"]
- ["{{ 'STAGED_TESTS_DIR' | getenv }}/{{ 'TEST_NAME' | getenv }}/input_files/gfs.{{ PDY }}/{{ cyc }}/model/atmos/input/gfs_data.tile4.nc", "{{ 'RUNTESTS' | getenv }}/COMROOT/{{ 'TEST_NAME' | getenv }}/gfs.{{ PDY }}/{{ cyc }}/model/atmos/input/gfs_data.tile4.nc"]
- ["{{ 'STAGED_TESTS_DIR' | getenv }}/{{ 'TEST_NAME' | getenv }}/input_files/gfs.{{ PDY }}/{{ cyc }}/model/atmos/input/gfs_data.tile5.nc", "{{ 'RUNTESTS' | getenv }}/COMROOT/{{ 'TEST_NAME' | getenv }}/gfs.{{ PDY }}/{{ cyc }}/model/atmos/input/gfs_data.tile5.nc"]
- ["{{ 'STAGED_TESTS_DIR' | getenv }}/{{ 'TEST_NAME' | getenv }}/input_files/gfs.{{ PDY }}/{{ cyc }}/model/atmos/input/gfs_data.tile6.nc", "{{ 'RUNTESTS' | getenv }}/COMROOT/{{ 'TEST_NAME' | getenv }}/gfs.{{ PDY }}/{{ cyc }}/model/atmos/input/gfs_data.tile6.nc"]
- ["{{ 'STAGED_TESTS_DIR' | getenv }}/{{ 'TEST_NAME' | getenv }}/input_files/gfs.{{ PDY }}/{{ cyc }}/model/atmos/input/sfc_data.tile1.nc", "{{ 'RUNTESTS' | getenv }}/COMROOT/{{ 'TEST_NAME' | getenv }}/gfs.{{ PDY }}/{{ cyc }}/model/atmos/input/sfc_data.tile1.nc"]
- ["{{ 'STAGED_TESTS_DIR' | getenv }}/{{ 'TEST_NAME' | getenv }}/input_files/gfs.{{ PDY }}/{{ cyc }}/model/atmos/input/sfc_data.tile2.nc", "{{ 'RUNTESTS' | getenv }}/COMROOT/{{ 'TEST_NAME' | getenv }}/gfs.{{ PDY }}/{{ cyc }}/model/atmos/input/sfc_data.tile2.nc"]
- ["{{ 'STAGED_TESTS_DIR' | getenv }}/{{ 'TEST_NAME' | getenv }}/input_files/gfs.{{ PDY }}/{{ cyc }}/model/atmos/input/sfc_data.tile3.nc", "{{ 'RUNTESTS' | getenv }}/COMROOT/{{ 'TEST_NAME' | getenv }}/gfs.{{ PDY }}/{{ cyc }}/model/atmos/input/sfc_data.tile3.nc"]
- ["{{ 'STAGED_TESTS_DIR' | getenv }}/{{ 'TEST_NAME' | getenv }}/input_files/gfs.{{ PDY }}/{{ cyc }}/model/atmos/input/sfc_data.tile4.nc", "{{ 'RUNTESTS' | getenv }}/COMROOT/{{ 'TEST_NAME' | getenv }}/gfs.{{ PDY }}/{{ cyc }}/model/atmos/input/sfc_data.tile4.nc"]
- ["{{ 'STAGED_TESTS_DIR' | getenv }}/{{ 'TEST_NAME' | getenv }}/input_files/gfs.{{ PDY }}/{{ cyc }}/model/atmos/input/sfc_data.tile5.nc", "{{ 'RUNTESTS' | getenv }}/COMROOT/{{ 'TEST_NAME' | getenv }}/gfs.{{ PDY }}/{{ cyc }}/model/atmos/input/sfc_data.tile5.nc"]
- ["{{ 'STAGED_TESTS_DIR' | getenv }}/{{ 'TEST_NAME' | getenv }}/input_files/gfs.{{ PDY }}/{{ cyc }}/model/atmos/input/sfc_data.tile5.nc", "{{ 'RUNTESTS' | getenv }}/COMROOT/{{ 'TEST_NAME' | getenv }}/gfs.{{ PDY }}/{{ cyc }}/model/atmos/input/sfc_data.tile5.nc"]
- ["{{ 'STAGED_TESTS_DIR' | getenv }}/{{ 'TEST_NAME' | getenv }}/input_files/gfs.{{ PDY }}/{{ cyc }}/model/atmos/input/sfc_data.tile6.nc", "{{ 'RUNTESTS' | getenv }}/COMROOT/{{ 'TEST_NAME' | getenv }}/gfs.{{ PDY }}/{{ cyc }}/model/atmos/input/sfc_data.tile6.nc"]

- ["{{ 'STAGED_TESTS_DIR' | getenv }}/{{ 'TEST_NAME' | getenv }}/input_files/gfs.{{ PDY }}/{{ cyc }}/model/wave/prep/gfswave.mod_def.glo_200", "{{ 'RUNTESTS' | getenv }}/COMROOT/{{ 'TEST_NAME' | getenv }}/gfs.{{ PDY }}/{{ cyc }}/model/wave/prep/gfswave.mod_def.glo_200"]
- ["{{ 'STAGED_TESTS_DIR' | getenv }}/{{ 'TEST_NAME' | getenv }}/input_files/gfs.{{ PDY }}/{{ cyc }}/model/wave/prep/gfswave.mod_def.uglo_100km", "{{ 'RUNTESTS' | getenv }}/COMROOT/{{ 'TEST_NAME' | getenv }}/gfs.{{ PDY }}/{{ cyc }}/model/wave/prep/gfswave.mod_def.uglo_100km"]

- ["{{ 'STAGED_TESTS_DIR' | getenv }}/{{ 'TEST_NAME' | getenv }}/input_files/gdas.{{ PDY_offset }}/{{ cyc_offset }}/model/ocean/restart/{{ TEST_DATE | strftime('%Y%m%d.%H0000') }}.MOM.res.nc",
"{{ 'RUNTESTS' | getenv }}/COMROOT/{{ 'TEST_NAME' | getenv }}/gdas.{{ PDY_offset }}/{{ cyc_offset }}/model/ocean/restart/{{ TEST_DATE | strftime('%Y%m%d.%H0000') }}.MOM.res.nc" ]

- ["{{ 'STAGED_TESTS_DIR' | getenv }}/{{ 'TEST_NAME' | getenv }}/input_files/gdas.{{ PDY_offset }}/{{ cyc_offset }}/model/ice/restart/{{ TEST_DATE | strftime('%Y%m%d.%H0000') }}.cice_model.res.nc",
"{{ 'RUNTESTS' | getenv }}/COMROOT/{{ 'TEST_NAME' | getenv }}/gdas.{{ PDY_offset }}/{{ cyc_offset }}/model/ice/restart/{{ TEST_DATE | strftime('%Y%m%d.%H0000') }}.cice_model.res.nc" ]

# TODO - To enable the validation step include specific files to compare against the results from running the test.
# Note: The below three files is only an example. The cmpfiles tag means it will use checksum to compare the files in the two locations.
# Other extensions can be added and/or folded into the FileUtils class in wxflow FileUtilities.py
#
#output_files:
# cmpfiles:
# - ["{{ 'STAGED_TESTS_DIR' | getenv }}/{{ 'TEST_NAME' | getenv }}/output_files/gfs.{{ PDY }}/{{ cyc }}/conf/ufs.diag_table", "{{ 'RUNTESTS' | getenv }}/COMROOT/{{ 'TEST_NAME' | getenv }}/gfs.{{ PDY }}/{{ cyc }}/conf/ufs.diag_table"]
# - ["{{ 'STAGED_TESTS_DIR' | getenv }}/{{ 'TEST_NAME' | getenv }}/output_files/gfs.{{ PDY }}/{{ cyc }}/conf/ufs.input.nml", "{{ 'RUNTESTS' | getenv }}/COMROOT/{{ 'TEST_NAME' | getenv }}/gfs.{{ PDY }}/{{ cyc }}/conf/ufs.input.nml"]
# - ["{{ 'STAGED_TESTS_DIR' | getenv }}/{{ 'TEST_NAME' | getenv }}/output_files/gfs.{{ PDY }}/{{ cyc }}/conf/ufs.model_configure", "{{ 'RUNTESTS' | getenv }}/COMROOT/{{ 'TEST_NAME' | getenv }}/gfs.{{ PDY }}/{{ cyc }}/conf/ufs.model_configure"]
2 changes: 1 addition & 1 deletion ctests/scripts/execute.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ JOB=${2:?"Job name is required"}
idate=$3

#TODO - add rocotoboot_dryrun to repo some how
rocotoboot_dryrun=/work2/noaa/global/mterry/rocoto_dryrun/bin/rocotoboot
rocotoboot_dryrun=$(command -v rocotoboot_dryrun) || true
CASEDIR="@CMAKE_CURRENT_BINARY_DIR@/RUNTESTS/EXPDIR/${TEST_NAME}"
cd "${CASEDIR}"
rm -f ./*.db
Expand Down
13 changes: 8 additions & 5 deletions ctests/scripts/stage.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

from argparse import ArgumentParser
from pathlib import Path
from wxflow import parse_j2yaml, FileHandler, Logger
from wxflow import parse_j2yaml, FileHandler, Logger, logit, to_datetime

# Initialize logger with environment variable for logging level
logger = Logger(level=os.environ.get("LOGGING_LEVEL", "DEBUG"), colored_log=False)
Expand Down Expand Up @@ -52,16 +52,19 @@ def parse_args():
return parser.parse_args()


if __name__ == '__main__':

# Parse command line arguments
@logit(logger)
def main():
args = parse_args()

data = {}
if args.test_date:
# Parse test date from string to datetime object
data['TEST_DATE'] = datetime.datetime.strptime(args.test_date, '%Y%m%d%H')
data['TEST_DATE'] = to_datetime(args.test_date)
# Parse YAML configuration file with optional data
case_cfg = parse_j2yaml(path=args.yaml, data=data)
# Synchronize input files as per the parsed configuration
FileHandler(case_cfg.input_files).sync()


if __name__ == '__main__':
main()
4 changes: 2 additions & 2 deletions ctests/scripts/stage.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ set -x
PYTHONPATH="${PYTHONPATH:+${PYTHONPATH}:}${HOMEgfs}/sorc/wxflow/src"
export PYTHONPATH

INPUTS_YAML="${HOMEgfs}/ctests/cases/${TEST_NAME}.yaml"
YAML_FILE="${HOMEgfs}/ctests/cases/${TEST_NAME}.yaml"

TEST_NAME="${TEST_NAME}" \
RUNTESTS="${RUNTESTS}" \
STAGED_TESTS_DIR="${STAGED_TESTS_DIR}" \
"${HOMEgfs}/ctests/scripts/stage.py" --yaml "${INPUTS_YAML}" --test_date "${TEST_DATE}"
"${HOMEgfs}/ctests/scripts/stage.py" --yaml "${YAML_FILE}" --test_date "${TEST_DATE}"
rc=$?
if [[ "${rc}" -ne 0 ]]; then
set +x
Expand Down
74 changes: 74 additions & 0 deletions ctests/scripts/validate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/usr/bin/env python3
"""
validate.py

Validation script that checks file checksums and verifies test outputs.

Usage
-----
validate.py --yaml <path_to_yaml> --test_date <YYYYMMDDHH>

Parameters
----------
--yaml : str
Path to the YAML configuration file.
--test_date : str
Test date in the format YYYYMMDDHH.

"""

import sys
import argparse
from pathlib import Path
import hashlib
from wxflow import parse_j2yaml, Logger, logit, to_datetime

logger = Logger(level="DEBUG", colored_log=True)


def parse_args():
TerrenceMcGuinness-NOAA marked this conversation as resolved.
Show resolved Hide resolved
parser = argparse.ArgumentParser()
parser.add_argument("--yaml", required=True)
parser.add_argument("--test_date", required=True)
return parser.parse_args()


def file_checksum(path):
hasher = hashlib.md5()
with open(path, "rb") as f:
for chunk in iter(lambda: f.read(4096), b""):
hasher.update(chunk)
return hasher.hexdigest()


def validate_cmpfiles(config):
cmpfiles = config.get("output_files", {}).get("cmpfiles", [])
for pair in cmpfiles:
file_a, file_b = pair
if file_checksum(file_a) != file_checksum(file_b):
logger.error(f"Checksum mismatch: {file_a} vs {file_b}")
raise ValueError(f"Checksum mismatch: {file_a} vs {file_b}")
logger.info(f"checksums match: {file_a} vs {file_b}")


@logit(logger)
def main():
args = parse_args()

data = {}
if args.test_date:
# Parse test date from string to datetime object
data['TEST_DATE'] = to_datetime(args.test_date)

files = parse_j2yaml(path=args.yaml, data=data)
if 'output_files' not in files:
logger.info(f"No output files found for test: {args.yaml}")
logger.info("Nothing to validate (TODO - Stubbed).")
sys.exit(0)

validate_cmpfiles(files)
logger.info(f"All files exist and pass checksum for test: {args.yaml}")


if __name__ == "__main__":
main()
31 changes: 29 additions & 2 deletions ctests/scripts/validate.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,35 @@
set -ux

TEST_NAME=${1:?"Name of the test is required"}
YAML_FILE=${2:?"Name of the CI yaml file for validating the test"}
TEST_DATE=${2:?"idate of the test is required"}

# CMake to fill these variables
STAGED_TESTS_DIR="@STAGED_TESTS_DIR@"
RUNTESTS="@RUNTESTS@"
HOMEgfs="@PROJECT_SOURCE_DIR@"

# Load the runtime environment for this script (needs wxflow and its dependencies)
set +x
source "${HOMEgfs}/workflow/gw_setup.sh"
rc=$?
[[ "${rc}" -ne 0 ]] && exit "${status}"
set -x
PYTHONPATH="${PYTHONPATH:+${PYTHONPATH}:}${HOMEgfs}/sorc/wxflow/src"
export PYTHONPATH

YAML_FILE="${HOMEgfs}/ctests/cases/${TEST_NAME}.yaml"
echo "validating '${TEST_NAME}' with yaml file '${YAML_FILE}'"

TEST_NAME="${TEST_NAME}" \
RUNTESTS="${RUNTESTS}" \
STAGED_TESTS_DIR="${STAGED_TESTS_DIR}" \
"${HOMEgfs}/ctests/scripts/validate.py" --yaml "${YAML_FILE}" --test_date "${TEST_DATE}"
rc=$?
if [[ "${rc}" -ne 0 ]]; then
set +x
echo "Failed to validate for '${TEST_NAME}' with '${YAML_FILE}'"
set -x
exit "${rc}"
fi

exit 0
exit 0