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

Feature #1829 set unique ID in config #1830

Merged
merged 4 commits into from
Oct 4, 2022
Merged
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
13 changes: 13 additions & 0 deletions docs/Users_Guide/glossary.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
22 changes: 5 additions & 17 deletions metplus/util/config_metplus.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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')]

Expand Down
25 changes: 25 additions & 0 deletions metplus/util/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
]