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 authored and FrankD412 committed May 28, 2022
1 parent af02c7d commit 54d3c0d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
5 changes: 2 additions & 3 deletions maestrowf/interfaces/script/localscriptadapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,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
12 changes: 8 additions & 4 deletions maestrowf/interfaces/script/slurmscriptadapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,13 @@ def get_header(self, step):
:returns: A string of the header based on internal batch parameters and
the parameter step.
"""
resources = ChainMap(step.run, self._batch)
resources["job-name"] = step.name.replace(" ", "_")
resources["comment"] = step.description.replace("\n", " ")
run = dict(step.run)
batch_header = dict(self._batch)
batch_header["walltime"] = run.pop("walltime")
if run["nodes"]:
batch_header["nodes"] = run.pop("nodes")
batch_header["job-name"] = step.name.replace(" ", "_")
batch_header["comment"] = step.description.replace("\n", " ")

modified_header = ["#!{}".format(self._exec)]
for key, value in self._header.items():
Expand Down Expand Up @@ -364,7 +368,7 @@ def _write_script(self, ws_path, step):
else:
header = "#!{}".format(self._exec)

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

Expand Down

0 comments on commit 54d3c0d

Please sign in to comment.