From 0272458ba677cbbdbb8e7c0d55d39f8c7a60bd4d Mon Sep 17 00:00:00 2001 From: George McCabe <23407799+georgemccabe@users.noreply.github.com> Date: Fri, 9 Sep 2022 13:19:18 -0600 Subject: [PATCH 1/3] set RUN_ID config variable with a unique 8 character hash to easily discern multiple METplus runs that may have the same timestamp --- metplus/util/config_metplus.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/metplus/util/config_metplus.py b/metplus/util/config_metplus.py index 316a8c5349..3056aaccb3 100644 --- a/metplus/util/config_metplus.py +++ b/metplus/util/config_metplus.py @@ -17,6 +17,7 @@ import shutil from configparser import ConfigParser, NoOptionError from pathlib import Path +import uuid from produtil.config import ProdConfig @@ -238,6 +239,9 @@ def launch(config_list): # save list of user configuration files in a variable config.set('config', 'CONFIG_INPUT', ','.join(config_format_list)) + # save unique identifier for the METplus run + config.set('config', 'RUN_ID', str(uuid.uuid4())[0:8]) + # get OUTPUT_BASE to make sure it is set correctly so the first error # that is logged relates to OUTPUT_BASE, not LOG_DIR, which is likely # only set incorrectly because OUTPUT_BASE is set incorrectly From 43e129cecfb194e9007d5695e81e48fcf7efcc5a Mon Sep 17 00:00:00 2001 From: George McCabe <23407799+georgemccabe@users.noreply.github.com> Date: Fri, 9 Sep 2022 13:20:52 -0600 Subject: [PATCH 2/3] moved list of runtime configs to constants file and added RUN_ID and FILE_LISTS_DIR --- metplus/util/config_metplus.py | 18 +----------------- metplus/util/constants.py | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/metplus/util/config_metplus.py b/metplus/util/config_metplus.py index 3056aaccb3..33bb2d8fd4 100644 --- a/metplus/util/config_metplus.py +++ b/metplus/util/config_metplus.py @@ -21,6 +21,7 @@ from produtil.config import ProdConfig +from .constants import RUNTIME_CONFS from . import met_util as util from .string_template_substitution import get_tags, do_string_sub from .met_util import is_python_script, format_var_items @@ -519,23 +520,6 @@ def move_runtime_configs(self): """ from_section = 'config' to_section = 'runtime' - RUNTIME_CONFS = [ - 'CLOCK_TIME', - 'METPLUS_VERSION', - 'MET_INSTALL_DIR', - 'CONFIG_INPUT', - 'METPLUS_CONF', - 'TMP_DIR', - 'STAGING_DIR', - 'CONVERT', - 'GEMPAKTOCF_JAR', - 'GFDL_TRACKER_EXEC', - 'INPUT_MUST_EXIST', - 'USER_SHELL', - 'DO_NOT_RUN_EXE', - 'SCRUB_STAGING_DIR', - 'MET_BIN_DIR', - ] more_run_confs = [item for item in self.keys(from_section) if item.startswith('LOG') or item.endswith('BASE')] diff --git a/metplus/util/constants.py b/metplus/util/constants.py index 7e7d9cd9f0..76f5b6966c 100644 --- a/metplus/util/constants.py +++ b/metplus/util/constants.py @@ -35,3 +35,28 @@ 'Example', 'CyclonePlotter', ) + +# configuration variables that are specific to a given run +# these are copied from [config] to [runtime] at the +# end of the run so they will not be read if the final +# config file is passed back into METplus but they will +# still be available to review +RUNTIME_CONFS = [ + 'RUN_ID', + 'CLOCK_TIME', + 'METPLUS_VERSION', + 'MET_INSTALL_DIR', + 'CONFIG_INPUT', + 'METPLUS_CONF', + 'TMP_DIR', + 'STAGING_DIR', + 'FILE_LISTS_DIR', + 'CONVERT', + 'GEMPAKTOCF_JAR', + 'GFDL_TRACKER_EXEC', + 'INPUT_MUST_EXIST', + 'USER_SHELL', + 'DO_NOT_RUN_EXE', + 'SCRUB_STAGING_DIR', + 'MET_BIN_DIR', +] From 11ca5e4cb1751d4da385a5fcd5eebc6c8a2d7663 Mon Sep 17 00:00:00 2001 From: George McCabe <23407799+georgemccabe@users.noreply.github.com> Date: Fri, 9 Sep 2022 13:27:35 -0600 Subject: [PATCH 3/3] added glossary entry for new RUN_ID config variable --- docs/Users_Guide/glossary.rst | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docs/Users_Guide/glossary.rst b/docs/Users_Guide/glossary.rst index b2a4501c91..490576fdaa 100644 --- a/docs/Users_Guide/glossary.rst +++ b/docs/Users_Guide/glossary.rst @@ -9937,3 +9937,16 @@ METplus Configuration Glossary See :ref:`Overriding Unsupported MET config file settings` for more information | *Used by:* PlotPointObs + + RUN_ID + Eight character hash string unique to a given run of METplus. + Automatically set by METplus at the beginning of a run. + Can be referenced in other METplus config variables to distinguish + multiple METplus runs that may have started within the same second. + For example, it can be added to :term:`LOG_TIMESTAMP_TEMPLATE` to + create unique log files, final config files, etc. + + Example: + LOG_TIMESTAMP_TEMPLATE = %Y%m%d%H%M%S.{RUN_ID} + + | *Used by:* All