From f2cd932ca4bea8c01abde1ca2005fd31da824974 Mon Sep 17 00:00:00 2001 From: Jason Boutte Date: Wed, 19 Jul 2023 10:02:43 -0700 Subject: [PATCH 1/4] Adds comment --- CIME/scripts/create_newcase.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CIME/scripts/create_newcase.py b/CIME/scripts/create_newcase.py index 3faea5d6553..eb82d392994 100755 --- a/CIME/scripts/create_newcase.py +++ b/CIME/scripts/create_newcase.py @@ -239,6 +239,8 @@ def parse_command_line(args, cimeroot, description): parser.add_argument( "--driver", + # use get_cime_default_driver rather than config.driver_default as it considers + # environment, user config then config.driver_default default=get_cime_default_driver(), choices=drv_choices, help=drv_help, From 9708936ef211a8fb553dd7a367cf58e489645db5 Mon Sep 17 00:00:00 2001 From: Jason Boutte Date: Wed, 19 Jul 2023 10:08:38 -0700 Subject: [PATCH 2/4] Fixes using driver_choices from model customize config --- CIME/scripts/create_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CIME/scripts/create_test.py b/CIME/scripts/create_test.py index 44ccb1687be..65fcc03b359 100755 --- a/CIME/scripts/create_test.py +++ b/CIME/scripts/create_test.py @@ -219,7 +219,7 @@ def parse_command_line(args, description): parser.add_argument( "--driver", - choices=("mct", "nuopc", "moab"), + choices=model_config.driver_choices, help="Override driver specified in tests and use this one.", ) From c71f9eaf54805e2dc983108ac53a071492f746e8 Mon Sep 17 00:00:00 2001 From: Jason Boutte Date: Wed, 19 Jul 2023 10:14:44 -0700 Subject: [PATCH 3/4] Adds --driver and deprecates --comp_interface --- CIME/scripts/query_config.py | 14 +++++++++++--- CIME/utils.py | 7 +++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/CIME/scripts/query_config.py b/CIME/scripts/query_config.py index 674713e0485..b746087911f 100755 --- a/CIME/scripts/query_config.py +++ b/CIME/scripts/query_config.py @@ -8,7 +8,7 @@ from CIME.Tools.standard_script_setup import * import re -from CIME.utils import expect +from CIME.utils import expect, get_cime_default_driver, deprecate_action from CIME.XML.files import Files from CIME.XML.component import Component from CIME.XML.compsets import Compsets @@ -314,8 +314,16 @@ def parse_command_line(args, description): parser.add_argument( "--comp_interface", - choices=supported_comp_interfaces, + choices=supported_comp_interfaces, # same as config.driver_choices default="mct", + action=deprecate_action(", use --driver argument"), + help="DEPRECATED: Use --driver argument", + ) + + parser.add_argument( + "--driver", + choices=config.driver_choices, + default=get_cime_default_driver(), help="Coupler/Driver interface", ) @@ -332,7 +340,7 @@ def parse_command_line(args, description): args.machines, args.long, args.xml, - files[args.comp_interface], + files[args.driver], ) diff --git a/CIME/utils.py b/CIME/utils.py index b79fcd5116e..78bbf324045 100644 --- a/CIME/utils.py +++ b/CIME/utils.py @@ -8,6 +8,7 @@ import importlib.util import errno, signal, warnings, filecmp import stat as statlib +from argparse import Action from contextlib import contextmanager from distutils import file_util @@ -21,6 +22,12 @@ GLOBAL = {} +def deprecate_action(message): + class ActionStoreDeprecated(Action): + def __call__(self, parser, namespace, values, option_string=None): + raise DeprecationWarning(f"{option_string} is deprecated{message}") + return ActionStoreDeprecated + def import_from_file(name, file_path): loader = importlib.machinery.SourceFileLoader(name, file_path) From 76add4d90b71877b42b9c34c69bc5bb5126cb939 Mon Sep 17 00:00:00 2001 From: Jason Boutte Date: Wed, 19 Jul 2023 11:58:06 -0700 Subject: [PATCH 4/4] Fixes black formatting --- CIME/scripts/query_config.py | 2 +- CIME/utils.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CIME/scripts/query_config.py b/CIME/scripts/query_config.py index b746087911f..88d2151d1c1 100755 --- a/CIME/scripts/query_config.py +++ b/CIME/scripts/query_config.py @@ -314,7 +314,7 @@ def parse_command_line(args, description): parser.add_argument( "--comp_interface", - choices=supported_comp_interfaces, # same as config.driver_choices + choices=supported_comp_interfaces, # same as config.driver_choices default="mct", action=deprecate_action(", use --driver argument"), help="DEPRECATED: Use --driver argument", diff --git a/CIME/utils.py b/CIME/utils.py index 78bbf324045..4f0e133ae73 100644 --- a/CIME/utils.py +++ b/CIME/utils.py @@ -26,8 +26,10 @@ def deprecate_action(message): class ActionStoreDeprecated(Action): def __call__(self, parser, namespace, values, option_string=None): raise DeprecationWarning(f"{option_string} is deprecated{message}") + return ActionStoreDeprecated + def import_from_file(name, file_path): loader = importlib.machinery.SourceFileLoader(name, file_path)