Skip to content

Commit 350fd4a

Browse files
committed
add attribute real_memory to interface, change attr memory to estimated_memory
1 parent f34b6d6 commit 350fd4a

File tree

5 files changed

+16
-15
lines changed

5 files changed

+16
-15
lines changed

nipype/interfaces/base.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,8 @@ def __init__(self, **inputs):
750750
raise Exception('No input_spec in class: %s' %
751751
self.__class__.__name__)
752752
self.inputs = self.input_spec(**inputs)
753-
self.memory = 1
753+
self.estimated_memory = 1
754+
self.real_memory = 0
754755
self.num_threads = 1
755756

756757
@classmethod

nipype/pipeline/plugins/callback_log.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,23 @@ def log_nodes_cb(node, status):
77
if status == 'start':
88
message = '{"name":' + '"' + node.name + '"' + ',"id":' + '"' +\
99
node._id + '"' + ',"start":' + '"' +str(datetime.datetime.now()) +\
10-
'"' + ',"memory":' + str(node._interface.memory) + ',"num_threads":' \
10+
'"' + ',"memory":' + str(node._interface.estimated_memory) + ',"num_threads":' \
1111
+ str(node._interface.num_threads) + '}'
1212

1313
logger.debug(message)
1414

1515
elif status == 'end':
1616
message = '{"name":' + '"' + node.name + '"' + ',"id":' + '"' + \
1717
node._id + '"' + ',"finish":' + '"' + str(datetime.datetime.now()) +\
18-
'"' + ',"memory":' + str(node._interface.memory) + ',"num_threads":' \
18+
'"' + ',"memory":' + str(node._interface.estimated_memory) + ',"num_threads":' \
1919
+ str(node._interface.num_threads) + '}'
2020

2121
logger.debug(message)
2222

2323
else:
2424
message = '{"name":' + '"' + node.name + '"' + ',"id":' + '"' + \
2525
node._id + '"' + ',"finish":' + '"' + str(datetime.datetime.now()) +\
26-
'"' + ',"memory":' + str(node._interface.memory) + ',"num_threads":' \
26+
'"' + ',"memory":' + str(node._interface.estimated_memory) + ',"num_threads":' \
2727
+ str(node._interface.num_threads) + ',"error":"True"}'
2828

2929
logger.debug(message)

nipype/pipeline/plugins/multiproc.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ def _send_procs_to_workers(self, updatehash=False, graph=None):
177177
busy_memory = 0
178178
busy_processors = 0
179179
for jobid in jobids:
180-
busy_memory+= self.procs[jobid]._interface.memory
180+
busy_memory+= self.procs[jobid]._interface.estimated_memory
181181
busy_processors+= self.procs[jobid]._interface.num_threads
182182

183183
free_memory = self.memory - busy_memory
@@ -190,17 +190,17 @@ def _send_procs_to_workers(self, updatehash=False, graph=None):
190190

191191
#sort jobs ready to run first by memory and then by number of threads
192192
#The most resource consuming jobs run first
193-
jobids = sorted(jobids, key=lambda item: (self.procs[item]._interface.memory, self.procs[item]._interface.num_threads))
193+
jobids = sorted(jobids, key=lambda item: (self.procs[item]._interface.estimated_memory, self.procs[item]._interface.num_threads))
194194

195195
logger.debug('Free memory: %d, Free processors: %d', free_memory, free_processors)
196196

197197

198198
#while have enough memory and processors for first job
199199
#submit first job on the list
200200
for jobid in jobids:
201-
logger.debug('Next Job: %d, memory: %d, threads: %d' %(jobid, self.procs[jobid]._interface.memory, self.procs[jobid]._interface.num_threads))
201+
logger.debug('Next Job: %d, memory: %d, threads: %d' %(jobid, self.procs[jobid]._interface.estimated_memory, self.procs[jobid]._interface.num_threads))
202202

203-
if self.procs[jobid]._interface.memory <= free_memory and self.procs[jobid]._interface.num_threads <= free_processors:
203+
if self.procs[jobid]._interface.estimated_memory <= free_memory and self.procs[jobid]._interface.num_threads <= free_processors:
204204
logger.info('Executing: %s ID: %d' %(self.procs[jobid]._id, jobid))
205205
executing_now.append(self.procs[jobid])
206206

@@ -220,7 +220,7 @@ def _send_procs_to_workers(self, updatehash=False, graph=None):
220220
self.proc_done[jobid] = True
221221
self.proc_pending[jobid] = True
222222

223-
free_memory -= self.procs[jobid]._interface.memory
223+
free_memory -= self.procs[jobid]._interface.estimated_memory
224224
free_processors -= self.procs[jobid]._interface.num_threads
225225

226226
# Send job to task manager and add to pending tasks

nipype/pipeline/plugins/tests/test_multiproc.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def find_metrics(nodes, last_node):
103103
node_finish = parse(nodes[j]['finish'])
104104

105105
if node_start < x and node_finish > x:
106-
total_memory[i] += nodes[j]['memory']
106+
total_memory[i] += nodes[j]['estimated_memory']
107107
total_threads[i] += nodes[j]['num_threads']
108108
start_index = j
109109

@@ -140,10 +140,10 @@ def test_do_not_use_more_memory_then_specified():
140140
n3 = pe.Node(interface=TestInterfaceSingleNode(), name='n3')
141141
n4 = pe.Node(interface=TestInterfaceSingleNode(), name='n4')
142142

143-
n1.interface.memory = 1
144-
n2.interface.memory = 1
145-
n3.interface.memory = 10
146-
n4.interface.memory = 1
143+
n1.interface.estimated_memory = 1
144+
n2.interface.estimated_memory = 1
145+
n3.interface.estimated_memory = 10
146+
n4.interface.estimated_memory = 1
147147

148148
pipe.connect(n1, 'output1', n2, 'input1')
149149
pipe.connect(n1, 'output1', n3, 'input1')

nipype/utils/draw_gantt_chart.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def draw_memory_bar(start, total_duration, nodes, space_between_minutes, minute_
133133
node_finish = parser.parse(nodes[j]['finish'])
134134

135135
if node_start <= now and node_finish >= now:
136-
memory[i] += nodes[j]['memory']
136+
memory[i] += nodes[j]['estimated_memory']
137137
if node_start > now:
138138
break
139139
now += datetime.timedelta(minutes=1)

0 commit comments

Comments
 (0)