-
Notifications
You must be signed in to change notification settings - Fork 86
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
[develop]: Use yaml format for specifying experiment parameters #778
Changes from 72 commits
b4b7acd
b013305
52e5f50
7e1e8c3
9a8ebd3
547e80f
49d5ac3
f65421a
ce81c00
b40e528
55b0870
025351a
e7b334b
ee43bc4
6502f60
713ca6f
3e2f19f
0694445
79abed8
0c4e822
b232b71
34a5241
7267e5a
ff858e9
4aa3631
b84c763
f13554c
ec88007
b71fee5
bbbe9a9
9a75311
871cfc0
4fd683d
abe6733
86ef28e
b02e7f5
0ba2a25
d2cad87
298ba67
15265db
84c16fd
47e4ea8
71abc8f
9fe6941
b21fe09
ad07c5b
ab21405
d4f62d3
9b818b5
41c46ab
a1735b4
6cd51a3
7d2f5e9
c9e9844
10cb19b
4adbd82
b215cae
283e2d9
0a0f7bd
d18dc0a
41264ad
7ad8498
860bf82
98d9a72
4f4d5c5
46d9f17
8bd7211
1cf6f01
15a1207
f30bff0
a6fb3ae
06e01e5
52a999b
1fc7791
9b85b39
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Python unittests | ||
name: Python functional tests | ||
on: | ||
push: | ||
paths: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -405,30 +405,10 @@ function get_WE2Etest_names_subdirs_descs() { | |
var_name_at \ | ||
vars_to_extract | ||
|
||
local grid_gen_method \ | ||
\ | ||
gfdlgrid_lon_t6_ctr \ | ||
gfdlgrid_lat_t6_ctr \ | ||
gfdlgrid_num_cells \ | ||
gfdlgrid_stretch_fac \ | ||
gfdlgrid_refine_ratio \ | ||
gfdlgrid_istart_of_rgnl_dom_on_t6g \ | ||
gfdlgrid_iend_of_rgnl_dom_on_t6g \ | ||
gfdlgrid_jstart_of_rgnl_dom_on_t6g \ | ||
gfdlgrid_jend_of_rgnl_dom_on_t6g \ | ||
\ | ||
esggrid_lon_ctr \ | ||
esggrid_lat_ctr \ | ||
esggrid_nx \ | ||
esggrid_ny \ | ||
esggrid_pazi \ | ||
esggrid_wide_halo_width \ | ||
esggrid_delx \ | ||
esggrid_dely \ | ||
\ | ||
nx \ | ||
ny \ | ||
dta | ||
local dta \ | ||
nxny \ | ||
dta_r \ | ||
nxny_r | ||
# | ||
#----------------------------------------------------------------------- | ||
# | ||
|
@@ -591,7 +571,11 @@ information on all WE2E tests: | |
# statement will be false. | ||
# | ||
if [ -z "${generate_csv_file}" ]; then | ||
mod_time_subdir=$( stat --format=%Y "${subdir_fp}" ) | ||
if [ -f "${subdir_fp}/*.yaml" ]; then | ||
mod_time_subdir=$( stat --format=%Y "${subdir_fp}"/*.yaml | sort -n | tail -1 ) | ||
else | ||
mod_time_subdir="0" | ||
fi | ||
if [ "${mod_time_subdir}" -gt "${mod_time_csv}" ]; then | ||
generate_csv_file="TRUE" | ||
print_info_msg " | ||
|
@@ -633,7 +617,7 @@ to generate a new CSV file: | |
# "config.${test_name}.sh", in which case it will be equal to ${test_name}. | ||
# Otherwise, it will be a null string. | ||
# | ||
regex_search="^config\.(.*)\.sh$" | ||
regex_search="^config\.(.*)\.yaml$" | ||
test_name_or_null=$( printf "%s\n" "${crnt_item}" | \ | ||
sed -n -r -e "s/${regex_search}/\1/p" ) | ||
# | ||
|
@@ -887,7 +871,7 @@ name (test_name) is not 1: | |
test_name = \"${test_name}\" | ||
num_occurrences = ${num_occurrences} | ||
These configuration files all have the name | ||
\"config.${test_name}.sh\" | ||
\"config.${test_name}.yaml\" | ||
and are located in the following category subdirectories under | ||
test_configs_basedir: | ||
subdirs = ( $( printf "\"%s\" " "${subdirs[@]}" )) | ||
|
@@ -995,80 +979,11 @@ configuration files of the primary WE2E tests... | |
# leading spaces, the hash symbol, and possibly another space and append | ||
# what remains to the local variable test_desc. | ||
# | ||
config_fn="config.${test_name}.sh" | ||
test_desc="" | ||
while read -r line; do | ||
gsketefian marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
regex_search="^[ ]*(#)([ ]{0,1})(.*)" | ||
hash_or_null=$( printf "%s" "${line}" | \ | ||
sed -n -r -e "s/${regex_search}/\1/p" ) | ||
# | ||
# If the current line is part of the file header containing the test | ||
# description, then... | ||
# | ||
if [ "${hash_or_null}" = "#" ]; then | ||
# | ||
# Strip from the current line any leading whitespace followed by the | ||
# hash symbol possibly followed by a single space. If what remains is | ||
# empty, it means there are no comments on that line and it is just a | ||
# separator line. In that case, simply add a newline to test_desc. | ||
# Otherwise, append what remains after stripping to what test_desc | ||
# already contains, followed by a single space in preparation for | ||
# appending the next (stripped) line. | ||
# | ||
stripped_line=$( printf "%s" "${line}" | \ | ||
sed -n -r -e "s/${regex_search}/\3/p" ) | ||
if [ -z "${stripped_line}" ]; then | ||
test_desc="\ | ||
${test_desc} | ||
|
||
" | ||
else | ||
test_desc="\ | ||
${test_desc}${stripped_line} " | ||
fi | ||
# | ||
# If the current line is not part of the file header containing the test | ||
# description, break out of the while-loop (and thus stop reading the | ||
# file). | ||
# | ||
else | ||
break | ||
fi | ||
|
||
done < "${config_fn}" | ||
# | ||
# At this point, test_desc contains a description of the current test. | ||
# Note that: | ||
# | ||
# 1) It will be empty if the configuration file for the current test | ||
# does not contain a header describing the test. | ||
# 2) It will contain newlines if the description header contained lines | ||
# that start with the hash symbol and contain no other characters. | ||
# These are used to delimit paragraphs within the description. | ||
# 3) It may contain leading and trailing whitespace. | ||
# | ||
# Next, for clarity, we remove any leading and trailing whitespace using | ||
# bash's pattern matching syntax. | ||
# | ||
# Note that the right-hand sides of the following two lines are NOT | ||
# regular expressions. They are expressions that use bash's pattern | ||
# matching syntax (gnu.org/software/bash/manual/html_node/Pattern-Matching.html, | ||
# wiki.bash-hackers.org/syntax/pattern) used in substring removal | ||
# (tldp.org/LDP/abs/html/string-manipulation.html). For example, | ||
# | ||
# ${var%%[![:space:]]*} | ||
# | ||
# says "remove from var its longest substring that starts with a non- | ||
# space character". | ||
# | ||
# First remove leading whitespace. | ||
# | ||
test_desc="${test_desc#"${test_desc%%[![:space:]]*}"}" | ||
# | ||
# Now remove trailing whitespace. | ||
# | ||
test_desc="${test_desc%"${test_desc##*[![:space:]]}"}" | ||
config_fn="config.${test_name}.yaml" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I generated a csv file containing test info and after opening it in google sheets, I found a couple of issues. At least in some places in the test descriptions, newlines are dropped and single quotes (apostrophes) are replaced with double quotes. For example, for the test
but in the csv file, it becomes:
So the newline/indentation is ignored and the apostrophes in App's User's Guide are changed to double quotes. Any chance we can fix that up? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just randomly checking other descriptions in the google sheet, I see a similar issue for the test There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @gsketefian Yes, I replace single quotes with double quotes, not only in we2e test description but also in comments in crontab contents. Usually you get empty crontab content but Venita's automated testing setup had crontab contents with comments that had single quotes. Please take a look at PR #816 that describs the issue and how I solved it. I didn't find a better solution than that at the time ... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @danielabdi-noaa In this case of the test descriptions, it doesn't seem to make sense to do that replacement. What you really want to do is take the description and put it into the csv file exactly as is. Replacing apostrophes with double quotes would be very confusing to someone reading the test description in the csv. Since this is separate from the treatment of crontab lines, is it possible to not do the replacement when dealing with these descriptions? There must be a way to just take a literal string from the yaml file (even one that includes single quotes and newlines) and place it exactly as-is into the csv. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @gsketefian I have made the we2e test description specifically (not For the record though, I liked the way it was where the test description is one long line, because, in the excel sheet it will be wrapped around cell width and looks natural. While with this new fix that keeps the format first used in the config file, widening the cell has no effect. Also now it is not consistent with the test description in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @danielabdi-noaa Sorry I wasn't clear about the newlines (or suggested the wrong thing). Yes, I like it to be one long string too (that's how it is now) because that's what works best in a spreadsheet, except when there is a blank line, which signifies a new paragraph or newline. Currently, if you have this in the description in the test config file (in bash):
it will show up like this in a cell in the spreadsheet:
So the lines without a blank line in between get concatenated into one long line, but the blank lines cause there to be a newline to be inserted. Also, the indentations for the lines |
||
config_fp="${test_configs_basedir}/$subdir/$config_fn" | ||
test_desc="$(config_to_shell_str $config_fp -k "metadata")" | ||
test_desc="${test_desc:26}" | ||
test_desc="${test_desc::${#test_desc}-1}" | ||
# | ||
# Finally, save the description of the current test as the next element | ||
# of the array prim_test_descs. | ||
|
@@ -1079,10 +994,11 @@ ${test_desc}${stripped_line} " | |
# variables specified in "vars_to_extract". Then save the value in the | ||
# arrays specified by "prim_array_names_vars_to_extract". | ||
# | ||
config_content=$(config_to_shell_str $config_fp) | ||
for (( k=0; k<=$((num_vars_to_extract-1)); k++ )); do | ||
|
||
var_name="${vars_to_extract[$k]}" | ||
cmd=$( grep "^[ ]*${var_name}=" "${config_fn}" ) | ||
cmd=$( grep "^[ ]*${var_name}=" <<< "${config_content}" ) | ||
eval $cmd | ||
|
||
if [ -z "${!var_name+x}" ]; then | ||
|
@@ -1689,49 +1605,8 @@ containing information on all WE2E tests: | |
fi | ||
|
||
if [ ! -z "${outvarname_test_descs}" ]; then | ||
# | ||
# We want to treat all characters in the test descriptions literally | ||
# when evaluating the array specified by outvarname_test_descs below | ||
# using the eval function because otherwise, characters such as "$", | ||
# "(", ")", etc will be interpreted as indicating the value of a variable, | ||
# the start of an array, the end of an array, etc, and lead to errors. | ||
# Thus, below, when forming the array that will be passed to eval, we | ||
# will surround each element of the local array test_descs in single | ||
# quotes. However, the test descriptions themselves may include single | ||
# quotes (e.g. when a description contains a phrase such as "Please see | ||
# the User's Guide for..."). In order to treat these single quotes | ||
# literally (as opposed to as delimiters indicating the start or end of | ||
# array elements), we have to pass them as separate strings by replacing | ||
# each single quote with the following series of characters: | ||
# | ||
# '"'"' | ||
# | ||
# In this, the first single quote indicates the end of the previous | ||
# single-quoted string, the "'" indicates a string containing a literal | ||
# single quote, and the last single quote inidicates the start of the | ||
# next single-quoted string. | ||
# | ||
# For example, let's assume there are only two WE2E tests to consider. | ||
# Assume the description of the first is | ||
# | ||
# Please see the User's Guide. | ||
# | ||
# and that of the second is: | ||
# | ||
# See description of ${DOT_OR_USCORE} in the configuration file. | ||
# | ||
# Then, if outvarname_test_descs is set to "some_array", the exact string | ||
# we want to pass to eval is: | ||
# | ||
# some_array=('Please see the User'"'"'s Guide.' 'See description of ${DOT_OR_USCORE} in the configuration file.') | ||
# | ||
test_descs_esc_sq=() | ||
for (( i=0; i<=$((num_tests-1)); i++ )); do | ||
test_descs_esc_sq[$i]=$( printf "%s" "${test_descs[$i]}" | \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess removal of this substitution is what's causing the apostrophes (single quotes) to become double quotes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The replacement is done whenever you produce a shell string equivalent of other formats. Bash does not like single quotes since they have been causing me problems in unexpected places (two places I already mentioned but there were of others too), so I decided to get rid of them in the config parser: # replace some problematic chars
v1 = v1.replace("'", '"')
v1 = v1.replace("\n", " ")
# end problematic
shell_str += f"{k}='{v1}'\n" Also I replace newlines with space for the same reason, without which I would not be able to store the test description in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here is an example # [metadata]
description='This test checks the capability of the workflow to have the user specify a new grid (as opposed to one of the predefined ones in the workflow) of GFDLgrid type. Note that this test sets the workflow variable GFDLgrid_USE_NUM_CELLS_IN_FILENAMES to "TRUE" (which is its default value); see the UFS SRW User"s Guide for a description of this variable. The difference between this test and the one named custom_GFDLgrid__GFDLgrid_USE_NUM_CELLS_IN_FILENAMES_eq_TRUE is that this one uses almost no stretching by setting the workflow variable GFDLgrid_STRETCH_FAC very close to 1. Setting it exactly to 1 used to cause the workflow to fail because it caused the GFDL grid generator to assume a global grid. This bug should be rechecked, e.g. by setting GFDLgrid_STRETCH_FAC to exactly 1 below. If the grid generation succeeds, then this test can be removed.'
version='1.0'
# [user]
RUN_ENVIR='community'
MACHINE='HERA'
MACHINE_FILE='/scratch2/BMC/gsd-hpcs/Daniel.Abdi/ufs-srweather-app/regional_workflow/ush/machine/hera.sh'
ACCOUNT='zrtrr'
# [platform]
WORKFLOW_MANAGER='rocoto'
NCORES_PER_NODE='40' That multiline description would cause problems if it had "single quotes" or "new line" characters. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I see. I didn't know the test description goes in |
||
sed -r -e "s/'/'\"'\"'/g" ) | ||
done | ||
test_descs_str="( "$( printf "'%s' " "${test_descs_esc_sq[@]}" )")" | ||
eval ${outvarname_test_descs}="${test_descs_str}" | ||
test_descs_str="( "$( printf "'%s' " "${test_descs[@]}" )")" | ||
eval ${output_varname_test_descs}="${test_descs_str}" | ||
fi | ||
# | ||
#----------------------------------------------------------------------- | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -712,7 +712,7 @@ for (( i=0; i<=$((num_tests_to_run-1)); i++ )); do | |
# Generate the full path to the current WE2E test's configuration file. | ||
# Then ensure that this file exists. | ||
# | ||
test_config_fp="${avail_WE2E_test_configs_basedir}/${test_subdir}/config.${test_name}.sh" | ||
test_config_fp="${avail_WE2E_test_configs_basedir}/${test_subdir}/config.${test_name}.yaml" | ||
|
||
if [ ! -f "${test_config_fp}" ]; then | ||
print_err_msg_exit "\ | ||
|
@@ -732,8 +732,8 @@ Please correct and rerun." | |
# | ||
#----------------------------------------------------------------------- | ||
# | ||
. ${ushdir}/config_defaults.sh | ||
. ${test_config_fp} | ||
source_config ${ushdir}/config_defaults.yaml | ||
source_config ${test_config_fp} | ||
# | ||
#----------------------------------------------------------------------- | ||
# | ||
|
@@ -742,7 +742,7 @@ Please correct and rerun." | |
# have. Once this variable is constructed, we will write its contents | ||
# to the generic configuration file that the experiment generation script | ||
# reads in (specified by the variable EXPT_CONFIG_FN in the default | ||
# configuration file config_defaults.sh sourced above) and then run that | ||
# configuration file config_defaults.yaml sourced above) and then run that | ||
# script to generate an experiment for the current WE2E test. | ||
# | ||
# We name the multiline variable that will contain the contents of the | ||
|
@@ -760,7 +760,7 @@ Please correct and rerun." | |
# that depend on the input arguments to this script (as opposed to | ||
# variable settings in the test configuration file specified by | ||
# test_config_fp). Note that any values of these parameters specified | ||
# in the default experiment configuration file (config_defaults.sh) | ||
# in the default experiment configuration file (config_defaults.yaml) | ||
# or in the test configuraiton file (test_config_fp) that were sourced | ||
# above will be overwritten by the settings below. | ||
# | ||
|
@@ -846,7 +846,7 @@ VERBOSE=\"${VERBOSE}\"" | |
# The following section is a copy of this WE2E test's configuration file. | ||
# | ||
" | ||
expt_config_str=${expt_config_str}$( cat "${test_config_fp}" ) | ||
expt_config_str=${expt_config_str}$( config_to_shell_str "${test_config_fp}" ) | ||
expt_config_str=${expt_config_str}" | ||
# | ||
# End of section from this test's configuration file. | ||
|
@@ -1172,14 +1172,11 @@ MAXTRIES_RUN_POST=\"${MAXTRIES_RUN_POST}\"" | |
fi | ||
# | ||
#----------------------------------------------------------------------- | ||
# | ||
# Set the full path to the configuration file that the experiment | ||
# generation script reads in. Then write the contents of expt_config_str | ||
# to that file. | ||
# | ||
# Write content to a temporary config file | ||
#----------------------------------------------------------------------- | ||
# | ||
expt_config_fp="$ushdir/${EXPT_CONFIG_FN}" | ||
temp_file="$PWD/_config_temp_.sh" | ||
expt_config_fp="${temp_file}" | ||
printf "%s" "${expt_config_str}" > "${expt_config_fp}" | ||
# | ||
#----------------------------------------------------------------------- | ||
|
@@ -1276,6 +1273,19 @@ exist or is not a directory: | |
# | ||
#----------------------------------------------------------------------- | ||
# | ||
# Set the full path to the configuration file that the experiment | ||
# generation script reads in. Then write the contents of expt_config_str | ||
# to that file. | ||
# | ||
#----------------------------------------------------------------------- | ||
# | ||
expt_config_fp="$ushdir/${EXPT_CONFIG_FN}" | ||
ext="${EXPT_CONFIG_FN##*.}" | ||
config_to_str "${ext}" "${temp_file}" -t "$ushdir/config_defaults.yaml" >"${expt_config_fp}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this a bash utility? Will that change with a transition to python? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Look into |
||
rm -rf "${temp_file}" | ||
# | ||
#----------------------------------------------------------------------- | ||
# | ||
# Call the experiment generation script to generate an experiment | ||
# directory and a rocoto workflow XML for the current WE2E test to run. | ||
# | ||
|
This file was deleted.
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.
Does this mean we have a button to run unittests on GitHub runners any time we want from any branch?
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.
That is the idea. I did check that I can manually re-run a workflow on my fork, but things could be different once it is merged here.