Skip to content

Commit

Permalink
Merge pull request #1496 from ESMCI/jgfouca/fix_force_queue
Browse files Browse the repository at this point in the history
Fix force queue
User can select unknown queue.

Add test.

Test suite: scripts_regression_tests.py K_TestCimeCase
Test baseline:
Test namelist changes:
Test status: bit for bit

Fixes #1493

User interface changes?: None

Code review: @jedwards4b
  • Loading branch information
jedwards4b authored May 8, 2017
2 parents 93a452a + 7a67bae commit 99f1f5b
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 4 deletions.
22 changes: 18 additions & 4 deletions scripts/lib/CIME/XML/env_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ def set_job_defaults(self, batch_jobs, pesize=None, walltime=None, force_queue=N
if force_queue:
if not self.queue_meets_spec(force_queue, task_count, walltime=walltime, job=job):
logger.warning("WARNING: User-requested queue '%s' does not meet requirements for job '%s'" % (force_queue, job))
queue = force_queue
else:
queue = self.select_best_queue(task_count, walltime=walltime, job=job)
if queue is None and walltime is not None:
Expand All @@ -221,8 +222,16 @@ def set_job_defaults(self, batch_jobs, pesize=None, walltime=None, force_queue=N
queue = default_queue_node.text
walltime = self.get_queue_specs(queue)[3]

walltime = self.get_queue_specs(queue)[3] if walltime is None else walltime
walltime = self._default_walltime if walltime is None else walltime # last-chance fallback
if walltime is None:
# Figure out walltime
specs = self.get_queue_specs(queue)
if specs is None:
# Queue is unknown, use specs from default queue
walltime = self.get_default_queue().get("walltimemax")
else:
walltime = specs[3]

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_WALLCLOCK_TIME", walltime, subgroup=job)
Expand Down Expand Up @@ -435,7 +444,12 @@ def get_job_id(self, output):
return jobid

def queue_meets_spec(self, queue, num_pes, walltime=None, job=None):
jobmin, jobmax, jobname, walltimemax, strict = self.get_queue_specs(queue)
specs = self.get_queue_specs(queue)
if specs is None:
logger.warning("WARNING: queue '%s' is unknown to this system" % queue)
return True

jobmin, jobmax, jobname, walltimemax, strict = specs

# A job name match automatically meets spec
if job is not None and jobname is not None:
Expand Down Expand Up @@ -484,7 +498,7 @@ def get_queue_specs(self, queue):

return jobmin, jobmax, jobname, walltimemax, strict

expect(False, "Queue '%s' is unknown to this system" % queue)
return None

def get_default_queue(self):
node = self.get_optional_node("queue", attributes={"default" : "true"})
Expand Down
21 changes: 21 additions & 0 deletions scripts/tests/scripts_regression_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1486,6 +1486,27 @@ def test_cime_case_test_walltime_mgmt_4(self):
result = run_cmd_assert_result(self, "./xmlquery JOB_QUEUE --subgroup=case.test --value", from_dir=casedir)
self.assertEqual(result, "shared")

###########################################################################
def test_cime_case_test_walltime_mgmt_5(self):
###########################################################################
if CIME.utils.get_model() != "acme":
self.skipTest("Skipping walltime test. Depends on ACME batch settings")

test_name = "ERS_P1.f19_g16_rx1.A"
machine, compiler = "blues", "gnu"
run_cmd_assert_result(self, "unset CIME_GLOBAL_WALLTIME && %s/create_test --no-setup --machine %s %s -t %s --test-root %s --output-root %s --queue slartibartfast" %
(SCRIPT_DIR, machine, test_name, self._baseline_name, self._testroot, self._testroot))

casedir = os.path.join(self._testroot,
"%s.%s" % (CIME.utils.get_full_test_name(test_name, machine=machine, compiler=compiler), self._baseline_name))
self.assertTrue(os.path.isdir(casedir), msg="Missing casedir '%s'" % casedir)

result = run_cmd_assert_result(self, "./xmlquery JOB_WALLCLOCK_TIME --subgroup=case.test --value", from_dir=casedir)
self.assertEqual(result, "03:00:00")

result = run_cmd_assert_result(self, "./xmlquery JOB_QUEUE --subgroup=case.test --value", from_dir=casedir)
self.assertEqual(result, "slartibartfast")

###############################################################################
class X_TestSingleSubmit(TestCreateTestCommon):
###############################################################################
Expand Down

0 comments on commit 99f1f5b

Please sign in to comment.