Skip to content

Commit

Permalink
per #2460, change warning messages to debug when checking a list of D…
Browse files Browse the repository at this point in the history
…A offsets since it is common that a given offset will not always be found in the files
  • Loading branch information
georgemccabe committed Jan 31, 2024
1 parent e98f8f9 commit 44c828e
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions metplus/wrappers/command_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ def find_obs_offset(self, time_info, mandatory=True, return_list=False):
# errors when searching through offset list
is_mandatory = mandatory if offsets == [0] else False

self.c_dict['SUPRESS_WARNINGS'] = True
for offset in offsets:
time_info['offset_hours'] = offset
time_info = ti_calculate(time_info)
Expand All @@ -447,8 +448,11 @@ def find_obs_offset(self, time_info, mandatory=True, return_list=False):
return_list=return_list)

if obs_path is not None:
self.c_dict['SUPRESS_WARNINGS'] = False
return obs_path, time_info

self.c_dict['SUPRESS_WARNINGS'] = False

# if no files are found return None
# if offsets are specified, log error with list offsets used
log_message = "Could not find observation file"
Expand Down Expand Up @@ -566,7 +570,10 @@ def _find_exact_file(self, level, data_type, time_info, mandatory=True,
if (not mandatory
or not self.c_dict.get('MANDATORY', True)
or self.c_dict.get('ALLOW_MISSING_INPUTS', False)):
self.logger.warning(msg)
if self.c_dict.get('SUPRESS_WARNINGS', False):
self.logger.debug(msg)
else:
self.logger.warning(msg)
else:
self.log_error(msg)

Expand Down Expand Up @@ -670,7 +677,12 @@ def _check_that_files_exist(self, check_file_list, data_type, allow_dir,
if (not mandatory
or not self.c_dict.get('MANDATORY', True)
or self.c_dict.get('ALLOW_MISSING_INPUTS', False)):
self.logger.warning(msg)

if self.c_dict.get('SUPRESS_WARNINGS', False):
self.logger.debug(msg)
else:
self.logger.warning(msg)

if self.c_dict.get(f'{data_type}FILL_MISSING'):
found_file_list.append(f'MISSING{file_path}')
continue
Expand Down Expand Up @@ -716,7 +728,12 @@ def _find_file_in_window(self, data_type, time_info, mandatory=True,
if (not mandatory
or not self.c_dict.get('MANDATORY', True)
or self.c_dict.get('ALLOW_MISSING_INPUTS', False)):
self.logger.warning(msg)

if self.c_dict.get('SUPRESS_WARNINGS', False):
self.logger.debug(msg)
else:
self.logger.warning(msg)

else:
self.log_error(msg)

Expand Down

0 comments on commit 44c828e

Please sign in to comment.