From e49cd48d195b09c7ea3cebfeba956162ee721404 Mon Sep 17 00:00:00 2001 From: George McCabe <23407799+georgemccabe@users.noreply.github.com> Date: Fri, 21 Oct 2022 16:48:11 -0600 Subject: [PATCH 1/2] per #1884, fix bug that prevents the {custom} filename template tag from being used in 2nd file for PCPCombine subtract method --- metplus/wrappers/pcp_combine_wrapper.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/metplus/wrappers/pcp_combine_wrapper.py b/metplus/wrappers/pcp_combine_wrapper.py index 8afbc171a6..8f476647b0 100755 --- a/metplus/wrappers/pcp_combine_wrapper.py +++ b/metplus/wrappers/pcp_combine_wrapper.py @@ -391,8 +391,7 @@ def setup_subtract_method(self, time_info, accum, data_src): 'lead': lead2} time_info2 = ti_calculate(input_dict2) time_info2['level'] = accum - if hasattr(time_info, 'custom'): - time_info2['custom'] = time_info['custom'] + time_info2['custom'] = time_info.get('custom', '') filepath2 = do_string_sub(full_template, **time_info2) file2 = util.preprocess_file(filepath2, From 3dd0ca710a3d8b869eba3ee5c70260a81aa2e5aa Mon Sep 17 00:00:00 2001 From: George McCabe <23407799+georgemccabe@users.noreply.github.com> Date: Fri, 21 Oct 2022 16:57:07 -0600 Subject: [PATCH 2/2] added test to ensure custom tag can be used in PCPCombine subtract method --- .../wrappers/pcp_combine/test_pcp_combine_wrapper.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/internal/tests/pytests/wrappers/pcp_combine/test_pcp_combine_wrapper.py b/internal/tests/pytests/wrappers/pcp_combine/test_pcp_combine_wrapper.py index 725278c393..19be7d9b24 100644 --- a/internal/tests/pytests/wrappers/pcp_combine/test_pcp_combine_wrapper.py +++ b/internal/tests/pytests/wrappers/pcp_combine/test_pcp_combine_wrapper.py @@ -189,13 +189,23 @@ def test_setup_sum_method(metplus_config): assert pcw.setup_sum_method(time_info, lookback, data_src) +@pytest.mark.parametrize( + 'custom', [ + False, True, + ] +) @pytest.mark.wrapper -def test_setup_subtract_method(metplus_config): +def test_setup_subtract_method(metplus_config, custom): data_src = "FCST" pcw = pcp_combine_wrapper(metplus_config, data_src) task_info = {} task_info['valid'] = datetime.strptime("201609050000", '%Y%m%d%H%M') task_info['lead_hours'] = 9 + if custom: + task_info['custom'] = 'file' + temp = pcw.config.getraw('config', 'FCST_PCP_COMBINE_INPUT_TEMPLATE') + temp = temp.replace('file.', '{custom}.') + pcw.config.set('config', 'FCST_PCP_COMBINE_INPUT_TEMPLATE', temp) time_info = ti_calculate(task_info) lookback = 6 * 3600 files_found = pcw.setup_subtract_method(time_info, lookback, data_src)