Skip to content

Commit 9cb7a68

Browse files
committed
Fixed pickling bug of instance method by passing profiling flag instead of complete plugin_args dict
1 parent e5945e9 commit 9cb7a68

File tree

4 files changed

+25
-19
lines changed

4 files changed

+25
-19
lines changed

nipype/interfaces/utility.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -450,14 +450,14 @@ def _run_interface(self, runtime):
450450
args[name] = value
451451

452452
# Record memory of function_handle
453-
try:
454-
import memory_profiler
455-
proc = (function_handle, (), args)
456-
mem_mb, out = memory_profiler.memory_usage(proc=proc, retval=True, include_children=True, max_usage=True)
457-
setattr(runtime, 'cmd_memory', mem_mb[0]/1024.0)
453+
#try:
454+
# import memory_profiler
455+
# proc = (function_handle, (), args)
456+
# mem_mb, out = memory_profiler.memory_usage(proc=proc, retval=True, include_children=True, max_usage=True)
457+
# setattr(runtime, 'cmd_memory', mem_mb[0]/1024.0)
458458
# If no memory_profiler package, run without recording memory
459-
except:
460-
out = function_handle(**args)
459+
#except:
460+
out = function_handle(**args)
461461

462462
if len(self._output_names) == 1:
463463
self._out[self._output_names[0]] = out

nipype/pipeline/plugins/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ def run(self, graph, config, updatehash=False):
250250
self._clear_task(taskid)
251251
else:
252252
toappend.insert(0, (taskid, jobid))
253-
except Exception:
253+
except Exception as exc:
254254
result = {'result': None,
255255
'traceback': format_exc()}
256256
notrun.append(self._clean_queue(jobid, graph,

nipype/pipeline/plugins/multiproc.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,20 @@
2121

2222

2323
# Run node
24-
def run_node(node, updatehash, plugin_args=None):
24+
def run_node(node, updatehash, runtime_profile=False):
2525
"""docstring
2626
"""
27-
27+
2828
# Import packages
2929
try:
30-
runtime_profile = plugin_args['runtime_profile']
3130
import memory_profiler
3231
import datetime
33-
except KeyError:
34-
runtime_profile = False
3532
except ImportError:
3633
runtime_profile = False
37-
34+
3835
# Init variables
3936
result = dict(result=None, traceback=None)
40-
37+
runtime_profile = False
4138
# If we're profiling the run
4239
if runtime_profile:
4340
try:
@@ -167,9 +164,14 @@ def _submit_job(self, node, updatehash=False):
167164
node.inputs.terminal_output = 'allatonce'
168165
except:
169166
pass
170-
self._taskresult[self._taskid] = self.pool.apply_async(run_node,
171-
(node, updatehash, self.plugin_args),
172-
callback=release_lock)
167+
try:
168+
runtime_profile = self.plugin_args['runtime_profile']
169+
except:
170+
runtime_profile = False
171+
self._taskresult[self._taskid] = \
172+
self.pool.apply_async(run_node,
173+
(node, updatehash, runtime_profile),
174+
callback=release_lock)
173175
return self._taskid
174176

175177
def _send_procs_to_workers(self, updatehash=False, graph=None):

nipype/pipeline/plugins/tests/test_callback.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class Status(object):
2626
def __init__(self):
2727
self.statuses = []
2828

29-
def callback(self, node, status):
29+
def callback(self, node, status, result=None):
3030
self.statuses.append((node, status))
3131

3232

@@ -105,3 +105,7 @@ def test_callback_multiproc_exception():
105105
yield assert_equal, so.statuses[0][1], 'start'
106106
yield assert_equal, so.statuses[1][1], 'exception'
107107
rmtree(wf.base_dir)
108+
109+
if __name__ == '__main__':
110+
import nose
111+
nose.run()

0 commit comments

Comments
 (0)