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

[develop]: Use yaml format for specifying experiment parameters #778

Merged
Merged
Show file tree
Hide file tree
Changes from 72 commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
b4b7acd
Construct var_defns components from dictionary.
danielabdi-noaa May 26, 2022
b013305
Bring back config_defaults.yaml
danielabdi-noaa May 23, 2022
52e5f50
Add support for sourcing yaml file into shell script.
danielabdi-noaa May 20, 2022
7e1e8c3
Remove newline for printing config, json config fix.
danielabdi-noaa May 20, 2022
9a8ebd3
Make QUILTING a sub-dictionary in predef_grids
danielabdi-noaa May 20, 2022
547e80f
Reorganize config_defaults.yaml by task and feature.
danielabdi-noaa May 21, 2022
49d5ac3
Bug fix with QUILTING=true.
danielabdi-noaa May 21, 2022
f65421a
Structure a dictionary based on a template dictionary.
danielabdi-noaa May 21, 2022
ce81c00
Convert all WE2E config files to yaml.
danielabdi-noaa May 21, 2022
b40e528
Take care of problematic chars when converting to shell string.
danielabdi-noaa May 22, 2022
55b0870
Process only selected keys of config.
danielabdi-noaa May 22, 2022
025351a
Add symlinked yaml config files.
danielabdi-noaa May 22, 2022
e7b334b
Actually use yaml config files for WE2E tests.
danielabdi-noaa May 22, 2022
ee43bc4
Delete all shell WE2E configs.
danielabdi-noaa May 22, 2022
6502f60
Don't check for single quotes in test description.
danielabdi-noaa May 22, 2022
713ca6f
Make WE2E work with yaml configs.
danielabdi-noaa May 22, 2022
3e2f19f
Make yaml default config format.
danielabdi-noaa May 22, 2022
0694445
Bug fix in run_WE2E script.
danielabdi-noaa May 23, 2022
79abed8
Add utility to check validity of yaml config file.
danielabdi-noaa May 23, 2022
0c4e822
Add config utility interface in ush directory.
danielabdi-noaa May 23, 2022
b232b71
Remove unused check_expt_config_vars script.
danielabdi-noaa May 23, 2022
34a5241
Add description to default config.
danielabdi-noaa May 23, 2022
7267e5a
Reorganize source_config.
danielabdi-noaa May 24, 2022
ff858e9
Add XML as one of the config formats.
danielabdi-noaa May 24, 2022
4aa3631
Update custom_ESGgrid config.
danielabdi-noaa May 25, 2022
b84c763
Bug fix due to update.
danielabdi-noaa May 25, 2022
f13554c
Change ensemble seed.
danielabdi-noaa Jun 2, 2022
ec88007
Change POST_OUTPUT group due to merge.
danielabdi-noaa Jun 4, 2022
b71fee5
Make xml and ini configs work.
danielabdi-noaa Jun 5, 2022
bbbe9a9
Maintain config structure down to var_defns.
danielabdi-noaa Jun 5, 2022
9a75311
Add function to load structured shell config, put description under m…
danielabdi-noaa Jun 6, 2022
871cfc0
Flatten dicts before importing env now that shell config is structured.
danielabdi-noaa Jun 6, 2022
4fd683d
Support python regex for selecting dict keys.
danielabdi-noaa Jun 7, 2022
abe6733
Add capability of sourcing task specific portion of config file.
danielabdi-noaa Jun 7, 2022
86ef28e
Access var_defns via env variable.
danielabdi-noaa Jun 8, 2022
b02e7f5
Make names of tasks consistent with ex- and j- job script names.
danielabdi-noaa Jun 7, 2022
0ba2a25
Append pid to temp file.
danielabdi-noaa Jun 8, 2022
d2cad87
Prettify user config, don't use " in xml texts.
danielabdi-noaa Jun 8, 2022
298ba67
Compare timestamp of csv vs all files instead of directory.
danielabdi-noaa Jun 8, 2022
15265db
Fixes for some pylint suggestions.
danielabdi-noaa Jun 12, 2022
84c16fd
Convert new configs to yaml.
danielabdi-noaa Jun 12, 2022
47e4ea8
Format python files with black (no functional change).
danielabdi-noaa Jun 15, 2022
71abc8f
More readable yaml/json formats by using more data types.
danielabdi-noaa Jun 16, 2022
9fe6941
More readable yaml config files for WE2E and default configs.
danielabdi-noaa Jun 16, 2022
b21fe09
Make config_defaults itself more readable.
danielabdi-noaa Jun 16, 2022
ad07c5b
Correct pyyaml list indentation issue.
danielabdi-noaa Jun 16, 2022
ab21405
Fix indentation in all config files.
danielabdi-noaa Jun 16, 2022
d4f62d3
Use unquoted WTIME in config_defaults
danielabdi-noaa Jun 16, 2022
9b818b5
Cosmotic changes.
danielabdi-noaa Jun 16, 2022
41c46ab
Fix due to merge.
danielabdi-noaa Jun 24, 2022
a1735b4
Make __init__.py clearer.
danielabdi-noaa Jun 25, 2022
6cd51a3
Fixes due to merge.
danielabdi-noaa Jun 27, 2022
7d2f5e9
Minor edits of comments.
danielabdi-noaa Jul 18, 2022
c9e9844
Remove wcoss_dell_p3 from workflow (#810)
chan-hoo Jul 19, 2022
10cb19b
Replace deprecated NCAR python environment with conda on Cheyenne (#812)
mkavulich Jul 21, 2022
4adbd82
Fix issue on get_extrn_lbcs when FCST_LEN_HRS>=40 with netcdf (#814)
chan-hoo Jul 22, 2022
b215cae
Merge branch 'develop' into feature/yaml_configs
danielabdi-noaa Jul 27, 2022
283e2d9
Convert new test case to yaml.
danielabdi-noaa Jul 27, 2022
0a0f7bd
Merge branch 'develop' into feature/yaml_configs
danielabdi-noaa Aug 9, 2022
d18dc0a
Fix formatting due to merge.
danielabdi-noaa Aug 9, 2022
41264ad
Convert new test case to yaml.
danielabdi-noaa Aug 9, 2022
7ad8498
Fix unittest.
danielabdi-noaa Aug 9, 2022
860bf82
Merge develop
danielabdi-noaa Aug 14, 2022
98d9a72
Merge branch 'develop' into feature/yaml_configs
danielabdi-noaa Aug 14, 2022
4f4d5c5
Remove exception logic from __init__.py
danielabdi-noaa Aug 17, 2022
46d9f17
Minor change to cmd concat.
danielabdi-noaa Aug 17, 2022
8bd7211
Make grid gen methods return dictionary, simplifis code a lot.
danielabdi-noaa Aug 17, 2022
1cf6f01
Add a comment why we are suppressing yaml import exception.
danielabdi-noaa Aug 17, 2022
15a1207
Minor change to beautify unittest output.
danielabdi-noaa Aug 17, 2022
f30bff0
Add status badge for functional tests.
danielabdi-noaa Aug 18, 2022
a6fb3ae
Merge branch 'develop' into feature/yaml_configs
danielabdi-noaa Aug 19, 2022
06e01e5
Merge branch 'develop' into feature/yaml_configs
danielabdi-noaa Aug 29, 2022
52a999b
Reorder tasks in config_default and we2e test cases to match order in…
danielabdi-noaa Sep 6, 2022
1fc7791
Keep single quotes and newlines in we2e test description.
danielabdi-noaa Sep 7, 2022
9b85b39
Revert back to not rounding to 10 digits
danielabdi-noaa Sep 7, 2022
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 .github/workflows/python_func_tests.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Python unittests
name: Python functional tests
on:
push:
paths:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python_unittests.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Python unittests
on: [push, pull_request]
on: [push, pull_request, workflow_dispatch]
Copy link
Contributor

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?

Copy link
Collaborator Author

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.

jobs:

python_unittests:
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[![Python unittests](https://github.com/ufs-community/regional_workflow/actions/workflows/python_unittests.yaml/badge.svg)](https://github.com/ufs-community/regional_workflow/actions/workflows/python_unittests.yaml)
[![Python functional tests](https://github.com/ufs-community/regional_workflow/actions/workflows/python_func_tests.yaml/badge.svg)](https://github.com/ufs-community/regional_workflow/actions/workflows/python_func_tests.yaml)

# Regional Workflow

Expand Down
2 changes: 1 addition & 1 deletion scripts/exregional_make_grid.sh
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ halo failed."
#
#-----------------------------------------------------------------------
#
python3 $USHDIR/link_fix.py \
python3 $USHDIR/link_fix.py \
--path-to-defns ${GLOBAL_VAR_DEFNS_FP} \
--file-group "grid" || \
print_err_msg_exit "\
Expand Down
2 changes: 1 addition & 1 deletion scripts/exregional_make_orog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ cd_vrfy -
#
#-----------------------------------------------------------------------
#
python3 $USHDIR/link_fix.py \
python3 $USHDIR/link_fix.py \
--path-to-defns ${GLOBAL_VAR_DEFNS_FP} \
--file-group "orog" || \
print_err_msg_exit "\
Expand Down
2 changes: 1 addition & 1 deletion scripts/exregional_make_sfc_climo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ esac
#
#-----------------------------------------------------------------------
#
python3 $USHDIR/link_fix.py \
python3 $USHDIR/link_fix.py \
--path-to-defns ${GLOBAL_VAR_DEFNS_FP} \
--file-group "sfc_climo" || \
print_err_msg_exit "\
Expand Down
165 changes: 20 additions & 145 deletions tests/WE2E/get_WE2Etest_names_subdirs_descs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
#
#-----------------------------------------------------------------------
#
Expand Down Expand Up @@ -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 "
Expand Down Expand Up @@ -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" )
#
Expand Down Expand Up @@ -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[@]}" ))
Expand Down Expand Up @@ -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"
Copy link
Collaborator

Choose a reason for hiding this comment

The 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 custom_GFDLgrid__GFDLgrid_USE_NUM_CELLS_IN_FILENAMES_eq_TRUE, the description in the yaml file is:

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 "FALSE"; see the UFS SRW App's User's Guide for a description of
    this variable.

but in the csv file, it becomes:

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 "FALSE"; see the UFS SRW App"s User"s Guide for a description of this variable.

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?

Copy link
Collaborator

@gsketefian gsketefian Sep 6, 2022

Choose a reason for hiding this comment

The 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 deactivate_tasks: extra spaces added and newlines ignored. Is there a way to have yaml treat the description verbatim?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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 ...

Copy link
Collaborator

Choose a reason for hiding this comment

The 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.

Copy link
Collaborator Author

@danielabdi-noaa danielabdi-noaa Sep 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gsketefian I have made the we2e test description specifically (not var_defns.sh or other places) to keep existing single quotes and new lines. Pyyamls folds newlines when >- is used for multiline string, so I had to replace that with |-. Even then when you write the multiline string back with yaml.dump it will not keep the format. I needed to use a hack to make pyyaml use block format when dumping multiline strings, but seems to work fine now.

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 var_defns.sh, that must replace single quotes and newlines to work properly. In any case, please test it and let me know what you think about it.

Copy link
Collaborator

Choose a reason for hiding this comment

The 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):

# Hello there.  This is a description of 
# this test.  Define a couple of variables:
#
#   MY_VAR1 = "abcd"
#   MY_VAR2 = "efgh${MY_VAR1}"
#   MY_VAR3 = 'klmn${MY_VAR2}'
#
# Done with description.

it will show up like this in a cell in the spreadsheet:

Hello there.  This is a description of this test.  Define a variable:

  MY_VAR1 = "abcd"
  MY_VAR2 = "efgh${MY_VAR1}"
  MY_VAR3 = 'klmn${MY_VAR2}'

Done with description.

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 MY_VAR... = ... are kept, and no changes are made to single and double quotes. Maybe there is a way to specify a newline character, e.g. \n, so it can be used only where required (i.e. where we want a blank line). Anyway, I'll leave it up to you to decide what is best. Feel free to change the |- back to >- (I actually prefer that).

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.
Expand All @@ -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
Expand Down Expand Up @@ -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]}" | \
Copy link
Collaborator

Choose a reason for hiding this comment

The 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.

Copy link
Collaborator Author

@danielabdi-noaa danielabdi-noaa Sep 6, 2022

Choose a reason for hiding this comment

The 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 var_defns.sh. It is debatable whether that is needed there but new lines and single quotes in strings does cause lots of problems in bash scripts.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is an example var_denfs.sh file with a test description

# [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.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I see. I didn't know the test description goes in var_defns.sh. It didn't used to and it's not necessary since it's not used by any tasks (as far as I know), but that's fine if you feel it should be there. And yes, it would be a problem to have single quotes and newlines in there. I wonder if you can escape them. But I'll leave it up to you how you want to handle it (also see my other comment above in this file).

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
#
#-----------------------------------------------------------------------
Expand Down
34 changes: 22 additions & 12 deletions tests/WE2E/run_WE2E_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 "\
Expand All @@ -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}
#
#-----------------------------------------------------------------------
#
Expand All @@ -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
Expand All @@ -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.
#
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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}"
#
#-----------------------------------------------------------------------
Expand Down Expand Up @@ -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}"
Copy link
Contributor

Choose a reason for hiding this comment

The 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?

Copy link
Collaborator Author

@danielabdi-noaa danielabdi-noaa Jun 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look into bash_utils/source_config.sh file I added for handling different config formats. The file is just a wrapper for whatever functionality is present in main of python_utils/config_parser.py.

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.
#
Expand Down

This file was deleted.

Loading