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

Improve validation error #320

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions tests/integration/template_complete_run.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ www = "#expand user_www#zppy_test_complete_run_www"
[climo]
active = True
walltime = "00:30:00"
years = "1850:1854:2", "1850:1854:4",
years = "1850:1854:2", "1850:1854:4"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Launches the following:

climo_atm_monthly_180x360_aave_1850-1851
climo_atm_monthly_180x360_aave_1852-1853
climo_atm_monthly_180x360_aave_1850-1853
climo_atm_monthly_diurnal_8xdaily_180x360_aave_1850-1851
climo_atm_monthly_diurnal_8xdaily_180x360_aave_1852-1853
climo_atm_monthly_diurnal_8xdaily_180x360_aave_1850-1853

Both the "1850:1854:2" (2-year increment) jobs and the "1850:1854:4" (4-year increment) jobs are launched successfully. Does this mean the trailing comma is no longer a requirement of string_list parameters?


[[ atm_monthly_180x360_aave ]]
frequency = "monthly"
Expand All @@ -25,9 +25,9 @@ years = "1850:1854:2", "1850:1854:4",
vars = "PRECT"

[ts]
active = True
active = 4
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Causes ValueError: Invalid value 4 for 'active' at runtime rather than a failed configuration validation.

walltime = "00:30:00"
years = "1850:1854:2",
years = "1850:1854:2"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If active = True above, then the error we get here is ValueError: Error interpreting years 1. climo's multiple year sets above no longer appear to need a trailing comma. However, this error seems to indicate at least one comma must be present in a string_list parameter.


[[ atm_monthly_180x360_aave ]]
frequency = "monthly"
Expand Down
7 changes: 6 additions & 1 deletion zppy/__main__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import argparse
import errno
import os
import pprint
from typing import List

from configobj import ConfigObj
Expand Down Expand Up @@ -167,8 +168,12 @@ def _validate_config(config):
validator = Validator()

result = config.validate(validator)
print(type(result))
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

result is a bool now. In the past, it has historically been some sort of dictionary or dictionary-like object. For example, from a validation failure discussed in a 3/22 Slack message, we had:

Validation results={'e3sm_diags': True, 'e3sm_diags_vs_model': True, 'mpas_analysis': True, 'default': True, 'climo': {'qos': True, 'nodes': True, 'walltime': True, 'input_files': True, 'fre
quency': True, 'mapping_file': True, 'grid': True, 'years': False, 'exclude': True, 'vars': True, 'atm_monthly_180x360_aave': True}, 'ts': True, 'tc_analysis': True, 'amwg': True, 'global_ti
me_series': {'input_subdir': True, 'qos': True, 'nodes': True, 'walltime': True, 'color': True, 'years': True, 'ts_num_years': True, 'figstr': True, 'moc_file': True, 'experiment_name': True
, 'ts_years': False, 'climo_years': False, 'atmosphere_only': True}}

if result is not True:
print("Validation results={}".format(result))
printer = pprint.PrettyPrinter(depth=3)
print("Validation results:")
printer.pprint(result)
# print("Validation results={}".format(result))
raise ValueError(
"Configuration file validation failed. Parameters listed as false in the validation results have invalid values."
)
Expand Down