-
Notifications
You must be signed in to change notification settings - Fork 178
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
CI JJOB Tests using CMake #3214
Merged
WalterKolczynski-NOAA
merged 160 commits into
NOAA-EMC:develop
from
TerrenceMcGuinness-NOAA:ctest_jjobs_framework
Jan 17, 2025
Merged
Changes from 149 commits
Commits
Show all changes
160 commits
Select commit
Hold shift + click to select a range
987ae5b
added ctest dir with cmake to create an experment
61fcf83
added CMakeLists for creating initial case EXPDIR usint ctest
f5f6595
ready to test getting the job names
cbe3bab
move all operations of creating EXPDIR cases into configure phase
6a50e14
got cmake configure to work for EXPDIR
bcebeca
can not do both file and variable save for execute_process
be7a890
working cmake config up to output of job names
2811629
Merge branch 'NOAA-EMC:develop' into ctest_jjobs_framework
TerrenceMcGuinness-NOAA 70a8183
loop over jobnames and create an experment for each
72e5a9c
update JOB name update in loop
1f1fcd6
addded debug outputs
ee27b02
modifying plslot list to be only on a per case
bc76ddf
filter pslot list for only relevent cases
38838a6
refining get_job_names
d18ad01
modigied get_jobs_names to task and metatask names
ef0e066
got better jobname parcer working
519a919
Merge branch 'NOAA-EMC:develop' into ctest_jjobs_framework
TerrenceMcGuinness-NOAA f813a1b
replaced generate_workflows with create_experment
8238228
removed non-existing ENVIRONMENT setting to consolated COMMAND line
bf579ee
got cmake script to use creat_experiment
28ef1af
Merge branch 'NOAA-EMC:develop' into ctest_jjobs_framework
TerrenceMcGuinness-NOAA 374927f
just getting started with addeding a ctest
8b4fc4f
add in test for configured project
ce37d86
added ctest and testing
d4e3266
Merge branch 'NOAA-EMC:develop' into ctest_jjobs_framework
TerrenceMcGuinness-NOAA bb12cda
moved ctests dir to top HOMEgfs/ci/ctests with its own scripts dir
f78181c
added all jobs for tests for each case
46cddb7
added data stagging dependances and started it as a stub script
d6c3a49
Merge branch 'NOAA-EMC:develop' into ctest_jjobs_framework
TerrenceMcGuinness-NOAA 434f869
added driver for creating ctests from yaml files
99df88d
added a driver to create ctests from defintions in yaml files
e186173
added final step to loop over yaml files for creating functiona ctest…
c4a2780
Merge branch 'NOAA-EMC:develop' into ctest_jjobs_framework
TerrenceMcGuinness-NOAA 0183667
added second yaml case file for testing python driver
3088bff
added a few comments for each section
9d06df7
Merge branch 'NOAA-EMC:develop' into ctest_jjobs_framework
TerrenceMcGuinness-NOAA 674f8d6
made CMakeList.txt independent of python script
68ca6ee
simplified CMakeList to be compatible with manin build, consolated cr…
f7bbd40
repurposed python script for generating args to man CMakeLists.txt
36d497e
added lables to run tests in groups and added stubbed scripts
808a4cf
created script and cases dir to isolate CMakeLists.txt
81e640f
renamed test to create_experiment
a1d0f20
missed update to name of test from test_ to create_experiment_
2cbf4ee
forgot to save contents of the stubbed scripts
687217f
spelling error on create_experiment
55766bd
got a few hints on using File Utils directly in case Yaml file
f69fb68
updated adding functional test as line enteries in CMakeLists.txt dir…
3cc83c6
Cleaned up names to have Case and job name first
e1e1858
added file utils copy commands in gfs_fcst for C48_ATM
5ce988f
started on stage data python script
cefaccd
added exec line for python staging script
bec03d9
deleted space in yaml file for copy commands
5f9451b
Merge branch 'NOAA-EMC:develop' into ctest_jjobs_framework
TerrenceMcGuinness-NOAA 74fbf45
removed extra $ on JOB var
19600f1
idate needed for PDY
2caa229
updated stage data with idate for PDY and HH and made sure paths wher…
749e54f
added copy using FIleHandler
75450e1
copy command needs quotes
0fc5d76
added sync() on file handler
ea01737
got FileUtil to work in stage data
e9c46f1
got started on execute
2602166
execute needed shabang and exit 0
1950af4
almost ready to launch execute.sh
c691c0e
Merge branch 'NOAA-EMC:develop' into ctest_jjobs_framework
TerrenceMcGuinness-NOAA 276a9bd
added working skeleton bash script for execute using rocotoboot with …
283000e
added a few ICs that where missed
b2a6fec
removed extra scripts no longer used
9525c74
added defulted values and over rides from command line
74f7268
removed HOMEgfs for path to create expermient
5cd1c5f
removed another unused script
c132786
fixed a few path errors with HOMEgfs still hanging around
87674f2
Merge branch 'NOAA-EMC:develop' into ctest_jjobs_framework
TerrenceMcGuinness-NOAA e873722
added cmake_parse_arguments with extras and used inline template for …
32c5f87
added template for cmake tests setup.sh
128d0e6
had to add ARG_ header to labels names for depenancies for setup worked
abb2952
added bash wrapper to stage_data.py and made single job per yaml conf…
1d54caf
added the part to drop in templated inline script for stage.sh
2532576
getting stage.sh.in args to work for now
0967f10
still getting args straintened out with staging
8231519
added args in bash wrapper to stage.py to pick up ARG_CASE and ARG_JOB
30466b9
updated args to stage.py to simply take yaml input
3deeb41
had extra ) for updated add_test
099a2cb
removed reading of pr case file for getting idate
94dd64e
replaced JOB_CASE in path for inputs to TEST_NAME
a98d55d
updated path to yaml input to stage
29517e3
ctest dir is ctests in path to YAML file for stage.py
60a6136
finilized inputs to make stage.py to work without using CASE+JOB
b977e52
mnissed a couple or ARGS_ again this time in execute
95be9f2
ARG are prefixes in execute add test
e9b0b6a
ARG are prefixes in execute add test 2
a72827c
ARG are prefixes in execute add test 3
4f010a4
added MAKE_CURRENT_BINARY_DIR as templated VAR in stage
b79d445
made execute bash sript a template too
16cd19f
forgot to save CMakeLists now has updated call to excute from script …
fffb13d
last bug for working execute phase
5c5ac0f
ready to test x coders add for waiting for slurm job to complete
06c8e8f
do not need link to wxflow anymore, added it to PYTHONPATH in bash wr…
edde418
Merge branch 'NOAA-EMC:develop' into ctest_jjobs_framework
TerrenceMcGuinness-NOAA d68b02e
path to wxflow in PYTHONPATH was wrong in stage template
b0602bc
generlized ARG over-ride and added check for exectution success from …
30b3f3a
should have checked for End not END for success
42084e7
oops need done at then of loop in execute bash sript
8d71151
removed C48_S2SW.yaml for functional test as it is not ready yet
cf7be28
working on shellnorms
a49a642
working on more shellnorms
466831d
working on even more shellnorms
2d18461
working couple more shellnorms
53b13e3
Merge branch 'NOAA-EMC:develop' into ctest_jjobs_framework
TerrenceMcGuinness-NOAA 4ee8d81
removed scripts used for getting system defaults and added top level …
b3518ca
added to yaml fun conf file to us jinja string modification TEST_DATE
54f633b
typos in CMakeLists and module file for adding CMake on Orion
a182c44
added TEST_DATE as an agrment to adding a test in CMake List file
fd8a8bc
needed idate in arg to exexcute
472d89c
just use par_yaml
45d2901
trying to get args into yaml
8ca4d7a
added TEST_DATA via data to template
91d76e3
added TEST_DATE into arg to bash stage
61e7ce3
changed test_date argument to datetime object so it can be used with …
1860e05
MACHINE_ID is no longer used (removed from messae)
e979f75
updated arg to stagy.py for test_date to a str
91f4331
missed commit (adding test_date arg to stage.py)
17fd1da
added env vars to starge.py in wrapper via prefixed values to call
48ec7c6
check if default is not used and needs to be set to valule for error …
243d47b
did not have updated var name for STAGED_TEST_DIR in yaml file
c092b10
replaced scraping output file with status from sacct
41b6aee
added extra step for making sure the submitted job_id is in the sacct…
42fbc2a
remove white spaces from job_status
b17ca77
update path to validate stub and reduce first wait on sacct to 30 sec…
bee8efc
update a few shellnorm suggestions
613d951
one more shellnorm for true on pipe
53bfb62
innocuous extra line at end of toplevel CMake file
c6cfefb
consolated GFS ROOT path for staged data dir on orion
02a03f1
added some more notes for validate subs
02e1a92
remove extras from stage.py
3da4c54
still had path woring to valication stub (has no *.in file)
c416370
another shellnorm || true
52c5081
pynomrs spaces
1b74559
pynomrs line space two
99defb4
Merge branch 'NOAA-EMC:develop' into ctest_jjobs_framework
TerrenceMcGuinness-NOAA e965602
added back missing submodels gsi_enkf and gsi_utils
241392d
updating to correct hash for submodule gsi_enkf
4669e38
added inline documentation to the stage file python script
892a6bf
added simple README.md file in the ctest directory
3dff4d1
Merge branch 'develop' into ctest_jjobs_framework
TerrenceMcGuinness-NOAA b7f80cb
included instructions on how to add a new test in the README.md file
898fcfe
Update README.md
TerrenceMcGuinness-NOAA 12cf0cf
Update README.md
TerrenceMcGuinness-NOAA eeb744f
Update README.md
TerrenceMcGuinness-NOAA 73211bc
Update README.md
TerrenceMcGuinness-NOAA f18f1ee
Update ctests/scripts/validate.sh
TerrenceMcGuinness-NOAA b1a9fd2
added validate.sh.in template bash wrapper script
f058450
added cmake to Hercules gwsetup modulefile
eede574
updated path to validate.sh
7da3828
needed to remove bash from the COMMAND line for validate.sh
5f722e3
Merge branch 'NOAA-EMC:develop' into ctest_jjobs_framework
TerrenceMcGuinness-NOAA e48ae52
allow the build to continue whe ctests can not be created without the…
b691a59
added inpt_files in the path of stagged file to seperate them from ou…
5c8a176
added ouput date into case yaml file
bfe10a2
removed output_files from C48_ATM
2833514
Merge branch 'NOAA-EMC:develop' into ctest_jjobs_framework
TerrenceMcGuinness-NOAA File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,27 @@ | ||
# ------------------------------------------------------------------------- # | ||
# Global Workflow | ||
# ------------------------------------------------------------------------- # | ||
|
||
# Check for minimum cmake requirement | ||
cmake_minimum_required( VERSION 3.20 FATAL_ERROR ) | ||
|
||
project(global_workflow VERSION 1.0.0) | ||
|
||
include(GNUInstallDirs) | ||
enable_testing() | ||
|
||
# Build type. | ||
if(NOT CMAKE_BUILD_TYPE MATCHES "^(Debug|Release|RelWithDebInfo|MinSizeRel)$") | ||
message(STATUS "Setting build type to 'Release' as none was specified.") | ||
set(CMAKE_BUILD_TYPE | ||
"Release" | ||
CACHE STRING "Choose the type of build." FORCE) | ||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" | ||
"MinSizeRel" "RelWithDebInfo") | ||
endif() | ||
|
||
# Build global-workflow source codes | ||
# add_subdirectory(sorc) | ||
|
||
# Setup tests | ||
add_subdirectory(ctests) |
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
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,106 @@ | ||
# ------------------------------------------------------------------------- # | ||
# CTests for Global Workflow | ||
# ------------------------------------------------------------------------- # | ||
# These ctests correspond to JJOBs (individual Rocoto jobs) that can be | ||
# run independently, each requiring its own YAML definition of inputs | ||
# and configurations. By integrating with Rocoto, these jobs can be | ||
# validated, staged, and executed as self-contained tests using | ||
# their own data and test parameters. | ||
# ------------------------------------------------------------------------- # | ||
|
||
# Function to set a variable from an environment variable or default value | ||
function(set_from_env_or_default VAR_NAME ENV_VAR DEFAULT_VALUE) | ||
if (DEFINED ENV{${ENV_VAR}} AND NOT DEFINED ${VAR_NAME}) | ||
set(${VAR_NAME} $ENV{${ENV_VAR}} CACHE STRING "Set from environment variable ${ENV_VAR}") | ||
elseif(NOT DEFINED ${VAR_NAME} AND NOT ${DEFAULT_VALUE} STREQUAL "") | ||
set(${VAR_NAME} ${DEFAULT_VALUE} CACHE STRING "Default value for ${VAR_NAME}") | ||
endif() | ||
endfunction() | ||
|
||
# Set HOMEgfs | ||
if (NOT DEFINED HOMEgfs) | ||
set(HOMEgfs ${PROJECT_SOURCE_DIR}) | ||
endif() | ||
|
||
# Set RUNTESTS | ||
set_from_env_or_default(RUNTESTS RUNTESTS "${CMAKE_CURRENT_BINARY_DIR}/RUNTESTS") | ||
|
||
# Set HPC_ACCOUNT | ||
set_from_env_or_default(HPC_ACCOUNT HPC_ACCOUNT " ") | ||
if (NOT DEFINED HPC_ACCOUNT) | ||
message(FATAL_ERROR "HPC_ACCOUNT must be set") | ||
return() | ||
endif() | ||
|
||
# Set ICSDIR_ROOT | ||
set_from_env_or_default(ICSDIR_ROOT ICSDIR_ROOT "") | ||
if (NOT DEFINED ICSDIR_ROOT) | ||
message(FATAL_ERROR "ICSDIR_ROOT must be set") | ||
return() | ||
endif() | ||
|
||
# Set STAGED_TESTS_DIR | ||
set_from_env_or_default(STAGED_TESTS_DIR STAGED_TESTS_DIR "") | ||
if (NOT DEFINED STAGED_TESTS_DIR) | ||
message(FATAL_ERROR "STAGED_TESTS_DIR must be set") | ||
return() | ||
endif() | ||
|
||
message(STATUS "gw: global-workflow baselines will be used from: '${HOMEgfs}'") | ||
message(STATUS "gw: global-workflow tests will be run at: '${RUNTESTS}'") | ||
message(STATUS "gw: global-workflow tests will use the allocation: '${HPC_ACCOUNT}'") | ||
message(STATUS "gw: global-workflow tests will use ICSDIR_ROOT: '${ICSDIR_ROOT}'") | ||
message(STATUS "gw: global-workflow tests will use staged data from: '${STAGED_TESTS_DIR}'") | ||
|
||
# Prepare test scripts | ||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/setup.sh.in | ||
${CMAKE_CURRENT_BINARY_DIR}/scripts/setup.sh @ONLY) | ||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/stage.sh.in | ||
${CMAKE_CURRENT_BINARY_DIR}/scripts/stage.sh @ONLY) | ||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/execute.sh.in | ||
${CMAKE_CURRENT_BINARY_DIR}/scripts/execute.sh @ONLY) | ||
# TODO - Validation step add its CMake Teplate for its bash wrapper script | ||
# configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/validate.sh.in | ||
# ${CMAKE_CURRENT_BINARY_DIR}/scripts/validate.sh @ONLY) | ||
|
||
function(AddJJOBTest) | ||
|
||
set(prefix ARG) | ||
set(novals NOTRAPFPE NOVALGRIND) | ||
set(singlevals CASE JOB TEST_DATE) | ||
set(multivals TEST_DEPENDS) | ||
|
||
cmake_parse_arguments(${prefix} | ||
"${novals}" "${singlevals}" "${multivals}" | ||
${ARGN}) | ||
|
||
set(TEST_NAME ${ARG_CASE}_${ARG_JOB}) | ||
set(CASE_PATH ${HOMEgfs}/ci/cases/pr) | ||
set(CASE_YAML ${CASE_PATH}/${ARG_CASE}.yaml) | ||
|
||
add_test(NAME test_${TEST_NAME}_setup | ||
COMMAND ./setup.sh ${TEST_NAME} ${CASE_YAML} ${ARG_TEST_DATE} | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/scripts) | ||
set_tests_properties(test_${TEST_NAME}_setup PROPERTIES LABELS "${ARG_CASE};${ARG_JOB}") | ||
|
||
add_test(NAME test_${TEST_NAME}_stage | ||
COMMAND ./stage.sh ${TEST_NAME} ${ARG_TEST_DATE} | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/scripts) | ||
set_tests_properties(test_${TEST_NAME}_stage PROPERTIES DEPENDS test_${TEST_NAME}_setup LABELS "${ARG_CASE};${ARG_JOB}") | ||
|
||
add_test(NAME test_${TEST_NAME}_execute | ||
COMMAND ./execute.sh ${TEST_NAME} ${ARG_JOB} ${ARG_TEST_DATE} | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/scripts) | ||
set_tests_properties(test_${TEST_NAME}_execute PROPERTIES DEPENDS test_${TEST_NAME}_stage LABELS "${ARG_CASE};${ARG_JOB}") | ||
|
||
# TODO - This is a stub for the validation step | ||
add_test(NAME test_${TEST_NAME}_validate | ||
COMMAND bash -c "${HOMEgfs}/ctests/scripts/validate.sh") | ||
TerrenceMcGuinness-NOAA marked this conversation as resolved.
Show resolved
Hide resolved
|
||
set_tests_properties(test_${TEST_NAME}_validate PROPERTIES DEPENDS test_${TEST_NAME}_execute LABELS "${ARG_CASE};${ARG_JOB}") | ||
endfunction() | ||
|
||
AddJJOBTest( | ||
CASE "C48_ATM" | ||
JOB "gfs_fcst_seg0" | ||
TEST_DATE "2021032312" | ||
) |
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,58 @@ | ||
# CTest Framework for NOAA Global Workflow | ||
|
||
This directory contains the CTest framework for testing Rocoto JJOBS. The framework allows you to stage, execute, and validate individual JJOBS independently from other jobs in the workflow. Each test requires its own YAML definition of inputs and configurations. | ||
|
||
## Overview | ||
|
||
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. | ||
|
||
## 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: | ||
|
||
```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" | ||
|
||
# Run CMake to configure the ctest framework | ||
cmake -S /path/to/HOMEgfs -B /path/to/build -DRUNTESTS=/path/to/runtests | ||
|
||
``` | ||
|
||
### Running Tests with CTest | ||
|
||
Once the project is configured, you can run the tests using CTest. Here are some examples: | ||
|
||
#### Run All Tests | ||
|
||
```bash | ||
cd /path/to/build | ||
ctest | ||
``` | ||
|
||
#### Run Tests for a Specific Case | ||
|
||
You can use the `-L` option with CTest to run tests for a specific case. For example, to run tests for the `C48_ATM` case: | ||
|
||
```bash | ||
cd /path/to/build | ||
ctest -L C48_ATM | ||
``` | ||
|
||
To add a new test use the **AddJJOBTest()** function at the end of the `$HOMEgfs/ctest/CMakeLists.txt` file as follows: | ||
```cmake | ||
AddJJOBTest( | ||
CASE "C48_ATM" | ||
JOB "gfs_fcst_seg0" | ||
TEST_DATE "2021032312" | ||
) | ||
``` | ||
Then create a new YAML file with the required staged input files as is done with this example found in `$HOMEgfs/ctests/cases/C48_ATM_gfs_fcts_seg0.yaml` |
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,17 @@ | ||
input_files: | ||
mkdir: | ||
- "{{ 'RUNTESTS' | getenv }}/COMROOT/{{ 'TEST_NAME' | getenv }}//gfs.{{TEST_DATE | to_YMD}}/{{TEST_DATE | strftime('%H')}}/model/atmos/input" | ||
copy: | ||
- ["{{ 'STAGED_TESTS_DIR' | getenv }}/{{ 'TEST_NAME' | getenv }}/gfs.{{ TEST_DATE | to_YMD }}/{{ TEST_DATE | strftime('%H') }}/model/atmos/input/gfs_ctrl.nc", "{{ 'RUNTESTS' | getenv }}/COMROOT/{{ 'TEST_NAME' | getenv }}//gfs.{{TEST_DATE | to_YMD}}/{{TEST_DATE | strftime('%H')}}/model/atmos/input/gfs_ctrl.nc"] | ||
- ["{{ 'STAGED_TESTS_DIR' | getenv }}/{{ 'TEST_NAME' | getenv }}/gfs.{{ TEST_DATE | to_YMD }}/{{ TEST_DATE | strftime('%H') }}/model/atmos/input/gfs_data.tile1.nc", "{{ 'RUNTESTS' | getenv }}/COMROOT/{{ 'TEST_NAME' | getenv }}//gfs.{{TEST_DATE | to_YMD}}/{{TEST_DATE | strftime('%H')}}/model/atmos/input/gfs_data.tile1.nc"] | ||
- ["{{ 'STAGED_TESTS_DIR' | getenv }}/{{ 'TEST_NAME' | getenv }}/gfs.{{ TEST_DATE | to_YMD }}/{{ TEST_DATE | strftime('%H') }}/model/atmos/input/gfs_data.tile2.nc", "{{ 'RUNTESTS' | getenv }}/COMROOT/{{ 'TEST_NAME' | getenv }}//gfs.{{TEST_DATE | to_YMD}}/{{TEST_DATE | strftime('%H')}}/model/atmos/input/gfs_data.tile2.nc"] | ||
- ["{{ 'STAGED_TESTS_DIR' | getenv }}/{{ 'TEST_NAME' | getenv }}/gfs.{{ TEST_DATE | to_YMD }}/{{ TEST_DATE | strftime('%H') }}/model/atmos/input/gfs_data.tile3.nc", "{{ 'RUNTESTS' | getenv }}/COMROOT/{{ 'TEST_NAME' | getenv }}/gfs.{{TEST_DATE | to_YMD}}/{{TEST_DATE | strftime('%H')}}/model/atmos/input/gfs_data.tile3.nc"] | ||
- ["{{ 'STAGED_TESTS_DIR' | getenv }}/{{ 'TEST_NAME' | getenv }}/gfs.{{ TEST_DATE | to_YMD }}/{{ TEST_DATE | strftime('%H') }}/model/atmos/input/gfs_data.tile4.nc", "{{ 'RUNTESTS' | getenv }}/COMROOT/{{ 'TEST_NAME' | getenv }}//gfs.{{TEST_DATE | to_YMD}}/{{TEST_DATE | strftime('%H')}}/model/atmos/input/gfs_data.tile4.nc"] | ||
- ["{{ 'STAGED_TESTS_DIR' | getenv }}/{{ 'TEST_NAME' | getenv }}/gfs.{{ TEST_DATE | to_YMD }}/{{ TEST_DATE | strftime('%H') }}/model/atmos/input/gfs_data.tile5.nc", "{{ 'RUNTESTS' | getenv }}/COMROOT/{{ 'TEST_NAME' | getenv }}///gfs.{{TEST_DATE | to_YMD}}/{{TEST_DATE | strftime('%H')}}/model/atmos/input/gfs_data.tile5.nc"] | ||
- ["{{ 'STAGED_TESTS_DIR' | getenv }}/{{ 'TEST_NAME' | getenv }}/gfs.{{ TEST_DATE | to_YMD }}/{{ TEST_DATE | strftime('%H') }}/model/atmos/input/gfs_data.tile6.nc", "{{ 'RUNTESTS' | getenv }}/COMROOT/{{ 'TEST_NAME' | getenv }}/gfs.{{TEST_DATE | to_YMD}}/{{TEST_DATE | strftime('%H')}}/model/atmos/input/gfs_data.tile6.nc"] | ||
- ["{{ 'STAGED_TESTS_DIR' | getenv }}/{{ 'TEST_NAME' | getenv }}/gfs.{{ TEST_DATE | to_YMD }}/{{ TEST_DATE | strftime('%H') }}/model/atmos/input/sfc_data.tile1.nc", "{{ 'RUNTESTS' | getenv }}/COMROOT/{{ 'TEST_NAME' | getenv }}/gfs.{{TEST_DATE | to_YMD}}/{{TEST_DATE | strftime('%H')}}/model/atmos/input/sfc_data.tile1.nc"] | ||
- ["{{ 'STAGED_TESTS_DIR' | getenv }}/{{ 'TEST_NAME' | getenv }}/gfs.{{ TEST_DATE | to_YMD }}/{{ TEST_DATE | strftime('%H') }}/model/atmos/input/sfc_data.tile2.nc", "{{ 'RUNTESTS' | getenv }}/COMROOT/{{ 'TEST_NAME' | getenv }}/gfs.{{TEST_DATE | to_YMD}}/{{TEST_DATE | strftime('%H')}}/model/atmos/input/sfc_data.tile2.nc"] | ||
- ["{{ 'STAGED_TESTS_DIR' | getenv }}/{{ 'TEST_NAME' | getenv }}/gfs.{{ TEST_DATE | to_YMD }}/{{ TEST_DATE | strftime('%H') }}/model/atmos/input/sfc_data.tile3.nc", "{{ 'RUNTESTS' | getenv }}/COMROOT/{{ 'TEST_NAME' | getenv }}/gfs.{{TEST_DATE | to_YMD}}/{{TEST_DATE | strftime('%H')}}/model/atmos/input/sfc_data.tile3.nc"] | ||
- ["{{ 'STAGED_TESTS_DIR' | getenv }}/{{ 'TEST_NAME' | getenv }}/gfs.{{ TEST_DATE | to_YMD }}/{{ TEST_DATE | strftime('%H') }}/model/atmos/input/sfc_data.tile4.nc", "{{ 'RUNTESTS' | getenv }}/COMROOT/{{ 'TEST_NAME' | getenv }}/gfs.{{TEST_DATE | to_YMD}}/{{TEST_DATE | strftime('%H')}}/model/atmos/input/sfc_data.tile4.nc"] | ||
- ["{{ 'STAGED_TESTS_DIR' | getenv }}/{{ 'TEST_NAME' | getenv }}/gfs.{{ TEST_DATE | to_YMD }}/{{ TEST_DATE | strftime('%H') }}/model/atmos/input/sfc_data.tile5.nc", "{{ 'RUNTESTS' | getenv }}/COMROOT/{{ 'TEST_NAME' | getenv }}/gfs.{{TEST_DATE | to_YMD}}/{{TEST_DATE | strftime('%H')}}/model/atmos/input/sfc_data.tile5.nc"] | ||
- ["{{ 'STAGED_TESTS_DIR' | getenv }}/{{ 'TEST_NAME' | getenv }}/gfs.{{ TEST_DATE | to_YMD }}/{{ TEST_DATE | strftime('%H') }}/model/atmos/input/sfc_data.tile6.nc", "{{ 'RUNTESTS' | getenv }}/COMROOT/{{ 'TEST_NAME' | getenv }}/gfs.{{TEST_DATE | to_YMD}}/{{TEST_DATE | strftime('%H')}}/model/atmos/input/sfc_data.tile6.nc"] |
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,66 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -xe | ||
|
||
TEST_NAME=${1:?"Name of the test is required"} | ||
JOB=${2:?"Job name is required"} | ||
# TODO - adding idate by hand for now, need to get this from the test somehow | ||
idate=$3 | ||
|
||
#TODO - add rocotoboot_dryrun to repo some how | ||
rocotoboot_dryrun=/work2/noaa/global/mterry/rocoto_dryrun/bin/rocotoboot | ||
CASEDIR="@CMAKE_CURRENT_BINARY_DIR@/RUNTESTS/EXPDIR/${TEST_NAME}" | ||
cd "${CASEDIR}" | ||
rm -f ./*.db | ||
rm -f ./jobcard | ||
|
||
yes | "${rocotoboot_dryrun}" -d "${TEST_NAME}.db" -w "${TEST_NAME}.xml" -v 10 -c "${idate}00" -t "${JOB}" 2> jobcard || true | ||
sed '/^{{\|^}}/d' < jobcard | sed '1d' > "${TEST_NAME}.sub" || true | ||
|
||
#TODO - Generalize for batch system (hard coded to slurm) | ||
|
||
output=$(sbatch "${TEST_NAME}.sub") | ||
job_id=$(echo "${output}" | awk '{print $4}') | ||
echo "Job ${job_id} submitted for test ${TEST_NAME} with job name ${JOB}" | ||
|
||
# First loop: wait until job appears | ||
lack_of_job_count=0 | ||
LACK_OF_JOB_LIMIT=5 | ||
|
||
while true; do | ||
job_status=$(sacct -j "${job_id}" --format=State --noheader -n | head -1) || true | ||
if [[ -n "${job_status}" ]]; then | ||
echo "Job ${job_id} found in sacct." | ||
break | ||
fi | ||
echo "Job ${job_id} not in sacct yet, attempt ${lack_of_job_count}/${LACK_OF_JOB_LIMIT}." | ||
lack_of_job_count=$((lack_of_job_count + 1)) | ||
if [[ "${lack_of_job_count}" -ge "${LACK_OF_JOB_LIMIT}" ]]; then | ||
echo "Job ${job_id} not found after ${lack_of_job_count} attempts. Exiting." | ||
exit 1 | ||
fi | ||
sleep 30 | ||
done | ||
|
||
# Second loop: monitor job status until completion or failure | ||
timeout=0 | ||
TIMEOUT=60 | ||
while true; do | ||
# Trim trailing spaces from job_status | ||
job_status=$(sacct -j "${job_id}" --format=State --noheader -n | head -1 | xargs) || true | ||
if [[ "${job_status}" == "COMPLETED" ]]; then | ||
echo "Job ${job_id} completed successfully." | ||
break | ||
elif [[ "${job_status}" =~ ^(FAILED|CANCELLED|TIMEOUT)$ ]]; then | ||
echo "Job ${job_id} failed with status: ${job_status}." | ||
exit 1 | ||
else | ||
echo "Job ${job_id} is still running with status: ${job_status}." | ||
sleep 60 | ||
timeout=$((timeout + 1)) | ||
if [[ "${timeout}" -gt "${TIMEOUT}" ]]; then | ||
echo "Job ${job_id} has been running for more than ${TIMEOUT} minutes. Exiting." | ||
exit 1 | ||
fi | ||
fi | ||
done |
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,31 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -ux | ||
|
||
TEST_NAME=${1:?"Name of the test is required"} | ||
YAML_FILE=${2:?"Name of the CI yaml file for the test"} | ||
|
||
# CMake to fill these variables | ||
HOMEgfs="@PROJECT_SOURCE_DIR@" | ||
RUNTESTS="@RUNTESTS@" | ||
ICSDIR_ROOT="@ICSDIR_ROOT@" | ||
HPC_ACCOUNT="@HPC_ACCOUNT@" | ||
|
||
set +x | ||
source "${HOMEgfs}/workflow/gw_setup.sh" | ||
set -x | ||
|
||
pslot="${TEST_NAME}" \ | ||
RUNTESTS="${RUNTESTS}" \ | ||
ICSDIR_ROOT="${ICSDIR_ROOT}" \ | ||
HPC_ACCOUNT="${HPC_ACCOUNT}" \ | ||
"${HOMEgfs}/workflow/create_experiment.py" --yaml "${YAML_FILE}" --overwrite | ||
rc=$? | ||
if [[ "${rc}" -ne 0 ]]; then | ||
set +x | ||
echo "Failed to create test experiment for '${TEST_NAME}' with yaml file '${YAML_FILE}'" | ||
set -x | ||
exit "${rc}" | ||
fi | ||
|
||
exit 0 |
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,67 @@ | ||
#!/usr/bin/env python3 | ||
|
||
""" | ||
stage.py | ||
|
||
This script is part of the ctest framework for testing Rocoto JJOBS that stages the | ||
input files needed to run a JJOB independently from other jobs in the workflow. | ||
The YAML file specified at the command line contains the paths to the staged input files | ||
and their corresponding directories under the COMROOT of the experiment for the JJOB. | ||
|
||
Usage: | ||
stage.py -y <yaml_file> [-d <test_date>] | ||
|
||
Arguments: | ||
-y, --yaml Path to the YAML file describing the job test configuration (required) | ||
-d, --test_date Test date in YYYYMMDDHH format (optional) | ||
|
||
Example: | ||
./stage.py -y /path/to/config.yaml -d 2021032312 | ||
""" | ||
|
||
import os | ||
import datetime | ||
|
||
from argparse import ArgumentParser | ||
from pathlib import Path | ||
from wxflow import parse_j2yaml, FileHandler, Logger | ||
|
||
# Initialize logger with environment variable for logging level | ||
logger = Logger(level=os.environ.get("LOGGING_LEVEL", "DEBUG"), colored_log=False) | ||
|
||
|
||
def parse_args(): | ||
""" | ||
Parse command line arguments. | ||
|
||
Returns | ||
------- | ||
argparse.Namespace | ||
The parsed command line arguments, including: | ||
- yaml: Path to the YAML file describing the job test configuration. | ||
- test_date: Optional test date in YYYYMMDDHH format. | ||
""" | ||
description = """Arguments for creating and updating error log files | ||
""" | ||
parser = ArgumentParser(description=description) | ||
|
||
# Add argument for YAML file path | ||
parser.add_argument('-y', '--yaml', help='full path to yaml file describing the job test configuration', type=Path, required=True) | ||
# Add optional argument for test date | ||
parser.add_argument('-d', '--test_date', help='test date in YYYYMMDDHH format', type=str, required=False) | ||
return parser.parse_args() | ||
|
||
|
||
if __name__ == '__main__': | ||
|
||
# Parse command line arguments | ||
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') | ||
# 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() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
FATAL_ERROR
will stop cmake processing (I think).The
return()
after this line will not allow the cmake-ification of the project.