From 3c1e081bb1ceb53dea4b958b794893bdde49a44b Mon Sep 17 00:00:00 2001 From: George McCabe <23407799+georgemccabe@users.noreply.github.com> Date: Wed, 4 Oct 2023 15:35:25 -0600 Subject: [PATCH] per #2349, improve error message for deprecated env vars to list files to compare and link to upgrade instructions in METplus User's Guide --- metplus/util/config_validate.py | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/metplus/util/config_validate.py b/metplus/util/config_validate.py index 1ba275336e..b3d0992c65 100644 --- a/metplus/util/config_validate.py +++ b/metplus/util/config_validate.py @@ -183,13 +183,25 @@ def check_for_deprecated_met_config_file(config, met_config, met_tool): if '${' + deprecated_item + '}' not in line: continue all_good = False - config.logger.error("Deprecated environment variable" - f" ${{{deprecated_item}}} found in MET config " - f"file: {met_config}. Please unset " - f"{met_tool}_CONFIG_FILE to use the wrapped " - "MET config that is provided with the " - "METplus wrappers and set values that differ " - "from the defaults in a METplus config file.") + config.logger.error( + f"Deprecated environment variable ${{{deprecated_item}}} found " + f"in MET config file: {met_config}" + ) + + if not all_good: + met_install_dir = config.getdir('MET_INSTALL_DIR') + config_dir = os.path.join(met_install_dir, 'share', 'met', 'config') + default_config = f"{get_wrapper_name(met_tool)}Config_default" + default_path = os.path.join(config_dir, default_config) + config.logger.error( + "Please set values that differ from the defaults in a METplus " + f"config file and unset {met_tool}_CONFIG_FILE to use the " + "wrapped MET config that is provided with the METplus wrappers." + f" Compare values set in {met_config} to {default_path}. " + "See https://metplus.readthedocs.io/en/latest/Users_Guide/" + "release-notes.html#metplus-wrappers-upgrade-instructions" + " for more information." + ) return all_good