Skip to content

Commit b566b22

Browse files
committed
Changed max memory to 1 GB
1 parent 0305930 commit b566b22

File tree

1 file changed

+59
-59
lines changed

1 file changed

+59
-59
lines changed

nipype/pipeline/plugins/tests/test_multiproc.py

Lines changed: 59 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -122,65 +122,65 @@ def find_metrics(nodes, last_node):
122122
return total_memory, total_threads
123123

124124

125-
#def test_do_not_use_more_memory_then_specified():
126-
# LOG_FILENAME = 'callback.log'
127-
# my_logger = logging.getLogger('callback')
128-
# my_logger.setLevel(logging.DEBUG)
129-
#
130-
# # Add the log message handler to the logger
131-
# handler = logging.FileHandler(LOG_FILENAME)
132-
# my_logger.addHandler(handler)
133-
#
134-
# max_memory = 10
135-
# pipe = pe.Workflow(name='pipe')
136-
# n1 = pe.Node(interface=TestInterfaceSingleNode(), name='n1')
137-
# n2 = pe.Node(interface=TestInterfaceSingleNode(), name='n2')
138-
# n3 = pe.Node(interface=TestInterfaceSingleNode(), name='n3')
139-
# n4 = pe.Node(interface=TestInterfaceSingleNode(), name='n4')
140-
#
141-
# n1.interface.estimated_memory_gb = 1
142-
# n2.interface.estimated_memory_gb = 1
143-
# n3.interface.estimated_memory_gb = 10
144-
# n4.interface.estimated_memory_gb = 1
145-
#
146-
# pipe.connect(n1, 'output1', n2, 'input1')
147-
# pipe.connect(n1, 'output1', n3, 'input1')
148-
# pipe.connect(n2, 'output1', n4, 'input1')
149-
# pipe.connect(n3, 'output1', n4, 'input2')
150-
# n1.inputs.input1 = 10
151-
#
152-
# pipe.run(plugin='MultiProc',
153-
# plugin_args={'memory': max_memory,
154-
# 'status_callback': log_nodes_cb})
155-
#
156-
#
157-
# nodes = draw_gantt_chart.log_to_dict(LOG_FILENAME)
158-
# last_node = nodes[-1]
159-
# #usage in every second
160-
# memory, threads = find_metrics(nodes, last_node)
161-
#
162-
# result = True
163-
# for m in memory:
164-
# if m > max_memory:
165-
# result = False
166-
# break
167-
#
168-
# yield assert_equal, result, True
169-
#
170-
# max_threads = cpu_count()
171-
#
172-
# result = True
173-
# for t in threads:
174-
# if t > max_threads:
175-
# result = False
176-
# break
177-
#
178-
# yield assert_equal, result, True,\
179-
# "using more threads than system has (threads is not specified by user)"
180-
#
181-
# os.remove(LOG_FILENAME)
182-
#
183-
#
125+
def test_do_not_use_more_memory_then_specified():
126+
LOG_FILENAME = 'callback.log'
127+
my_logger = logging.getLogger('callback')
128+
my_logger.setLevel(logging.DEBUG)
129+
130+
# Add the log message handler to the logger
131+
handler = logging.FileHandler(LOG_FILENAME)
132+
my_logger.addHandler(handler)
133+
134+
max_memory = 1
135+
pipe = pe.Workflow(name='pipe')
136+
n1 = pe.Node(interface=TestInterfaceSingleNode(), name='n1')
137+
n2 = pe.Node(interface=TestInterfaceSingleNode(), name='n2')
138+
n3 = pe.Node(interface=TestInterfaceSingleNode(), name='n3')
139+
n4 = pe.Node(interface=TestInterfaceSingleNode(), name='n4')
140+
141+
n1.interface.estimated_memory_gb = 1
142+
n2.interface.estimated_memory_gb = 1
143+
n3.interface.estimated_memory_gb = 1
144+
n4.interface.estimated_memory_gb = 1
145+
146+
pipe.connect(n1, 'output1', n2, 'input1')
147+
pipe.connect(n1, 'output1', n3, 'input1')
148+
pipe.connect(n2, 'output1', n4, 'input1')
149+
pipe.connect(n3, 'output1', n4, 'input2')
150+
n1.inputs.input1 = 1
151+
152+
pipe.run(plugin='MultiProc',
153+
plugin_args={'memory': max_memory,
154+
'status_callback': log_nodes_cb})
155+
156+
157+
nodes = draw_gantt_chart.log_to_dict(LOG_FILENAME)
158+
last_node = nodes[-1]
159+
#usage in every second
160+
memory, threads = find_metrics(nodes, last_node)
161+
162+
result = True
163+
for m in memory:
164+
if m > max_memory:
165+
result = False
166+
break
167+
168+
yield assert_equal, result, True
169+
170+
max_threads = cpu_count()
171+
172+
result = True
173+
for t in threads:
174+
if t > max_threads:
175+
result = False
176+
break
177+
178+
yield assert_equal, result, True,\
179+
"using more threads than system has (threads is not specified by user)"
180+
181+
os.remove(LOG_FILENAME)
182+
183+
184184
def test_do_not_use_more_threads_then_specified():
185185
LOG_FILENAME = 'callback.log'
186186
my_logger = logging.getLogger('callback')

0 commit comments

Comments
 (0)