Skip to content

Commit

Permalink
Fixes the addition of the shebang header for SLURM (#184)
Browse files Browse the repository at this point in the history
* Docstring correction for LocalAdapter.

* Correction to addition of exec line at top of scripts.
  • Loading branch information
Francesco Di Natale committed Jul 14, 2019
1 parent db3221e commit 8e188fb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 18 deletions.
5 changes: 2 additions & 3 deletions maestrowf/interfaces/script/localscriptadapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,10 @@


class LocalScriptAdapter(ScriptAdapter):
"""A ScriptAdapter class for interfacing for local execution."""

key = "local"

"""
A ScriptAdapter class for interfacing for local execution.
"""
def __init__(self, **kwargs):
"""
Initialize an instance of the LocalScriptAdapter.
Expand Down
25 changes: 10 additions & 15 deletions maestrowf/interfaces/script/slurmscriptadapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def get_header(self, step):
batch_header["job-name"] = step.name.replace(" ", "_")
batch_header["comment"] = step.description.replace("\n", " ")

modified_header = [self._exec]
modified_header = ["#!{}".format(self._exec)]
for key, value in self._header.items():
# If we're looking at the bank and the reservation header exists,
# skip the bank to prefer the reservation.
Expand Down Expand Up @@ -335,27 +335,22 @@ def _write_script(self, ws_path, step):

fname = "{}.slurm.sh".format(step.name)
script_path = os.path.join(ws_path, fname)
with open(script_path, "w") as script:
if to_be_scheduled:
script.write(self.get_header(step))
else:
script.write(self._exec)

cmd = "\n\n{}\n".format(cmd)
script.write(cmd)
if to_be_scheduled:
header = self.get_header(step)
else:
header = "#!{}".format(self._exec)

form_cmd = cmd = "{0}\n\n{1}\n"
with open(script_path, "w") as script:
script.write(form_cmd.format(header, cmd))

if restart:
rname = "{}.restart.slurm.sh".format(step.name)
restart_path = os.path.join(ws_path, rname)

with open(restart_path, "w") as script:
if to_be_scheduled:
script.write(self.get_header(step))
else:
script.write(self._exec)

cmd = "\n\n{}\n".format(restart)
script.write(cmd)
script.write(form_cmd.format(header, restart))
else:
restart_path = None

Expand Down

0 comments on commit 8e188fb

Please sign in to comment.