Skip to content

Commit

Permalink
Merge pull request #335 from ESMCI/jgfouca/add_queue_option_to_create…
Browse files Browse the repository at this point in the history
…_test

Add ability to select queue to create_test and create_newcase
  • Loading branch information
jgfouca authored Aug 3, 2016
2 parents 6f9613f + 731f8a0 commit fef81df
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 13 deletions.
9 changes: 6 additions & 3 deletions scripts/create_newcase
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ def parse_command_line(args, cimeroot):
help="Set the wallclock limit for this case. "
"Can use env var CIME_GLOBAL_WALLTIME to set this.")

parser.add_argument("-q", "--queue", default=None,
help="Force batch system to use a certain queue")

args = parser.parse_args()

CIME.utils.handle_standard_logging_options(args)
Expand Down Expand Up @@ -129,7 +132,7 @@ def parse_command_line(args, cimeroot):
args.mpilib, args.project, args.pecount, \
args.mach_dir, args.user_mods_dir, args.user_compset, args.pesfile, \
args.user_grid, args.gridfile, args.srcroot, args.test, args.ninst, \
args.walltime
args.walltime, args.queue

###############################################################################
def _main_func():
Expand All @@ -139,7 +142,7 @@ def _main_func():
caseroot, compset, grid, machine, compiler, \
mpilib, project, pecount, \
machine_dir, user_mods_dir, user_compset, pesfile, \
user_grid, gridfile, srcroot, test, ninst, walltime \
user_grid, gridfile, srcroot, test, ninst, walltime, queue \
= parse_command_line(sys.argv, cimeroot)

caseroot = os.path.abspath(caseroot)
Expand All @@ -160,7 +163,7 @@ def _main_func():
pecount=pecount, compiler=compiler, mpilib=mpilib,
user_compset=user_compset, pesfile=pesfile,
user_grid=user_grid, gridfile=gridfile, ninst=ninst, test=test,
walltime=walltime)
walltime=walltime, queue=queue)

case.create_caseroot()

Expand Down
14 changes: 9 additions & 5 deletions scripts/create_test
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ OR
help="Set the wallclock limit for all tests in the suite. "
"Can use env var CIME_GLOBAL_WALLTIME to set this for all test.")

parser.add_argument("-q", "--queue", default=None,
help="Force batch system to use a certain queue")

parser.add_argument("--xml-machine",
help="Use this machine key in the lookup in testlist.xml")
parser.add_argument("--xml-compiler",
Expand Down Expand Up @@ -225,7 +228,7 @@ OR
args.test_root, args.baseline_root, args.clean, args.compare, args.generate, \
args.baseline_name, args.namelists_only, args.project, args.test_id, args.parallel_jobs, \
args.xml_machine, args.xml_compiler, args.xml_category, args.xml_testlist, args.walltime, \
args.single_submit, args.proc_pool, args.use_existing, args.save_timing
args.single_submit, args.proc_pool, args.use_existing, args.save_timing, args.queue

###############################################################################
def single_submit_impl(machine_name, test_id, proc_pool, project, args, job_cost_map, wall_time, test_root):
Expand Down Expand Up @@ -331,7 +334,7 @@ def create_test(testargs, compiler, machine_name, no_run, no_build, no_setup, no
baseline_root, clean, compare, generate,
baseline_name, namelists_only, project, test_id, parallel_jobs,
xml_machine, xml_compiler, xml_category, xml_testlist, walltime,
single_submit, proc_pool, use_existing, save_timing):
single_submit, proc_pool, use_existing, save_timing, queue):
###############################################################################
if testargs and machine_name is None and compiler is None:
for test in testargs:
Expand All @@ -352,7 +355,8 @@ def create_test(testargs, compiler, machine_name, no_run, no_build, no_setup, no
project=project, parallel_jobs=parallel_jobs,
xml_machine=xml_machine, xml_compiler=xml_compiler,
xml_category=xml_category, xml_testlist=xml_testlist, walltime=walltime,
proc_pool=proc_pool, use_existing=use_existing, save_timing=save_timing)
proc_pool=proc_pool, use_existing=use_existing, save_timing=save_timing,
queue=queue)

success = impl.run_tests()

Expand Down Expand Up @@ -391,13 +395,13 @@ def _main_func(description):
testargs, compiler, machine_name, no_run, no_build, no_setup, no_batch, test_root, baseline_root, clean, \
compare, generate, baseline_name, namelists_only, project, test_id, parallel_jobs, \
xml_machine, xml_compiler, xml_category, xml_testlist, walltime, single_submit, proc_pool, \
use_existing, save_timing \
use_existing, save_timing, queue \
= parse_command_line(sys.argv, description)

sys.exit(create_test(testargs, compiler, machine_name, no_run, no_build, no_setup, no_batch, test_root,
baseline_root, clean, compare, generate, baseline_name, namelists_only,
project, test_id, parallel_jobs, xml_machine, xml_compiler, xml_category,
xml_testlist, walltime, single_submit, proc_pool, use_existing, save_timing))
xml_testlist, walltime, single_submit, proc_pool, use_existing, save_timing, queue))

###############################################################################

Expand Down
9 changes: 7 additions & 2 deletions utils/python/CIME/XML/env_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,23 +262,28 @@ def make_batch_script(self, input_template, job, case):
fd.write(output_text)
os.chmod(job, os.stat(job).st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)

def set_job_defaults(self, bjobs, pesize=None, walltime=None):
def set_job_defaults(self, bjobs, pesize=None, walltime=None, force_queue=None):
if self.batchtype is None:
self.batchtype = self.get_batch_system_type()

if self.batchtype == 'none':
return

for job, jsect in bjobs:
task_count = jsect["task_count"]
if task_count is None or task_count == "default":
task_count = pesize
else:
task_count = int(task_count)
queue = self.select_best_queue(task_count)

queue = force_queue if force_queue is not None else self.select_best_queue(task_count)
self.set_value("JOB_QUEUE", queue, subgroup=job)

walltime = self.get_max_walltime(queue) if walltime is None else walltime
if walltime is None:
logger.warn("Could not find a queue matching task count %d, falling back to depreciated default walltime parameter"%task_count)
walltime = self.get_default_walltime()

self.set_value( "JOB_WALLCLOCK_TIME", walltime , subgroup=job)
logger.info("Job %s queue %s walltime %s"%(job, queue, walltime))

Expand Down
4 changes: 2 additions & 2 deletions utils/python/CIME/case.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ def configure(self, compset_name, grid_name, machine_name=None,
project=None, pecount=None, compiler=None, mpilib=None,
user_compset=False, pesfile=None,
user_grid=False, gridfile=None, ninst=1, test=False,
walltime=None):
walltime=None, queue=None):

#--------------------------------------------
# compset, pesfile, and compset components
Expand Down Expand Up @@ -614,7 +614,7 @@ def configure(self, compset_name, grid_name, machine_name=None,
env_batch = self.get_env("batch")
env_batch.set_batch_system(batch, batch_system_type=batch_system_type)
env_batch.create_job_groups(bjobs)
env_batch.set_job_defaults(bjobs, pesize=maxval, walltime=walltime)
env_batch.set_job_defaults(bjobs, pesize=maxval, walltime=walltime, force_queue=queue)
self.schedule_rewrite(env_batch)

self.set_value("COMPSET",self._compsetname)
Expand Down
8 changes: 7 additions & 1 deletion utils/python/CIME/test_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,13 @@ def __init__(self, test_names,
project=None, parallel_jobs=None,
xml_machine=None, xml_compiler=None, xml_category=None,
xml_testlist=None, walltime=None, proc_pool=None,
use_existing=False, save_timing=False):
use_existing=False, save_timing=False, queue=None):
###########################################################################
self._cime_root = CIME.utils.get_cime_root()
self._cime_model = CIME.utils.get_model()

self._save_timing = save_timing
self._queue = queue

# needed for perl interface
os.environ["CIMEROOT"] = self._cime_root
Expand Down Expand Up @@ -79,6 +80,8 @@ def __init__(self, test_names,
# We will not use batch system if user asked for no_batch or if current
# machine is not a batch machine
self._no_batch = no_batch or not self._machobj.has_batch_system()
expect(not (self._no_batch and self._queue is not None),
"Does not make sense to request a queue without batch system")

self._test_root = test_root if test_root is not None \
else self._machobj.get_value("CESMSCRATCHROOT")
Expand Down Expand Up @@ -394,6 +397,9 @@ def _create_newcase_phase(self, test):
pesize = case_opt[1:]
create_newcase_cmd += " --pecount %s"%pesize

if self._queue is not None:
create_newcase_cmd += " --queue=%s" % self._queue

if self._walltime is not None:
create_newcase_cmd += " --walltime %s" % self._walltime
elif test in self._test_xml and "wallclock" in self._test_xml[test]:
Expand Down

0 comments on commit fef81df

Please sign in to comment.