Changing node's tmp folder?



Is it possible to set different tmp directory for a node?

My default tmp is on a small system partition and I would like to change that.


If I understand your question correctly, then yes, you can change where your node writes to with the base_dir attribute of the node.


from nipype.pipeline import engine as pe
from nipype.interfaces import utility as niu
import os
import shutil

def make_file(name):
    from pathlib import Path
    import os

    return os.path.abspath(name)
mf_interface = niu.Function(function=make_file, output_names=['myfile'])

tmp_mf_node = pe.Node(mf_interface, name='tmp_mf_node')
my_mf_node = pe.Node(mf_interface, name='my_mf_node') = = 'myfile.txt'

# make base dir different for my_mf_node
test_path = os.path.join(os.getcwd(), 'test')
os.makedirs(test_path, exist_ok=True)
my_mf_node.base_dir = test_path

tmp_res =
my_res =

print('tmp_res: {}'.format(tmp_res.outputs.myfile))
print('my_res: {}'.format(my_res.outputs.myfile))


190212-14:23:58,317 nipype.workflow INFO:
	 [Node] Setting-up "tmp_mf_node" in "/tmp/tmp7lc_ldd9/tmp_mf_node".
190212-14:23:58,320 nipype.workflow INFO:
	 [Node] Running "tmp_mf_node" ("nipype.interfaces.utility.wrappers.Function")
190212-14:23:58,328 nipype.workflow INFO:
	 [Node] Finished "tmp_mf_node".
190212-14:23:58,330 nipype.workflow INFO:
	 [Node] Setting-up "my_mf_node" in "/home/james/test/my_mf_node".
190212-14:23:58,335 nipype.workflow INFO:
	 [Node] Running "my_mf_node" ("nipype.interfaces.utility.wrappers.Function")
190212-14:23:58,344 nipype.workflow INFO:
	 [Node] Finished "my_mf_node".
tmp_res: /tmp/tmp7lc_ldd9/tmp_mf_node/myfile.txt
my_res: /home/james/test/my_mf_node/myfile.txt

Hope this helps!