Skip to content

Commit af3f8df

Browse files
authored
Fixed bug for work dirs longer than 255 characters, fixes #2061 (#3495)
* 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).
1 parent 0a8316d commit af3f8df

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

nipype/pipeline/engine/nodes.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -293,9 +293,12 @@ def output_dir(self):
293293
if self._hierarchy:
294294
outputdir = op.join(outputdir, *self._hierarchy.split("."))
295295
if self.parameterization:
296-
params_str = ["{}".format(p) for p in self.parameterization]
297-
if not str2bool(self.config["execution"]["parameterize_dirs"]):
298-
params_str = [_parameterization_dir(p) for p in params_str]
296+
maxlen = (
297+
252 if str2bool(self.config["execution"]["parameterize_dirs"]) else 32
298+
)
299+
params_str = [
300+
_parameterization_dir(str(p), maxlen) for p in self.parameterization
301+
]
299302
outputdir = op.join(outputdir, *params_str)
300303

301304
self._output_dir = op.realpath(op.join(outputdir, self.name))

nipype/pipeline/engine/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@
5151
logger = logging.getLogger("nipype.workflow")
5252

5353

54-
def _parameterization_dir(param):
54+
def _parameterization_dir(param, maxlen):
5555
"""
5656
Returns the directory name for the given parameterization string as follows:
57-
- If the parameterization is longer than 32 characters, then
57+
- If the parameterization is longer than maxlen characters, then
5858
return the SHA-1 hex digest.
5959
- Otherwise, return the parameterization unchanged.
6060
"""
61-
if len(param) > 32:
61+
if len(param) > maxlen:
6262
return sha1(param.encode()).hexdigest()
6363
return param
6464

0 commit comments

Comments
 (0)