Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance shell batch setting to apply to scheduler scripts. #183

Merged
merged 8 commits into from
Apr 25, 2019
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions maestrowf/abstracts/interfaces/schedulerscriptadapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,21 @@ class SchedulerScriptAdapter(ScriptAdapter):
# Just allocate based on nodes.
node_alloc = r"(?P<nodes>[0-9]+)n"

def __init__(self):
"""Initialize an empty ScriptAdapter object."""
def __init__(self, **kwargs):
"""
Initialize an empty ScriptAdapter object.

:param kwargs: Key-value dictionary of arguments.

Currently we only support the "shell" keyword.
"""
# NOTE: The _batch member should be used to store persistent batching
# parameters. The entries in this dictionary are meant to capture the
# the base settings for submission to a batch. This member variables
# should never be used publicallly outside of an instance.

# Call super to set self._exec
super(SchedulerScriptAdapter, self).__init__(**kwargs)
self._batch = {}

def add_batch_parameter(self, name, value):
Expand Down
11 changes: 10 additions & 1 deletion maestrowf/abstracts/interfaces/scriptadapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ class ScriptAdapter(object):
- Checking job status.
"""

def __init__(self, **kwargs):
"""
Initialize a new instance of a ScriptAdapter.

:param kwargs: The key value arguments for the ScriptAdapter instance.
"""
self._exec = kwargs.pop("shell", "/bin/bash")
LOGGER.debug("Shell set to '%s'.", self._exec)

@abstractmethod
def check_jobs(self, joblist):
"""
Expand Down Expand Up @@ -138,7 +147,7 @@ def submit(self, step, path, cwd, job_map=None, env=None):
@abstractmethod
def key(self):
"""
The key to be used in workflow specification to describe the adapter.
Return the key name for a ScriptAdapter..

This is used to register the adapter in the ScriptAdapterFactory
and when writing the workflow specification.
Expand Down
6 changes: 2 additions & 4 deletions maestrowf/interfaces/script/fluxscriptadapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def __init__(self, **kwargs):

:param **kwargs: A dictionary with default settings for the adapter.
"""
super(SpectrumFluxScriptAdapter, self).__init__()
super(SpectrumFluxScriptAdapter, self).__init__(**kwargs)

# NOTE: These libraries are compiled at runtime when an allocation
# is spun up.
Expand All @@ -94,7 +94,6 @@ def __init__(self, **kwargs):
self._mpi_exe = kwargs.pop("mpi")
self._addl_args = kwargs.pop("args", [])

self._exec = "#!/bin/bash"
# Header is only for informational purposes.
self._header = {
"nodes": "#SBATCH -N {nodes}",
Expand Down Expand Up @@ -502,7 +501,7 @@ def __init__(self, **kwargs):

:param **kwargs: A dictionary with default settings for the adapter.
"""
super(FluxScriptAdapter, self).__init__()
super(FluxScriptAdapter, self).__init__(**kwargs)

# NOTE: These libraries are compiled at runtime when an allocation
# is spun up.
Expand All @@ -514,7 +513,6 @@ def __init__(self, **kwargs):
self.add_batch_parameter("nodes", kwargs.pop("nodes", "1"))
self._addl_args = kwargs.get("args", [])

self._exec = "#!/bin/bash"
# Header is only for informational purposes.
self._header = {
"nodes": "#INFO (nodes) {nodes}",
Expand Down
5 changes: 2 additions & 3 deletions maestrowf/interfaces/script/localscriptadapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,8 @@ def __init__(self, **kwargs):

:param **kwargs: A dictionary with default settings for the adapter.
"""
super(LocalScriptAdapter, self).__init__()

self._exec = kwargs.pop("shell", "/bin/bash")
LOGGER.debug("kwargs\n--------------------------\n%s", kwargs)
super(LocalScriptAdapter, self).__init__(**kwargs)

def _write_script(self, ws_path, step):
"""
Expand Down
2 changes: 1 addition & 1 deletion maestrowf/interfaces/script/slurmscriptadapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def __init__(self, **kwargs):

:param **kwargs: A dictionary with default settings for the adapter.
"""
super(SlurmScriptAdapter, self).__init__()
super(SlurmScriptAdapter, self).__init__(**kwargs)

# NOTE: Host doesn't seem to matter for SLURM. sbatch assumes that the
# current host is where submission occurs.
Expand Down
3 changes: 3 additions & 0 deletions maestrowf/maestro.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,9 @@ def run_study(args):
if not spec.batch:
exec_dag.set_adapter({"type": "local"})
else:
if "type" not in spec.batch:
spec.batch["type"] = "local"

exec_dag.set_adapter(spec.batch)

# Copy the spec to the output directory
Expand Down
3 changes: 3 additions & 0 deletions samples/lulesh/lulesh_sample1_macosx.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ env:
url: https://github.com/LLNL/LULESH.git
tag: 2.0.3

batch:
shell: /bin/bash

study:
- name: make-lulesh
description: Build the serial version of LULESH.
Expand Down