From 99aad8ab6c6e2d904ed3b1cbc196e006623167c3 Mon Sep 17 00:00:00 2001 From: Pierre Rioux Date: Thu, 21 Jul 2022 15:55:45 -0400 Subject: [PATCH 1/4] Fixed bug for work dirs longer than 255 characters This change is fully backwards compatible and will not affect existing pipelines, but it will prevent the pipeline engine from crashing when some parameters are long and it was trying to create subdirectories longer than 255 characters (a typical unix limit). --- nipype/pipeline/engine/nodes.py | 3 ++- nipype/pipeline/engine/utils.py | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/nipype/pipeline/engine/nodes.py b/nipype/pipeline/engine/nodes.py index 59fb2e6724..1b2640369e 100644 --- a/nipype/pipeline/engine/nodes.py +++ b/nipype/pipeline/engine/nodes.py @@ -295,7 +295,8 @@ def output_dir(self): if self.parameterization: params_str = ["{}".format(p) for p in self.parameterization] if not str2bool(self.config["execution"]["parameterize_dirs"]): - params_str = [_parameterization_dir(p) for p in params_str] + params_str = [_parameterization_dir(p,32) for p in params_str] + params_str = [_parameterization_dir(p,252) for p in params_str] outputdir = op.join(outputdir, *params_str) self._output_dir = op.realpath(op.join(outputdir, self.name)) diff --git a/nipype/pipeline/engine/utils.py b/nipype/pipeline/engine/utils.py index a1666b855a..c050d7d6b9 100644 --- a/nipype/pipeline/engine/utils.py +++ b/nipype/pipeline/engine/utils.py @@ -51,14 +51,14 @@ logger = logging.getLogger("nipype.workflow") -def _parameterization_dir(param): +def _parameterization_dir(param,maxlen): """ Returns the directory name for the given parameterization string as follows: - - If the parameterization is longer than 32 characters, then + - If the parameterization is longer than maxlen characters, then return the SHA-1 hex digest. - Otherwise, return the parameterization unchanged. """ - if len(param) > 32: + if len(param) > maxlen: return sha1(param.encode()).hexdigest() return param From 3b557eefec05806a5ea205fbbbafde0a8bed006a Mon Sep 17 00:00:00 2001 From: Pierre Rioux Date: Tue, 26 Jul 2022 17:11:07 -0400 Subject: [PATCH 2/4] Update nipype/pipeline/engine/utils.py Co-authored-by: Chris Markiewicz --- nipype/pipeline/engine/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nipype/pipeline/engine/utils.py b/nipype/pipeline/engine/utils.py index c050d7d6b9..b744849c57 100644 --- a/nipype/pipeline/engine/utils.py +++ b/nipype/pipeline/engine/utils.py @@ -51,7 +51,7 @@ logger = logging.getLogger("nipype.workflow") -def _parameterization_dir(param,maxlen): +def _parameterization_dir(param, maxlen): """ Returns the directory name for the given parameterization string as follows: - If the parameterization is longer than maxlen characters, then From 0094bed9c4b2149b0055ac44ada1fe768ab8a311 Mon Sep 17 00:00:00 2001 From: Pierre Rioux Date: Mon, 1 Aug 2022 13:45:38 -0400 Subject: [PATCH 3/4] Update nodes.py As suggested by @effigies --- nipype/pipeline/engine/nodes.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/nipype/pipeline/engine/nodes.py b/nipype/pipeline/engine/nodes.py index 1b2640369e..20ea70e2f2 100644 --- a/nipype/pipeline/engine/nodes.py +++ b/nipype/pipeline/engine/nodes.py @@ -293,10 +293,8 @@ def output_dir(self): if self._hierarchy: outputdir = op.join(outputdir, *self._hierarchy.split(".")) if self.parameterization: - params_str = ["{}".format(p) for p in self.parameterization] - if not str2bool(self.config["execution"]["parameterize_dirs"]): - params_str = [_parameterization_dir(p,32) for p in params_str] - params_str = [_parameterization_dir(p,252) for p in params_str] + maxlen = 252 if str2bool(self.config["execution"]["parameterize_dirs"]) else 32 + params_str = [_parameterization_dir(str(p), maxlen) for p in self.parameterization] outputdir = op.join(outputdir, *params_str) self._output_dir = op.realpath(op.join(outputdir, self.name)) From 97c05fb34790bca0988bbc5cf17e745dbd074ab7 Mon Sep 17 00:00:00 2001 From: "Christopher J. Markiewicz" Date: Mon, 5 Sep 2022 09:09:09 -0400 Subject: [PATCH 4/4] STY: black --- nipype/pipeline/engine/nodes.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/nipype/pipeline/engine/nodes.py b/nipype/pipeline/engine/nodes.py index 20ea70e2f2..20fe360504 100644 --- a/nipype/pipeline/engine/nodes.py +++ b/nipype/pipeline/engine/nodes.py @@ -293,8 +293,12 @@ def output_dir(self): if self._hierarchy: outputdir = op.join(outputdir, *self._hierarchy.split(".")) if self.parameterization: - maxlen = 252 if str2bool(self.config["execution"]["parameterize_dirs"]) else 32 - params_str = [_parameterization_dir(str(p), maxlen) for p in self.parameterization] + maxlen = ( + 252 if str2bool(self.config["execution"]["parameterize_dirs"]) else 32 + ) + params_str = [ + _parameterization_dir(str(p), maxlen) for p in self.parameterization + ] outputdir = op.join(outputdir, *params_str) self._output_dir = op.realpath(op.join(outputdir, self.name))