Skip to content

Commit

Permalink
per #2241, create directory containing -out_stat file to prevent MET …
Browse files Browse the repository at this point in the history
…error
  • Loading branch information
georgemccabe committed Jul 10, 2023
1 parent 2c977a3 commit 0ad64d7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
config_init_beg = '20170705'
config_init_end = '20170901'


def get_config(metplus_config):
# extra_configs = []
# extra_configs.append(os.path.join(os.path.dirname(__file__),
Expand Down
24 changes: 15 additions & 9 deletions metplus/wrappers/tc_stat_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,15 +365,9 @@ def handle_jobs(self, time_info):
subbed_job = do_string_sub(job, **time_info) if time_info else job
formatted_jobs.append(subbed_job.strip())

# check if -dump_row is used
# if it is, create parent directory of output file
split_job = subbed_job.split(' ')
if '-dump_row' in split_job:
index = split_job.index('-dump_row') + 1
filepath = split_job[index]
self.c_dict['OUTPUT_TEMPLATE'] = filepath

if not self.find_and_check_output_file(time_info):
# create parent directory of output file
for out in ('-dump_row', '-out_stat'):
if not self._create_job_out_dirs(out, subbed_job, time_info):
return None

job_list_string = '","'.join(formatted_jobs)
Expand All @@ -384,6 +378,18 @@ def handle_jobs(self, time_info):

return job_list_string

def _create_job_out_dirs(self, out_type, job_args, time_info):
split_job = job_args.split(' ')
# return True if job arg that writes a file is not found in job args
if out_type not in split_job:
return True

# if job arg is found, create parent directory of output file
index = split_job.index(out_type) + 1
filepath = split_job[index]
self.c_dict['OUTPUT_TEMPLATE'] = filepath
return self.find_and_check_output_file(time_info)

def handle_out_file(self, time_info):
"""! If output template is set,
"""
Expand Down

0 comments on commit 0ad64d7

Please sign in to comment.