Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed bug for work dirs longer than 255 characters, fixes #2061 #3495

Merged
merged 4 commits into from
Sep 5, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions nipype/pipeline/engine/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +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) 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))
Expand Down
6 changes: 3 additions & 3 deletions nipype/pipeline/engine/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down