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

Bug in create workflow config check for invalid key #541

Closed
zmoon opened this issue Jan 17, 2023 · 1 comment · Fixed by #559
Closed

Bug in create workflow config check for invalid key #541

zmoon opened this issue Jan 17, 2023 · 1 comment · Fixed by #559
Assignees
Labels
bug Something isn't working

Comments

@zmoon
Copy link
Contributor

zmoon commented Jan 17, 2023

If the config check finds an invalid key, we get UnboundLocalError: local variable 'key' referenced before assignment, since key is not defined. EXPT_DEFAULT_CONFIG_FN is also not defined.

# Make sure the keys in user config match those in the default
# config.
if not check_structure_dict(cfg_u, cfg_d):
raise Exception(
dedent(
f"""
User-specified variable "{key}" in {user_config} is not valid
Check {EXPT_DEFAULT_CONFIG_FN} for allowed user-specified variables\n
"""
)
)

cc: @drnimbusrain

Expected behavior

It would be better if the info about the invalid key were included in the error message, instead of as a normal print higher up in the log. (And better if the error message worked properly.)

Current behavior

Example
> ./generate_FV3LAM_wflow.py

  ========================================================================
  Starting experiment generation...
  ========================================================================

  ========================================================================
  Starting function setup() in "setup.py"...
  ========================================================================
INVALID ENTRY: RESTART_WORKFLOW=True

*********************************************************************
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: /scratch2/NAGAPE/arl/Zachary.Moon/git/ufs-srweather-app_arl/ush/log.generate_FV3LAM_wflow
*********************************************************************

Traceback (most recent call last):
  File "/scratch2/NAGAPE/arl/Zachary.Moon/git/ufs-srweather-app_arl/ush/./generate_FV3LAM_wflow.py", line 822, in <module>
    generate_FV3LAM_wflow(USHdir, wflow_logfile)
  File "/scratch2/NAGAPE/arl/Zachary.Moon/git/ufs-srweather-app_arl/ush/./generate_FV3LAM_wflow.py", line 70, in generate_FV3LAM_wflow
    expt_config = setup(ushdir)
  File "/scratch2/NAGAPE/arl/Zachary.Moon/git/ufs-srweather-app_arl/ush/setup.py", line 299, in setup
    expt_config = load_config_for_setup(USHdir, default_config_fp, user_config_fp)
  File "/scratch2/NAGAPE/arl/Zachary.Moon/git/ufs-srweather-app_arl/ush/setup.py", line 87, in load_config_for_setup
    User-specified variable "{key}" in {user_config} is not valid
UnboundLocalError: local variable 'key' referenced before assignment

Machines affected

I assume all, but tested on Hera.

Steps To Reproduce

Run generate workflow with a config.yaml that has a key that isn't in the default config file.

Detailed Description of Fix (optional)

Additional Information (optional)

Possible Implementation (optional)

Output (optional)

@mkavulich
Copy link
Collaborator

@zmoon Thank you for taking the time to open this issue. I have opened a PR for a fix here: #559

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants