diff --git a/docs/Users_Guide/glossary.rst b/docs/Users_Guide/glossary.rst index dbe419ef6e..552ebafbf4 100644 --- a/docs/Users_Guide/glossary.rst +++ b/docs/Users_Guide/glossary.rst @@ -9901,6 +9901,19 @@ METplus Configuration Glossary | *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 + ENSEMBLE_STAT_NC_ORANK_FLAG_LATLON Specify the value for 'nc_orank_flag.latlon' in the MET configuration file for EnsembleStat. diff --git a/metplus/util/config_metplus.py b/metplus/util/config_metplus.py index feea916bc2..875cde963e 100644 --- a/metplus/util/config_metplus.py +++ b/metplus/util/config_metplus.py @@ -18,9 +18,11 @@ import shutil from configparser import ConfigParser, NoOptionError from pathlib import Path +import uuid 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 @@ -242,6 +244,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 @@ -523,23 +528,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', +]