Skip to content

Commit

Permalink
per #2460, start to implement logic to prevent errors when some input…
Browse files Browse the repository at this point in the history
… files are not found
  • Loading branch information
georgemccabe committed Jan 25, 2024
1 parent 8bc5895 commit b4fad5a
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions internal/tests/pytests/util/run_util/test_run_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
'METPLUS_BASE',
'PARM_BASE',
'METPLUS_VERSION',
'ALLOW_MISSING_INPUTS',
'INPUT_THRESH',
]


Expand Down
1 change: 1 addition & 0 deletions metplus/wrappers/extract_tiles_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ def run_at_time_once(self, time_info):
location_input = self.c_dict.get('LOCATION_INPUT')
input_path = self.get_location_input_file(time_info, location_input)
if not input_path:
self.missing_input_count += 1
return

# get unique storm ids or object cats from the input file
Expand Down
1 change: 1 addition & 0 deletions metplus/wrappers/pcp_combine_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,7 @@ def setup_derive_method(self, time_info, lookback, data_src):
data_type=data_src,
return_list=True)
if not input_files:
self.missing_input_count += 1
return None

files_found = []
Expand Down
13 changes: 13 additions & 0 deletions metplus/wrappers/runtime_freq_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ class RuntimeFreqWrapper(CommandBuilder):

def __init__(self, config, instance=None):
super().__init__(config, instance=instance)
self.run_count = 0
self.missing_input_count = 0

def create_c_dict(self):
c_dict = super().create_c_dict()
Expand All @@ -59,6 +61,13 @@ def create_c_dict(self):
)
self.validate_runtime_freq(c_dict)

# check if missing inputs are allowed and threshold of missing inputs
name = 'ALLOW_MISSING_INPUTS'
c_dict[name] = self.get_wrapper_or_generic_config(name, 'bool')
if c_dict[name]:
name = 'INPUT_THRESH'
c_dict[name] = self.get_wrapper_or_generic_config(name, 'float')

return c_dict

def validate_runtime_freq(self, c_dict):
Expand Down Expand Up @@ -195,6 +204,7 @@ def run_once(self, custom):
return None

self.clear()
self.run_count += 1
return self.run_at_time_once(time_info)

def run_once_per_init_or_valid(self, custom):
Expand Down Expand Up @@ -222,6 +232,7 @@ def run_once_per_init_or_valid(self, custom):
self.c_dict['ALL_FILES'] = self.get_all_files_from_leads(time_info)

self.clear()
self.run_count += 1
if not self.run_at_time_once(time_info):
success = False

Expand Down Expand Up @@ -253,6 +264,7 @@ def run_once_per_lead(self, custom):
self.c_dict['ALL_FILES'] = self.get_all_files_for_lead(time_info)

self.clear()
self.run_count += 1
if not self.run_at_time_once(time_info):
success = False

Expand Down Expand Up @@ -307,6 +319,7 @@ def run_at_time(self, input_dict):

# Run for given init/valid time and forecast lead combination
self.clear()
self.run_count += 1
if not self.run_at_time_once(time_info):
success = False

Expand Down
7 changes: 7 additions & 0 deletions parm/metplus_config/defaults.conf
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ GFDL_TRACKER_EXEC = /path/to/standalone_gfdl-vortextracker_v3.9a/trk_exec
# that value will be used instead of the value set in this file. #
# * SCRUB_STAGING_DIR removes intermediate files generated by a METplus run #
# Set to False to preserve these files #
# * ALLOW_MISSING_INPUTS determines if an error should be reported if input #
# files are not found, or if a warning should be reported instead #
# * INPUT_THRESH specifies the percentage (0-1) of inputs that must be #
# found to prevent an error (only used if ALLOW_MISSING_INPUTS=True) #
###############################################################################

PROCESS_LIST = Usage
Expand All @@ -73,6 +77,9 @@ OMP_NUM_THREADS = 1

SCRUB_STAGING_DIR = True

ALLOW_MISSING_INPUTS = False
INPUT_THRESH = 0.0


###############################################################################
# Log File Information (Where to write logs files) #
Expand Down

0 comments on commit b4fad5a

Please sign in to comment.