Skip to content

Commit

Permalink
Enable extra scheduler options through API config
Browse files Browse the repository at this point in the history
Initial solution for #75.
  • Loading branch information
LourensVeen committed Nov 4, 2018
1 parent e6e3cff commit 304d887
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 3 deletions.
5 changes: 5 additions & 0 deletions cerise/back_end/job_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ def __init__(self, job_store, config, api_files_path, api_install_script_path):
"""The name of the remote queue to submit jobs to."""
self._mpi_slots_per_node = config.get_slots_per_node()
"""Number of MPI slots per node to request."""
self._scheduler_options = config.get_scheduler_options()
"""Additional scheduler options to add."""

self._logger.debug('Slots per node set to ' + str(self._mpi_slots_per_node))

Expand Down Expand Up @@ -107,6 +109,9 @@ def start_job(self, job_id):
if self._queue_name:
jobdesc.queue_name = self._queue_name

if self._scheduler_options:
jobdesc.extra_scheduler_options = self._scheduler_options

print("Starting job: " + str(jobdesc))
job.remote_job_id = self._sched.submit(jobdesc)
self._logger.debug('Job submitted')
Expand Down
3 changes: 3 additions & 0 deletions cerise/back_end/test/test_job_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ def get_queue_name(self):
def get_slots_per_node(self):
return 1

def get_scheduler_options(self):
return None

def get_remote_cwl_runner(self):
return '$CERISE_API_FILES/cerise/cwltiny.py'

Expand Down
10 changes: 10 additions & 0 deletions cerise/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,16 @@ def get_slots_per_node(self):
return default
return self._cr_config['jobs'].get('slots-per-node', default)

def get_scheduler_options(self):
"""Returns the additional scheduler options to use.
Returns:
(str): The options as a single string.
"""
if 'jobs' not in self._cr_config:
return None
return self._cr_config['jobs'].get('scheduler-options', None)

def get_remote_refresh(self):
"""
Returns the interval in between checks of the remote job \
Expand Down
10 changes: 7 additions & 3 deletions docs/source/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ format::

queue-name: None # cluster default
slots-per-node: None # cluster default
scheduler-options: None
cwl-runner: $CERISE_API_FILES/cerise/cwltiny.py

refresh: 10
Expand Down Expand Up @@ -172,9 +173,12 @@ Other valid values for ``scheduler`` are ``slurm``, ``torque`` and
If jobs need to be sent to a particular queue, then you can pass the queue name
using the corresponding option; if it is not specified, the default queue is
used. If one or more of your steps start MPI jobs, then you may want to set the
number of MPI slots per node via ``slots-per-node`` for better performance.
Ideally, it would be possible to specify this in the CWL file for the step, but
neither CWL nor Cerise currently support this.
number of MPI slots per node via ``slots-per-node`` for better performance. If
you need to specify additional scheduler options to e.g. select a GPU node, you
can do so using e.g. ``scheduler-options: "-C TitanX --gres=gpu:1"``. Ideally,
it would be possible to specify this in the CWL file for the step, but support
for this in CWL is partial and in-development, and Cerise does not currently
support this.

Finally, ``cwl-runner`` specifies the remote path to the CWL runner. It defaults
to ``$CERISE_API_FILES/cerise/cwltiny.py``, which is Cerise's included simple
Expand Down
1 change: 1 addition & 0 deletions integration_test/api/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ compute-resource:
username: xenon
password: javagat
scheduler: slurm
scheduler-options: --comment='testing'

0 comments on commit 304d887

Please sign in to comment.