Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds query_config driver argument #4463

Merged
merged 4 commits into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
7 changes: 7 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,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)

Expand Down
Loading