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] Fix issue 541: correct error message when config.yaml has invalid entries #559

Merged
merged 2 commits into from
Jan 31, 2023

Conversation

mkavulich
Copy link
Collaborator

DESCRIPTION OF CHANGES:

This is actually two fixes/enhancements, one required by the other:

  1. Fix error message that appears when user specifies an invalid key in their config.yaml file. The current version references undefined variables and appears to be a copy/paste error from some other exception.
  2. In order to achieve the above neatly, I had to change the behavior of the python_utils function check_structure_dict(). Rather than simply printing the invalid key/value pair, it now returns a dictionary of invalid key/value pairs (that is empty if all keys are valid). I also fixed a minor bug here: even though this function claimed to detect all invalid entries, it actually only printed the first before returning. Now all invalid entries are returned.

With this change users will now see the following type of error if they specify one or more invalid keys in their config.yaml file:


*********************************************************************
FATAL ERROR:
Experiment generation failed. See the error message(s) printed below.
For more detailed information, check the log file from the workflow
generation script: /glade/scratch/kavulich/workdir/UFS/issue_541/ufs-srweather-app/ush/log.generate_FV3LAM_wflow
*********************************************************************

Traceback (most recent call last):
  File "/glade/scratch/kavulich/workdir/UFS/issue_541/ufs-srweather-app/ush/./generate_FV3LAM_wflow.py", line 774, in <module>
    generate_FV3LAM_wflow(USHdir, wflow_logfile)
  File "/glade/scratch/kavulich/workdir/UFS/issue_541/ufs-srweather-app/ush/./generate_FV3LAM_wflow.py", line 70, in generate_FV3LAM_wflow
    expt_config = setup(ushdir)
  File "/glade/scratch/kavulich/workdir/UFS/issue_541/ufs-srweather-app/ush/setup.py", line 297, in setup
    expt_config = load_config_for_setup(USHdir, default_config_fp, user_config_fp)
  File "/glade/scratch/kavulich/workdir/UFS/issue_541/ufs-srweather-app/ush/setup.py", line 89, in load_config_for_setup
    raise Exception(errmsg)
Exception: Invalid key(s) specified in {user_config}:
badvalue1 = bad
badvalue2 = 2019061500
badvalue3 = False

Check /glade/scratch/kavulich/workdir/UFS/issue_541/ufs-srweather-app/ush/config_defaults.yaml for allowed user-specified variables

Type of change

  • Bug fix (non-breaking change which fixes an issue)

TESTS CONDUCTED:

Ran unit tests for python_utils which were successful. Ran several iterations of incorrect config.yaml entries on Hera and Cheyenne, which produced expected results. Also ran fundamental suite of tests on Hera as a sanity check, but this change should not impact correctly configured runs.

  • hera.intel
  • orion.intel
  • cheyenne.intel
  • cheyenne.gnu
  • gaea.intel
  • jet.intel
  • wcoss2.intel
  • NOAA Cloud (indicate which platform)
  • Jenkins
  • fundamental test suite
  • comprehensive tests (specify which if a subset was used)

DEPENDENCIES:

None

DOCUMENTATION:

None

ISSUE:

Fixes #541

CHECKLIST

  • My code follows the style guidelines in the Contributor's Guide
  • I have performed a self-review of my own code using the Code Reviewer's Guide
  • I have commented my code, particularly in hard-to-understand areas
  • My changes need updates to the documentation. I have made corresponding changes to the documentation
  • My changes do not require updates to the documentation (explain).
  • My changes generate no new warnings
  • New and existing tests pass with my changes
  • Any dependent changes have been merged and published

CONTRIBUTORS:

Thank you to @zmoon for taking the time to open an issue describing this problem.

1. Fix error message that appears when user specifies an invalid key in
their config.yaml file.

2. In order to achieve the above neatly, I had to change the behavior of
check_structure_dict in python_utils. Rather than simply printing the
invalid key/value pair, it now returns a dictionary of invalid key/value
pairs (that is empty if all keys are valid). I also fixed a minor bug
here: even though this function *claimed* to detect all invalid entries,
it actually only printed the first before returning. Now all invalid
entries are returned.
@mkavulich mkavulich changed the title Fix issue 541: correct error message when config.yaml has invalid entries [develop] Fix issue 541: correct error message when config.yaml has invalid entries Jan 25, 2023
@mkavulich
Copy link
Collaborator Author

Note: The unit test failure appears to be a known issue introduced in #536

Copy link
Collaborator

@MichaelLueken MichaelLueken left a comment

Choose a reason for hiding this comment

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

@mkavulich These changes look good to me! Approving now and then will launch the Jenkins tests.

@MichaelLueken MichaelLueken added the run_we2e_coverage_tests Run the coverage set of SRW end-to-end tests label Jan 26, 2023
Suggestions for correct docstring style from @zmoon

Co-authored-by: Zachary Moon <[email protected]>
@MichaelLueken MichaelLueken merged commit fc72f4e into ufs-community:develop Jan 31, 2023
@mkavulich mkavulich deleted the feature/fix_issue_541 branch July 19, 2023 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
run_we2e_coverage_tests Run the coverage set of SRW end-to-end tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug in create workflow config check for invalid key
4 participants