Skip to content

Commit

Permalink
Merge pull request #2552 from jedwards4b/unknown_queues
Browse files Browse the repository at this point in the history
allow unknown queues only with --force and set with defaults

If a user attempts to set a JOB_QUEUE unknown in config_batch.xml

require the --force flag to xmlchange so that the user confirms intent.
Use the default queue to get settings from env_batch.xml
Test suite: scripts_regression_tests.py, hand testing in undefined queue on cheyenne
Test baseline:
Test namelist changes:
Test status: bit for bit
Fixes #2551

User interface changes?: require --force to set a queue unknown to the system.

Update gh-pages html (Y/N)?:

Code review:
  • Loading branch information
jgfouca authored May 7, 2018
2 parents dd4e568 + 66f27f0 commit 1626fe0
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions scripts/lib/CIME/XML/env_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ def set_value(self, item, value, subgroup=None, ignore_type=False):
expect(False, "could not interpret format for wallclock time {}".format(value))
value = format_time(walltime_format, t_spec, value)

if item == "JOB_QUEUE":
expect(value in self._get_all_queue_names() or ignore_type,
"Unknown Job Queue specified use --force to set")

# allow the user to set item for all jobs if subgroup is not provided
if subgroup is None:
gnodes = self.get_children("group")
Expand Down Expand Up @@ -278,7 +282,7 @@ def set_job_defaults(self, batch_jobs, case):

walltime = self._default_walltime if walltime is None else walltime # last-chance fallback

self.set_value("JOB_QUEUE", queue, subgroup=job)
self.set_value("JOB_QUEUE", queue, subgroup=job, ignore_type=specs is None)
self.set_value("JOB_WALLCLOCK_TIME", walltime, subgroup=job)
logger.debug("Job {} queue {} walltime {}".format(job, queue, walltime))

Expand Down Expand Up @@ -321,6 +325,9 @@ def get_batch_directives(self, case, job, overrides=None):

roots = self.get_children("batch_system")
queue = self.get_value("JOB_QUEUE", subgroup=job)
if not queue in self._get_all_queue_names():
qnode = self.get_default_queue()
queue = self.text(qnode)
for root in roots:
if root is not None:
if directive_prefix is None:
Expand Down Expand Up @@ -627,16 +634,21 @@ def queue_meets_spec(self, queue, num_nodes, num_tasks, walltime=None, job=None)

return True

def select_best_queue(self, num_nodes, num_tasks, walltime=None, job=None):
# Make sure to check default queue first.
def _get_all_queue_names(self):
all_queues = []
all_queues.append( self.get_default_queue())
all_queues = all_queues + self.get_all_queues()
all_queues = self.get_all_queues()
queue_names = []
for queue in all_queues:
if queue is not None:
qname = self.text(queue)
if self.queue_meets_spec(qname, num_nodes, num_tasks, walltime=walltime, job=job):
return qname
queue_names.append(self.text(queue))
return queue_names

def select_best_queue(self, num_nodes, num_tasks, walltime=None, job=None):
# Make sure to check default queue first.
qnames = self._get_all_queue_names()
for qname in qnames:
if self.queue_meets_spec(qname, num_nodes, num_tasks, walltime=walltime, job=job):
return qname

return None

Expand Down

0 comments on commit 1626fe0

Please sign in to comment.