From c28dde13f553b2f2bb5724d5a93e0204dfc498b7 Mon Sep 17 00:00:00 2001 From: Daniel Abdi Date: Mon, 14 Mar 2022 14:51:32 +0000 Subject: [PATCH] Simplify some func argument processing. --- ush/check_ruc_lsm.py | 14 ++++++-------- ush/create_diag_table_file.py | 7 ++----- ush/get_crontab_contents.py | 7 ++----- ush/set_ozone_param.py | 7 ++----- ush/set_thompson_mp_fix_files.py | 7 ++----- 5 files changed, 14 insertions(+), 28 deletions(-) diff --git a/ush/check_ruc_lsm.py b/ush/check_ruc_lsm.py index 9f34cdbe96..6af11c8830 100644 --- a/ush/check_ruc_lsm.py +++ b/ush/check_ruc_lsm.py @@ -3,10 +3,10 @@ import os import unittest -from python_utils import process_args, import_vars, print_input_args, \ +from python_utils import process_args, set_env_var, import_vars, print_input_args, \ load_xml_file, has_tag_with_value -def check_ruc_lsm(**kwargs): +def check_ruc_lsm(ccpp_phys_suite_fp): """ This file defines a function that checks whether the RUC land surface model (LSM) parameterization is being called by the selected physics suite. @@ -15,17 +15,15 @@ def check_ruc_lsm(**kwargs): Returns: Boolean """ - - valid_args = ['ccpp_phys_suite_fp'] - dictionary = process_args(valid_args, **kwargs) - print_input_args(dictionary) - import_vars(dictionary=dictionary) - + print_input_args(locals()) tree = load_xml_file(ccpp_phys_suite_fp) has_ruc = has_tag_with_value(tree, "scheme", "lsm_ruc") return has_ruc class Testing(unittest.TestCase): def test_check_ruc_lsm(self): + set_env_var('DEBUG',True) self.assertTrue( check_ruc_lsm(ccpp_phys_suite_fp="test_data/suite_FV3_GSD_SAR.xml") ) + def setUp(self): + set_env_var('DEBUG',True) diff --git a/ush/create_diag_table_file.py b/ush/create_diag_table_file.py index fdf31c5044..c994a89da0 100644 --- a/ush/create_diag_table_file.py +++ b/ush/create_diag_table_file.py @@ -9,7 +9,7 @@ from fill_jinja_template import fill_jinja_template -def create_diag_table_file(**kwargs): +def create_diag_table_file(run_dir): """ Creates a diagnostic table file for each cycle to be run Args: @@ -19,10 +19,7 @@ def create_diag_table_file(**kwargs): """ #process input arguments - valid_args = [ "run_dir" ] - dictionary = process_args(valid_args, **kwargs) - print_input_args(dictionary) - import_vars(dictionary=dictionary) + print_input_args(locals()) #import all environment variables import_vars() diff --git a/ush/get_crontab_contents.py b/ush/get_crontab_contents.py index f5457cd848..0f1d21be55 100644 --- a/ush/get_crontab_contents.py +++ b/ush/get_crontab_contents.py @@ -8,7 +8,7 @@ run_command, define_macos_utilities, check_var_valid_value from constants import valid_vals_BOOLEAN -def get_crontab_contents(**kwargs): +def get_crontab_contents(called_from_cron): """ #----------------------------------------------------------------------- # @@ -35,10 +35,7 @@ def get_crontab_contents(**kwargs): #----------------------------------------------------------------------- """ - valid_args=["called_from_cron"] - dictionary = process_args(valid_args, **kwargs) - print_input_args(dictionary) - import_vars(dictionary=dictionary) + print_input_args(locals()) #import all env vars IMPORTS = ["MACHINE"] diff --git a/ush/set_ozone_param.py b/ush/set_ozone_param.py index 5ff76bba0d..786f02f519 100644 --- a/ush/set_ozone_param.py +++ b/ush/set_ozone_param.py @@ -8,7 +8,7 @@ print_input_args, print_info_msg, print_err_msg_exit,\ define_macos_utilities,load_xml_file,has_tag_with_value,find_pattern_in_str -def set_ozone_param(**kwargs): +def set_ozone_param(ccpp_phys_suite_fp): """ Function that does the following: (1) Determines the ozone parameterization being used by checking in the CCPP physics suite XML. @@ -36,10 +36,7 @@ def set_ozone_param(**kwargs): ozone_param: a string """ - valid_args = ['ccpp_phys_suite_fp'] - dictionary = process_args(valid_args, **kwargs) - print_input_args(dictionary) - import_vars(dictionary=dictionary) + print_input_args(locals()) # import all environment variables import_vars() diff --git a/ush/set_thompson_mp_fix_files.py b/ush/set_thompson_mp_fix_files.py index dcd17ab738..1e7a80200f 100644 --- a/ush/set_thompson_mp_fix_files.py +++ b/ush/set_thompson_mp_fix_files.py @@ -8,7 +8,7 @@ print_input_args,print_info_msg, print_err_msg_exit,\ define_macos_utilities,load_xml_file,has_tag_with_value -def set_thompson_mp_fix_files(**kwargs): +def set_thompson_mp_fix_files(ccpp_phys_suite_fp, thompson_mp_climo_fn): """ Function that first checks whether the Thompson microphysics parameterization is being called by the selected physics suite. If not, it sets the output variable whose name is specified by @@ -26,10 +26,7 @@ def set_thompson_mp_fix_files(**kwargs): boolean: sdf_uses_thompson_mp """ - valid_args = ['ccpp_phys_suite_fp', 'thompson_mp_climo_fn'] - dictionary = process_args(valid_args, **kwargs) - print_input_args(dictionary) - import_vars(dictionary=dictionary) + print_input_args(locals()) # import all environment variables import_vars()