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

Maximum filename length #2061

Closed
jokedurnez opened this issue Jun 1, 2017 · 12 comments · Fixed by #3495
Closed

Maximum filename length #2061

jokedurnez opened this issue Jun 1, 2017 · 12 comments · Fixed by #3495
Labels

Comments

@jokedurnez
Copy link
Contributor

This code runs without problem:
(note that you can reproduce the full analysis if you change the name of the nifti in the first line to one that exists on a local machine)

copes = ['/oak/stanford/groups/russpold/data/ds000030_R1.0.3_analysis_0.4.4_group/sub-50073/stopsignal.feat/stats/cope1.nii.gz']*2
copemerge = Node(interface=fsl.Merge(dimension='t',in_files=copes),name='copemerge')
median = Node(interface=fsl.maths.MaxImage(dimension="T"),name="max")
CNPgroup = Workflow(name='cnp_group')
CNPgroup.connect([(copemerge,median,[('merged_file','in_file')])])
CNPgroup.run()

When I make the first two lines into an iterable, like the following, the problem appears.

copes = [['/oak/stanford/groups/russpold/data/ds000030_R1.0.3_analysis_0.4.4_group/sub-50073/stopsignal.feat/stats/cope1.nii.gz']*2]*2
copemerge = Node(interface=fsl.Merge(dimension='t'),name='copemerge')
copemerge.iterables = ('in_files',copes)
(next lines equal to the ones in the previous code snippet)

This is the error trace:

170601-16:26:25,882 workflow ERROR:
         ['Node copemerge.aI.a0 failed to run on host sh-5-36.local.']
170601-16:26:25,883 workflow INFO:
         Saving crash info to /home/jdurnez/crash-20170601-162625-jdurnez-copemerge.aI.a0-c7647a64-69ca-49a2-8e44-50c99755d74e.pklz
170601-16:26:25,883 workflow INFO:
         Traceback (most recent call last):
  File "/scratch/PI/russpold/crn-agave/anaconda/lib/python2.7/site-packages/nipype/pipeline/plugins/linear.py", line 39, in run
    node.run(updatehash=updatehash)
  File "/scratch/PI/russpold/crn-agave/anaconda/lib/python2.7/site-packages/nipype/pipeline/engine/nodes.py", line 387, in run
    outdir = make_output_dir(outdir)
  File "/scratch/PI/russpold/crn-agave/anaconda/lib/python2.7/site-packages/nipype/pipeline/engine/utils.py", line 1076, in make_output_dir
    raise OSError('Could not create %s'%outdir)

OSError: Could not create /local-scratch/jdurnez/15385190/tmpKhcTIF/cnp_group/_in_files_..oak..stanford..groups..russpold..data..ds000030_R1.0.3_analysis_0.4.4_group..sub-50073..stopsign
al.feat..stats..cope1.nii.gz...oak..stanford..groups..russpold..data..ds000030_R1.0.3_analysis_0.4.4_group..sub-50073..stopsignal.feat..stats..cope1.nii.gz/copemerge

I think because this outputdir exceeds the maximum number of characters in a file/folder name.
See the following, where I cut off the following directory name (not full path) at 255 characters in the second try:

[jdurnez@sh-5-36 ~]$ getconf NAME_MAX /local-scratch
255
[jdurnez@sh-5-36 ~]$ mkdir /local-scratch/jdurnez/15385190/tmp8WFMe1/cnp_group/_in_files_..oak..stanford..groups..russpold..data..ds000030_R1.0.3_analysis_0.4.4_group..sub50073..stopsignal.feat..stats..cope1.nii.gz...oak..stanford..groups..russpold..data..ds000030_R1.0.3_analysis_0.4.4_group..sub50073..stopsignal.feat..stats..cope1.nii.gz
mkdir: cannot create directory `/local-scratch/jdurnez/15385190/tmp8WFMe1/cnp_group/_in_files_..oak..stanford..groups..russpold..data..ds000030_R1.0.3_analysis_0.4.4_group..sub50073..stopsignal.feat..stats..cope1.nii.gz...oak..stanford..groups..russpold..data..ds000030_R1.0.3_analysis_0.4.4_group..sub50073..stopsignal.feat..stats..cope1.nii.gz': File name too long
[jdurnez@sh-5-36 ~]$ mkdir /localscratch/jdurnez/15385190/tmp8WFMe1/cnp_group/_in_files_..oak..stanford..groups..russpold..data..ds000030_R1.0.3_analysis_0.4.4_group..sub50073..stopsignal.feat..stats..cope1.nii.gz...oak..stanford..groups..russpold..data..ds000030_R1.0.3_analysis_0.4.4_group..sub-50073..stopsignal.feat..stats..cope
[jdurnez@sh-5-36 ~]$

I'm going to solve it by manually looping instead of using the iterables, but I thought you'd want to know. I'm not going to try to solve this, looks too deep in the nipype code, but maybe it would be better to use a random string for the iter folder instead?

@satra
Copy link
Member

satra commented Jun 2, 2017

@jokedurnez - do you set this config option to false by any chance?

config['execution']['parameterize_dirs']

the default value is true and by default it should have turned that long parameterization to a hash.

@mgxd
Copy link
Member

mgxd commented Jun 2, 2017

@satra that option should be set to False in order to convert iterables > 32 characters into a hash. Right now the default is set to True, but turning this option off in the base config would be a good idea.

@satra
Copy link
Member

satra commented Jun 2, 2017

@mgxd - thank you. @jokedurnez - i stand corrected. to prevent the error you are receiving you can do:

workflow_variable.config['execution']['parameterize_dirs'] = False

@jokedurnez
Copy link
Contributor Author

Cool, thanks !

@jokedurnez
Copy link
Contributor Author

btw this didn't work for me.

@satra
Copy link
Member

satra commented Jun 4, 2017

@jokedurnez - do you have node object that crashes? if so can you please inspect it to see if the config is set correctly?

from nipype.utils.filemanip import loadpkl

node = loadpkl('_node.pklz')
node.config['execution']['parameterize_dirs']

was this run with current nipype? (although that particular feature has been around for a while).

@mgxd
Copy link
Member

mgxd commented Jun 8, 2017

@jokedurnez is this still a problem? If so, can you try clearing your working directory?

@mgxd mgxd added the question label Jun 8, 2017
@jokedurnez
Copy link
Contributor Author

I changed my pipeline so that it loops over the iterables to circumvent the problem. I'll try the proposed solution later to verify.

@mgxd
Copy link
Member

mgxd commented Oct 31, 2017

closing - feel free to reopen

@mgxd mgxd closed this as completed Oct 31, 2017
@MontrealSergiy
Copy link

MontrealSergiy commented Jul 19, 2022

The section about config file and parameterize_dirs disappeared from the recent nipype documentation at https://nipype.readthedocs.io. Is it deprecated now?

@effigies
Copy link
Member

@erikglee
Copy link

Would you ever consider setting parameterize_dirs to false as a default in nipype? We are working on integrating MRIQC into CBRAIN (http://www.cbrain.ca/), and have run into an issue with file name lengths. While the solution posted above should hopefully work for this version of MRIQC, having this changed in nipype's defaults would make it so we don't have to implement this change in future containerized versions of MRIQC + limit the likelihood of this happening for other pipelines we work with. I would understand if there are negative repercussions of this change that would outweigh the potential utility. Thanks!

effigies pushed a commit that referenced this issue Sep 5, 2022
* 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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants