Repository: nipy/nipype

Issue:
Setting crashdump dir is broken
The docs assert that you can set the crashdump directory in your config file: http://nipy.sourceforge.net/nipype/users/tutorial_103.html?highlight=crashdump#debugging

But this is broken.  It does work if you modify the config attribute on a Workflow object directly, but it doesn't get picked up from the config file.



Discussion:

Resolving patch:
diff --git a/nipype/pipeline/engine.py b/nipype/pipeline/engine.py
--- a/nipype/pipeline/engine.py
+++ b/nipype/pipeline/engine.py
@@ -22,6 +22,7 @@
 from socket import gethostname
 import sys
 from tempfile import mkdtemp
+from warnings import warn
 
 import numpy as np
 
@@ -453,6 +454,11 @@ def run(self, plugin=None, plugin_args=None, updatehash=False):
             else:
                 runner = getattr(sys.modules[name], '%sPlugin'%plugin)(plugin_args=plugin_args)
         flatgraph = self._create_flat_graph()
+        if 'crashdump_dir' in self.config:
+            warnings.warn(("Deprecated: workflow.config['crashdump_dir']\n"
+                           "Please use config['execution']['crashdump_dir']"))
+            self.config['execution']['crashdump_dir'] = self.config['crashdump_dir']
+            del self.config['crashdump_dir']
         self.config = merge_dict(deepcopy(config._sections), self.config)
         logger.info(str(sorted(self.config)))
         self._set_needed_outputs(flatgraph)
@@ -1102,6 +1108,7 @@ def run(self, updatehash=False, force_execute=False):
             Force rerunning the node
         """
         # check to see if output directory and hash exist
+        self.config = merge_dict(deepcopy(config._sections), self.config)
         self._get_inputs()
         outdir = self.output_dir()
         logger.info("Executing node %s in dir: %s"%(self._id,outdir))
diff --git a/nipype/pipeline/plugins/base.py b/nipype/pipeline/plugins/base.py
--- a/nipype/pipeline/plugins/base.py
+++ b/nipype/pipeline/plugins/base.py
@@ -13,6 +13,7 @@
 import sys
 from time import strftime, sleep
 from traceback import format_exception
+from warnings import warn
 
 import numpy as np
 import scipy.sparse as ssp
@@ -53,13 +54,12 @@ def report_crash(node, traceback=None):
     crashfile = 'crash-%s-%s-%s.npz' % (timeofcrash,
                                         login_name,
                                         name)
-    if hasattr(node, 'config') and ('crashdump_dir' in node.config.keys()):
-        if not os.path.exists(node.config['crashdump_dir']):
-            os.makedirs(node.config['crashdump_dir'])
-        crashfile = os.path.join(node.config['crashdump_dir'],
-                                 crashfile)
-    else:
-        crashfile = os.path.join(os.getcwd(), crashfile)
+    crashdir = node.config['execution']['crashdump_dir']
+    if crashdir is None:
+        crashdir=os.getcwd()
+    if not os.path.exists(crashdir):
+        os.makedirs(crashdir)
+    crashfile = os.path.join(crashdir, crashfile)
     logger.info('Saving crash info to %s' % crashfile)
     logger.info(''.join(traceback))
     np.savez(crashfile, node=node, traceback=traceback)
diff --git a/nipype/utils/config.py b/nipype/utils/config.py
--- a/nipype/utils/config.py
+++ b/nipype/utils/config.py
@@ -23,17 +23,18 @@
 log_rotate = 4
 
 [execution]
-plugin = Linear
-stop_on_first_crash = false
-stop_on_first_rerun = false
-keep_inputs = false
+crashdump_dir = %s
 hash_method = timestamp
-single_thread_matlab = true
+keep_inputs = false
+matplotlib_backend = Agg
+plugin = Linear
 remove_node_directories = false
 remove_unnecessary_outputs = true
+single_thread_matlab = true
+stop_on_first_crash = false
+stop_on_first_rerun = false
 use_relative_paths = false
-matplotlib_backend = Agg
-"""%(homedir))
+""" % (homedir, os.getcwd()))
 
 class NipypeConfig(ConfigParser.ConfigParser):
     """Base nipype config class


Test patch: