Skip to content

Commit

Permalink
Merge pull request #4463 from ESMCI/fix_query_config
Browse files Browse the repository at this point in the history
- Adds --driver to query_config
- Deprecates --comp_interface for query_config
- Fixes driver_choices in create_test

Test suite: pytest CIME/tests/test_unit*
Test baseline: n/a
Test namelist changes: n/a
Test status: n/a

Fixes #4456
User interface changes?: N
Update gh-pages html (Y/N)?: N
  • Loading branch information
jasonb5 committed Jul 20, 2023
2 parents 79f555a + 76add4d commit 95c1430
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CIME/scripts/create_newcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion CIME/scripts/create_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
)

Expand Down
14 changes: 11 additions & 3 deletions CIME/scripts/query_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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",
)

Expand All @@ -332,7 +340,7 @@ def parse_command_line(args, description):
args.machines,
args.long,
args.xml,
files[args.comp_interface],
files[args.driver],
)


Expand Down
9 changes: 9 additions & 0 deletions CIME/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -21,6 +22,14 @@
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)

Expand Down

0 comments on commit 95c1430

Please sign in to comment.