From 7ad9461a7fbeccc6f07e83af6452229afb6d26db Mon Sep 17 00:00:00 2001 From: d-vogel Date: Thu, 4 Feb 2021 14:23:41 +0100 Subject: [PATCH 1/2] Avoid empty line in bash script output Remove the newline at the end of template to avoid having am empty line after joining with the node command. This allows to have the node command integrated in more complex call, such as a `singularity exec ...` call. --- nipype/pipeline/plugins/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nipype/pipeline/plugins/base.py b/nipype/pipeline/plugins/base.py index 4be8eb232b..d739e43b7d 100644 --- a/nipype/pipeline/plugins/base.py +++ b/nipype/pipeline/plugins/base.py @@ -549,7 +549,7 @@ def _submit_job(self, node, updatehash=False): pyscript = create_pyscript(node, updatehash=updatehash) batch_dir, name = os.path.split(pyscript) name = ".".join(name.split(".")[:-1]) - batchscript = "\n".join((self._template, "%s %s" % (sys.executable, pyscript))) + batchscript = "\n".join((self._template[:-1], "%s %s" % (sys.executable, pyscript))) batchscriptfile = os.path.join(batch_dir, "batchscript_%s.sh" % name) with open(batchscriptfile, "wt") as fp: fp.writelines(batchscript) From a60eb4ec27dd64c37bf3f9d0f3b9b9d424f7bf62 Mon Sep 17 00:00:00 2001 From: d-vogel Date: Sat, 1 May 2021 14:04:12 +0200 Subject: [PATCH 2/2] Rather remove the newlines than trim the last char of the template. As per @effigies suggestion. Co-authored-by: Chris Markiewicz --- nipype/pipeline/plugins/base.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nipype/pipeline/plugins/base.py b/nipype/pipeline/plugins/base.py index bb64003de6..becc6b4364 100644 --- a/nipype/pipeline/plugins/base.py +++ b/nipype/pipeline/plugins/base.py @@ -543,7 +543,9 @@ def _submit_job(self, node, updatehash=False): pyscript = create_pyscript(node, updatehash=updatehash) batch_dir, name = os.path.split(pyscript) name = ".".join(name.split(".")[:-1]) - batchscript = "\n".join((self._template[:-1], "%s %s" % (sys.executable, pyscript))) + batchscript = "\n".join( + (self._template.rstrip("\n"), "%s %s" % (sys.executable, pyscript)) + ) batchscriptfile = os.path.join(batch_dir, "batchscript_%s.sh" % name) with open(batchscriptfile, "wt") as fp: fp.writelines(batchscript)