Skip to content

Commit 5dac574

Browse files
committed
Merged Carol's changes
2 parents a68e0e6 + 0bb6d79 commit 5dac574

File tree

5 files changed

+51
-43
lines changed

5 files changed

+51
-43
lines changed

nipype/interfaces/tests/test_io.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def test_selectfiles_valueerror():
9494
yield assert_raises, ValueError, sf.run
9595

9696

97-
@skipif(noboto)
97+
@skip
9898
def test_s3datagrabber_communication():
9999
dg = nio.S3DataGrabber(
100100
infields=['subj_id', 'run_num'], outfields=['func', 'struct'])

nipype/pipeline/plugins/callback_log.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,27 @@ def log_nodes_cb(node, status, result=None):
1313
if status == 'start':
1414
message = '{"name":' + '"' + node.name + '"' + ',"id":' + '"' +\
1515
node._id + '"' + ',"start":' + '"' +str(datetime.datetime.now()) +\
16-
'"' + ',"estimate memory":' + str(node._interface.estimated_memory) + ',"num_threads":' \
16+
'"' + ',"estimated_memory":' + str(node._interface.estimated_memory) + ',"num_threads":' \
1717
+ str(node._interface.num_threads) + '}'
1818

1919
logger.debug(message)
2020

2121
elif status == 'end':
2222
message = '{"name":' + '"' + node.name + '"' + ',"id":' + '"' + \
23-
node._id + '"' + ',"finish":' + '"' + str(datetime.datetime.now()) + \
24-
'"' + ',"estimate memory":' + str(node._interface.estimated_memory) + \
25-
',"num_threads":' + str(node._interface.num_threads) + \
26-
',"cmd-level threads":' + str(cmd_threads) + \
27-
',"node-level memory":' + str(node_mem) + \
28-
',"cmd-level memory":' + str(cmd_mem) + \
29-
',"run_seconds":' + str(run_seconds) + '}'
23+
node._id + '"' + ',"finish":' + '"' + str(datetime.datetime.now()) + \
24+
'"' + ',"estimated_memory":' + '"'+ str(node._interface.estimated_memory) + '"'+ \
25+
',"num_threads":' + '"'+ str(node._interface.num_threads) + '"'+ \
26+
',"cmd-level_threads":' + '"'+ str(cmd_threads) + '"'+ \
27+
',"node-level_memory":' + '"'+ str(node_mem) + '"'+ \
28+
',"cmd-level_memory":' + '"'+ str(cmd_mem) + '"' + \
29+
',"run_seconds":' + '"'+ str(run_seconds) + '"'+ '}'
3030

3131
logger.debug(message)
3232

3333
else:
3434
message = '{"name":' + '"' + node.name + '"' + ',"id":' + '"' + \
3535
node._id + '"' + ',"finish":' + '"' + str(datetime.datetime.now()) +\
36-
'"' + ',"estimate memory":' + str(node._interface.estimated_memory) + ',"num_threads":' \
36+
'"' + ',"estimated_memory":' + str(node._interface.estimated_memory) + ',"num_threads":' \
3737
+ str(node._interface.num_threads) + ',"error":"True"}'
3838

3939
logger.debug(message)

nipype/pipeline/plugins/multiproc.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,14 @@
99
from multiprocessing import Process, Pool, cpu_count, pool
1010
from traceback import format_exception
1111
import sys
12-
12+
import numpy as np
13+
from copy import deepcopy
14+
from ..engine import MapNode
15+
from ...utils.misc import str2bool
16+
import datetime
17+
import psutil
18+
from ... import logging
19+
import semaphore_singleton
1320
from .base import (DistributedPluginBase, report_crash)
1421

1522

@@ -76,14 +83,6 @@ class NonDaemonPool(pool.Pool):
7683
"""
7784
Process = NonDaemonProcess
7885

79-
import numpy as np
80-
from copy import deepcopy
81-
from ..engine import MapNode
82-
from ...utils.misc import str2bool
83-
import datetime
84-
import psutil
85-
from ... import logging
86-
import semaphore_singleton
8786
logger = logging.getLogger('workflow')
8887

8988
def release_lock(args):

nipype/pipeline/plugins/tests/test_multiproc.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from nipype.testing import assert_equal, assert_less_equal
77
import nipype.pipeline.engine as pe
88

9-
9+
1010
class InputSpec(nib.TraitedSpec):
1111
input1 = nib.traits.Int(desc='a random int')
1212
input2 = nib.traits.Int(desc='a random int')
@@ -182,6 +182,8 @@ def test_do_not_use_more_memory_then_specified():
182182
os.remove(LOG_FILENAME)
183183

184184

185+
186+
185187
def test_do_not_use_more_threads_then_specified():
186188
LOG_FILENAME = 'callback.log'
187189
my_logger = logging.getLogger('callback')
@@ -231,4 +233,4 @@ def test_do_not_use_more_threads_then_specified():
231233
break
232234
yield assert_equal, result, True, "using more memory than system has (memory is not specified by user)"
233235

234-
os.remove(LOG_FILENAME)
236+
os.remove(LOG_FILENAME)

nipype/utils/draw_gantt_chart.py

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,39 @@
33
import datetime
44
import random
55

6-
6+
77
def log_to_json(logfile):
88
result = []
99
with open(logfile, 'r') as content:
1010

11-
#read file separating each line
12-
content = content.read()
13-
lines = content.split('\n')
14-
15-
lines = [ json.loads(x) for x in lines[:-1]]
16-
17-
last_node = [ x for x in lines if x.has_key('finish')][-1]
18-
19-
for i, line in enumerate(lines):
20-
#get first start it finds
21-
if not line.has_key('start'):
22-
continue
23-
24-
#fint the end node for that start
25-
for j in range(i+1, len(lines)):
26-
if lines[j].has_key('finish'):
27-
if lines[j]['id'] == line['id'] and lines[j]['name'] == line['name']:
28-
line['finish'] = lines[j]['finish']
29-
line['duration'] = (parser.parse(line['finish']) - parser.parse(line['start'])).total_seconds()
30-
result.append(line)
31-
break
11+
#read file separating each line
12+
content = content.read()
13+
lines = content.split('\n')
14+
l = []
15+
for i in lines:
16+
try:
17+
y = json.loads(i)
18+
l.append(y)
19+
except Exception, e:
20+
pass
21+
22+
lines = l
23+
24+
last_node = [ x for x in lines if x.has_key('finish')][-1]
25+
26+
for i, line in enumerate(lines):
27+
#get first start it finds
28+
if not line.has_key('start'):
29+
continue
30+
31+
#fint the end node for that start
32+
for j in range(i+1, len(lines)):
33+
if lines[j].has_key('finish'):
34+
if lines[j]['id'] == line['id'] and lines[j]['name'] == line['name']:
35+
line['finish'] = lines[j]['finish']
36+
line['duration'] = (parser.parse(line['finish']) - parser.parse(line['start'])).total_seconds()
37+
result.append(line)
38+
break
3239

3340
return result, last_node
3441

0 commit comments

Comments
 (0)