Skip to content

Commit c42473a

Browse files
committed
remove logging from run_node which blocked mriqc, improve logging of both Nodes and MultiProc
1 parent 1d7afbc commit c42473a

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

nipype/pipeline/engine/nodes.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ def run(self, updatehash=False):
314314
self._get_inputs()
315315
self._got_inputs = True
316316
outdir = self.output_dir()
317-
logger.info("Executing node %s in dir: %s", self._id, outdir)
317+
logger.info("Executing node %s in dir: %s", self.fullname, outdir)
318318
if op.exists(outdir):
319319
logger.debug('Output dir: %s', to_str(os.listdir(outdir)))
320320
hash_info = self.hash_exists(updatehash=updatehash)
@@ -630,20 +630,21 @@ def _run_command(self, execute, copyfiles=True):
630630
runtime=runtime,
631631
inputs=self._interface.inputs.get_traitsfree())
632632
self._result = result
633-
logger.debug('Executing node')
634633
if copyfiles:
635634
self._copyfiles_to_wd(cwd, execute)
635+
636+
message = 'Running a "%s" interface'
636637
if issubclass(self._interface.__class__, CommandLine):
637638
try:
638639
cmd = self._interface.cmdline
639640
except Exception as msg:
640641
self._result.runtime.stderr = msg
641642
raise
642643
cmdfile = op.join(cwd, 'command.txt')
643-
fd = open(cmdfile, 'wt')
644-
fd.writelines(cmd + "\n")
645-
fd.close()
646-
logger.info('Running: %s' % cmd)
644+
with open(cmdfile, 'wt') as fd:
645+
print(cmd + "\n", file=fd)
646+
message += ', a CommandLine Interface with command:\n%s' % cmd
647+
logger.info(message + '.', self._interface.__class__.__name__)
647648
try:
648649
result = self._interface.run()
649650
except Exception as msg:

nipype/pipeline/plugins/multiproc.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import numpy as np
1818

1919
from ... import logging
20-
from ...utils.misc import str2bool
2120
from ...utils.profiler import get_system_total_memory_gb
2221
from ..engine import MapNode
2322
from .base import DistributedPluginBase
@@ -44,10 +43,6 @@ def run_node(node, updatehash, taskid):
4443
dictionary containing the node runtime results and stats
4544
"""
4645

47-
from nipype import logging
48-
logger = logging.getLogger('workflow')
49-
50-
logger.debug('run_node called on %s', node.name)
5146
# Init variables
5247
result = dict(result=None, traceback=None, taskid=taskid)
5348

@@ -148,6 +143,9 @@ def _submit_job(self, node, updatehash=False):
148143
self._task_obj[self._taskid] = self.pool.apply_async(
149144
run_node, (node, updatehash, self._taskid),
150145
callback=self._async_callback)
146+
147+
logger.debug('MultiProc submitted task %s (taskid=%d).',
148+
node.fullname, self._taskid)
151149
return self._taskid
152150

153151
def _prerun_check(self, graph):
@@ -245,7 +243,7 @@ def _send_procs_to_workers(self, updatehash=False, graph=None):
245243
free_memory_gb -= next_job_gb
246244
free_processors -= next_job_th
247245
logger.debug('Allocating %s ID=%d (%0.2fGB, %d threads). Free: %0.2fGB, %d threads.',
248-
self.procs[jobid]._id, jobid, next_job_gb, next_job_th,
246+
self.procs[jobid].fullname, jobid, next_job_gb, next_job_th,
249247
free_memory_gb, free_processors)
250248

251249
# change job status in appropriate queues
@@ -274,7 +272,6 @@ def _send_procs_to_workers(self, updatehash=False, graph=None):
274272

275273
# Task should be submitted to workers
276274
# Send job to task manager and add to pending tasks
277-
logger.debug('MultiProc submitting job ID %d', jobid)
278275
if self._status_callback:
279276
self._status_callback(self.procs[jobid], 'start')
280277
tid = self._submit_job(deepcopy(self.procs[jobid]),

0 commit comments

Comments
 (0)