Skip to content

Commit

Permalink
Merge pull request #1388 from ESMCI/erichlf/manage_case
Browse files Browse the repository at this point in the history
Renamed manage_case to query_config. Additionally, changed all
references to manage_case to query_config. Added ability to query current machine and a single machine. Added 'all' option to --compsets. Made the help message much more useful.

Test suite: scripts_regression_tests.py
and

./query_config
./query_config --grids
./query_config --machines
./query_config --machines current
./query_config --machines redsky
./query_config --machines edison
./query_config --machines skybridge
./query_config --compsets
./query_config --compsets all
./query_config --compsets drv
./query_config --component
Test baseline:
Test namelist changes:
Test status: bit for bit

Fixes #1155
Fixes #1190

User interface changes?:
manage_case -> query_config
--compset -> --compsets
--machine -> --machines
added 'all' option for --compsets
added 'current' and to --machines

Code review: @billsacks, @jgfouca
  • Loading branch information
rljacob authored May 5, 2017
2 parents b661f5b + 1bd5f7b commit 68f4b5d
Show file tree
Hide file tree
Showing 25 changed files with 461 additions and 197 deletions.
10 changes: 5 additions & 5 deletions scripts/create_newcase
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,28 @@ OR

parser.add_argument("--compset", "-compset", required=True,
help="(required) Specify a compset. "
"To see list of current compsets, use the utility manage_case in this directory")
"To see list of current compsets, use the utility query_config in this directory")

parser.add_argument("--res", "-res", required=True,
help="(required) Specify a model grid resolution. "
"To see list of current compsets, use the utility manage_case in this directory")
"To see list of current compsets, use the utility query_config in this directory")

parser.add_argument("--machine", "-mach",
help="Specify a machine. default: match NODENAME_REGEX in config_machines.xml "
"To see list of current machines, use the utility manage_case in this directory"
"To see list of current machines, use the utility query_config in this directory"
)

parser.add_argument("--compiler", "-compiler",
help="Specify a compiler. "
"To see list of supported compilers for each machine, use the utility manage_case in this directory")
"To see list of supported compilers for each machine, use the utility query_config in this directory")

parser.add_argument("--ninst",default=1,
help="Specify number of component instances"
"Set the number of component instances in the case.")

parser.add_argument("--mpilib", "-mpilib",
help="Specify the mpilib. "
"To see list of supported mpilibs for each machine, use the utility manage_case in this directory. "
"To see list of supported mpilibs for each machine, use the utility query_config in this directory. "
"The default is the first listing in MPILIBS in config_machines.xml")

parser.add_argument("--project", "-project",
Expand Down
2 changes: 1 addition & 1 deletion scripts/create_test
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ OR

parser.add_argument("--mpilib",
help="Specify the mpilib. "
"To see list of supported mpilibs for each machine, use the utility manage_case in this directory. "
"To see list of supported mpilibs for each machine, use the utility query_config in this directory. "
"The default is the first listing in MPILIBS in config_machines.xml")

if model == "cesm":
Expand Down
2 changes: 1 addition & 1 deletion scripts/lib/CIME/XML/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,6 @@ def print_values(self):
compsets[attrib] = text

logger.info(" %s" %helptext)
for v in compsets.iteritems():
for v in sorted(compsets.iteritems()):
label, definition = v
logger.info(" %20s : %s" %(label, definition))
13 changes: 7 additions & 6 deletions scripts/lib/CIME/XML/compsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def get_compset_match(self, name):
user_mods = user_mods_node.text
else:
user_mods = None
logger.debug("Found node match with alias: %s and lname: %s" % (alias, lname))
logger.debug("Found node match with alias: {} and lname: {}".format(alias, lname))
return (lname, alias, science_support, user_mods)
return (None, None, [False], None)

Expand Down Expand Up @@ -72,22 +72,23 @@ def get_value(self, name, attribute=None, resolved=False, subgroup=None):
nodes = self.get_nodes(nodename="compset")
for node in nodes:
for child in node:
logger.debug ("Here child is %s with value %s"%(child.tag,child.text))
logger.debug ("Here child is {} with value {}".format(child.tag,child.text))
if child.tag == "alias":
alias = child.text
if child.tag == "lname":
lname = child.text
compsets[alias] = lname
return compsets

def print_values(self):
def print_values(self, help=True):
help_text = self.get_value(name="help")
compsets_text = self.get_value("names")
logger.info(" %s " %help_text)
if help:
logger.info(" {} ".format(help_text))

logger.info(" --------------------------------------")
logger.info(" Compset Short Name: Compset Long Name ")
logger.info(" Compset Alias: Compset Long Name ")
logger.info(" --------------------------------------")
for v in compsets_text.iteritems():
label, definition = v
logger.info(" %20s : %s" %(label, definition))
logger.info(" {:20} : {}".format(label, definition))
2 changes: 1 addition & 1 deletion scripts/lib/CIME/XML/grids.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def _read_config_grids_v1(self, name, compset):
component_grids = self._get_component_grids(lname)
return lname, component_grids
expect (False,
"grid '%s' is not supported, use manage_case to determine supported grids " %name)
"grid '%s' is not supported, use query_config to determine supported grids " %name)

def _read_config_grids_v2(self, name, compset):
"""
Expand Down
19 changes: 10 additions & 9 deletions scripts/lib/CIME/XML/machines.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def __init__(self, infile=None, files=None, machine=None):
if infile is None:
infile = files.get_value("MACHINES_SPEC_FILE")
schema = files.get_schema("MACHINES_SPEC_FILE")
logger.debug("Verifying using schema %s"%schema)
logger.debug("Verifying using schema {}".format(schema))

self.machines_dir = os.path.dirname(infile)

Expand All @@ -38,7 +38,7 @@ def __init__(self, infile=None, files=None, machine=None):
# Append the contents of $HOME/.cime/config_machines.xml if it exists
# This could cause problems if node matchs are repeated when only one is expected
local_infile = os.path.join(os.environ.get("HOME"),".cime","config_machines.xml")
logger.debug("Infile: %s" , local_infile)
logger.debug("Infile: {}" , local_infile)
if os.path.exists(local_infile):
GenericXML.read(self, local_infile, schema)

Expand All @@ -48,7 +48,7 @@ def __init__(self, infile=None, files=None, machine=None):
else:
machine = self.probe_machine_name()

expect(machine is not None, "Could not initialize machine object from %s or %s" % (infile, local_infile))
expect(machine is not None, "Could not initialize machine object from {} or {}".format(infile, local_infile))
self.set_machine(machine)

def get_machines_dir(self):
Expand Down Expand Up @@ -91,7 +91,7 @@ def list_available_machines(self):
machines.append(mach)
return machines

def probe_machine_name(self):
def probe_machine_name(self, warn=True):
"""
Find a matching regular expression for hostname
in the NODENAME_REGEX field in the file. First match wins.
Expand All @@ -113,7 +113,8 @@ def probe_machine_name(self):

names_not_found_quoted = ["'" + name + "'" for name in names_not_found]
names_not_found_str = ' or '.join(names_not_found_quoted)
logger.warning("Could not find machine match for %s" % names_not_found_str)
if warn:
logger.warning("Could not find machine match for {}".format(names_not_found_str))

return machine

Expand All @@ -136,7 +137,7 @@ def _probe_machine_name_one_guess(self, nametomatch):
logger.debug("machine regex string is " + regex_str)
regex = re.compile(regex_str)
if regex.match(nametomatch):
logger.debug("Found machine: %s matches %s" % (machtocheck, nametomatch))
logger.debug("Found machine: {} matches {}".format(machtocheck, nametomatch))
machine = machtocheck
break

Expand All @@ -158,7 +159,7 @@ def set_machine(self, machine):
self.machine = machine
elif self.machine != machine or self.machine_node is None:
self.machine_node = self.get_optional_node("machine", {"MACH" : machine})
expect(self.machine_node is not None, "No machine %s found" % machine)
expect(self.machine_node is not None, "No machine {} found".format(machine))
self.machine = machine

return machine
Expand Down Expand Up @@ -275,7 +276,7 @@ def has_batch_system(self):
batch_system = self.get_optional_node("BATCH_SYSTEM", root=self.machine_node)
if batch_system is not None:
result = (batch_system.text is not None and batch_system.text != "none")
logger.debug("Machine %s has batch: %s" % (self.machine, result))
logger.debug("Machine {} has batch: {}".format(self.machine, result))
return result

def get_suffix(self, suffix_type):
Expand All @@ -299,7 +300,7 @@ def print_values(self):
max_tasks_per_node = machine.find("MAX_TASKS_PER_NODE")
pes_per_node = machine.find("PES_PER_NODE")

print " %s : %s "% (name , desc.text)
print " {} : {} ".format(name , desc.text)
print " os ", os_.text
print " compilers ",compilers.text
if pes_per_node is not None:
Expand Down
168 changes: 0 additions & 168 deletions scripts/manage_case

This file was deleted.

Loading

0 comments on commit 68f4b5d

Please sign in to comment.