From 54d3c0d23aa3ee162d0fa32888ef7903d93b5d1a Mon Sep 17 00:00:00 2001 From: Francesco Di Natale Date: Fri, 26 Apr 2019 09:12:11 -0700 Subject: [PATCH] Fixes the addition of the shebang header for SLURM (#184) * Docstring correction for LocalAdapter. * Correction to addition of exec line at top of scripts. --- maestrowf/interfaces/script/localscriptadapter.py | 5 ++--- maestrowf/interfaces/script/slurmscriptadapter.py | 12 ++++++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/maestrowf/interfaces/script/localscriptadapter.py b/maestrowf/interfaces/script/localscriptadapter.py index b55722c43..911ed4cf2 100644 --- a/maestrowf/interfaces/script/localscriptadapter.py +++ b/maestrowf/interfaces/script/localscriptadapter.py @@ -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. diff --git a/maestrowf/interfaces/script/slurmscriptadapter.py b/maestrowf/interfaces/script/slurmscriptadapter.py index cef122203..53189abef 100644 --- a/maestrowf/interfaces/script/slurmscriptadapter.py +++ b/maestrowf/interfaces/script/slurmscriptadapter.py @@ -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(): @@ -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))