Skip to content

Commit

Permalink
per #2096, add check of forecast lead when looking for existing outpu…
Browse files Browse the repository at this point in the history
…t files for apps that create multiple output files
  • Loading branch information
georgemccabe committed Mar 22, 2023
1 parent 3a55b82 commit feab072
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions metplus/wrappers/command_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from ..util.constants import PYTHON_EMBEDDING_TYPES, COMPRESSION_EXTENSIONS
from ..util import getlist, preprocess_file, loop_over_times_and_call
from ..util import do_string_sub, ti_calculate, get_seconds_from_string
from ..util import get_time_from_file, shift_time_seconds
from ..util import get_time_from_file, shift_time_seconds, seconds_to_met_time
from ..util import replace_config_from_section
from ..util import METConfig
from ..util import MISSING_DATA_VALUE
Expand Down Expand Up @@ -924,7 +924,7 @@ def find_and_check_output_file(self, time_info=None,
template
@param is_directory If True, check in output directory for
any files that match the pattern
{app_name}_{output_prefix}*YYYYMMDD_HHMMSSV*
{app_name}_{output_prefix}_HHMMSSL_YYYYMMDD_HHMMSSV*
@param output_path_template optional filename template to use
If None, build output path template from c_dict's OUTPUT_DIR
and OUTPUT_TEMPLATE. Default is None
Expand Down Expand Up @@ -962,13 +962,18 @@ def find_and_check_output_file(self, time_info=None,
# get directory that the output file will exist
if is_directory:
parent_dir = output_path
if time_info and time_info['valid'] != '*':
valid_format = time_info['valid'].strftime('%Y%m%d_%H%M%S')
else:
valid_format = ''
valid = '*'
lead = '*'
if time_info:
if time_info['valid'] != '*':
valid = time_info['valid'].strftime('%Y%m%d_%H%M%S')
if time_info['lead'] != '*':
lead = seconds_to_met_time(time_info['lead_seconds'],
force_hms=True)

prefix = self.get_output_prefix(time_info, set_env_vars=False)
search_string = f"{self.app_name}_{prefix}*{valid_format}V*"
prefix = f'{self.app_name}_{prefix}' if prefix else self.app_name
search_string = f'{prefix}_{lead}L_{valid}V*'
search_path = os.path.join(output_path,
search_string)
if skip_if_output_exists:
Expand Down

0 comments on commit feab072

Please sign in to comment.