@@ -34,27 +34,27 @@ def _list_outputs(self):
3434 return outputs
3535
3636
37- def test_run_multiproc ():
38- cur_dir = os .getcwd ()
39- temp_dir = mkdtemp (prefix = 'test_engine_' )
40- os .chdir (temp_dir )
41-
42- pipe = pe .Workflow (name = 'pipe' )
43- mod1 = pe .Node (interface = TestInterface (), name = 'mod1' )
44- mod2 = pe .MapNode (interface = TestInterface (),
45- iterfield = ['input1' ],
46- name = 'mod2' )
47- pipe .connect ([(mod1 , mod2 , [('output1' , 'input1' )])])
48- pipe .base_dir = os .getcwd ()
49- mod1 .inputs .input1 = 1
50- pipe .config ['execution' ]['poll_sleep_duration' ] = 2
51- execgraph = pipe .run (plugin = "MultiProc" )
52- names = ['.' .join ((node ._hierarchy , node .name )) for node in execgraph .nodes ()]
53- node = execgraph .nodes ()[names .index ('pipe.mod1' )]
54- result = node .get_output ('output1' )
55- yield assert_equal , result , [1 , 1 ]
56- os .chdir (cur_dir )
57- rmtree (temp_dir )
37+ # def test_run_multiproc():
38+ # cur_dir = os.getcwd()
39+ # temp_dir = mkdtemp(prefix='test_engine_')
40+ # os.chdir(temp_dir)
41+ #
42+ # pipe = pe.Workflow(name='pipe')
43+ # mod1 = pe.Node(interface=TestInterface(), name='mod1')
44+ # mod2 = pe.MapNode(interface=TestInterface(),
45+ # iterfield=['input1'],
46+ # name='mod2')
47+ # pipe.connect([(mod1, mod2, [('output1', 'input1')])])
48+ # pipe.base_dir = os.getcwd()
49+ # mod1.inputs.input1 = 1
50+ # pipe.config['execution']['poll_sleep_duration'] = 2
51+ # execgraph = pipe.run(plugin="MultiProc")
52+ # names = ['.'.join((node._hierarchy, node.name)) for node in execgraph.nodes()]
53+ # node = execgraph.nodes()[names.index('pipe.mod1')]
54+ # result = node.get_output('output1')
55+ # yield assert_equal, result, [1, 1]
56+ # os.chdir(cur_dir)
57+ # rmtree(temp_dir)
5858
5959
6060class InputSpecSingleNode (nib .TraitedSpec ):
@@ -122,115 +122,115 @@ 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-
184- def test_do_not_use_more_threads_then_specified ():
185- LOG_FILENAME = 'callback.log'
186- my_logger = logging .getLogger ('callback' )
187- my_logger .setLevel (logging .DEBUG )
188-
189- # Add the log message handler to the logger
190- handler = logging .FileHandler (LOG_FILENAME )
191- my_logger .addHandler (handler )
192-
193- max_threads = 10
194- pipe = pe .Workflow (name = 'pipe' )
195- n1 = pe .Node (interface = TestInterfaceSingleNode (), name = 'n1' )
196- n2 = pe .Node (interface = TestInterfaceSingleNode (), name = 'n2' )
197- n3 = pe .Node (interface = TestInterfaceSingleNode (), name = 'n3' )
198- n4 = pe .Node (interface = TestInterfaceSingleNode (), name = 'n4' )
199-
200- n1 .interface .num_threads = 1
201- n2 .interface .num_threads = 1
202- n3 .interface .num_threads = 10
203- n4 .interface .num_threads = 1
204-
205- pipe .connect (n1 , 'output1' , n2 , 'input1' )
206- pipe .connect (n1 , 'output1' , n3 , 'input1' )
207- pipe .connect (n2 , 'output1' , n4 , 'input1' )
208- pipe .connect (n3 , 'output1' , n4 , 'input2' )
209- n1 .inputs .input1 = 10
210- pipe .config ['execution' ]['poll_sleep_duration' ] = 1
211- pipe .run (plugin = 'MultiProc' , plugin_args = {'n_procs' : max_threads ,
212- 'status_callback' : log_nodes_cb })
213-
214- nodes = draw_gantt_chart .log_to_dict (LOG_FILENAME )
215- last_node = nodes [- 1 ]
216- #usage in every second
217- memory , threads = find_metrics (nodes , last_node )
218-
219- result = True
220- for t in threads :
221- if t > max_threads :
222- result = False
223- break
224-
225- yield assert_equal , result , True , "using more threads than specified"
226-
227- max_memory = get_system_total_memory_gb ()
228- result = True
229- for m in memory :
230- if m > max_memory :
231- result = False
232- break
233- yield assert_equal , result , True ,\
234- "using more memory than system has (memory is not specified by user)"
235-
236- os .remove (LOG_FILENAME )
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+ #
184+ # def test_do_not_use_more_threads_then_specified():
185+ # LOG_FILENAME = 'callback.log'
186+ # my_logger = logging.getLogger('callback')
187+ # my_logger.setLevel(logging.DEBUG)
188+ #
189+ # # Add the log message handler to the logger
190+ # handler = logging.FileHandler(LOG_FILENAME)
191+ # my_logger.addHandler(handler)
192+ #
193+ # max_threads = 10
194+ # pipe = pe.Workflow(name='pipe')
195+ # n1 = pe.Node(interface=TestInterfaceSingleNode(), name='n1')
196+ # n2 = pe.Node(interface=TestInterfaceSingleNode(), name='n2')
197+ # n3 = pe.Node(interface=TestInterfaceSingleNode(), name='n3')
198+ # n4 = pe.Node(interface=TestInterfaceSingleNode(), name='n4')
199+ #
200+ # n1.interface.num_threads = 1
201+ # n2.interface.num_threads = 1
202+ # n3.interface.num_threads = 10
203+ # n4.interface.num_threads = 1
204+ #
205+ # pipe.connect(n1, 'output1', n2, 'input1')
206+ # pipe.connect(n1, 'output1', n3, 'input1')
207+ # pipe.connect(n2, 'output1', n4, 'input1')
208+ # pipe.connect(n3, 'output1', n4, 'input2')
209+ # n1.inputs.input1 = 10
210+ # pipe.config['execution']['poll_sleep_duration'] = 1
211+ # pipe.run(plugin='MultiProc', plugin_args={'n_procs': max_threads,
212+ # 'status_callback': log_nodes_cb})
213+ #
214+ # nodes = draw_gantt_chart.log_to_dict(LOG_FILENAME)
215+ # last_node = nodes[-1]
216+ # #usage in every second
217+ # memory, threads = find_metrics(nodes, last_node)
218+ #
219+ # result = True
220+ # for t in threads:
221+ # if t > max_threads:
222+ # result = False
223+ # break
224+ #
225+ # yield assert_equal, result, True, "using more threads than specified"
226+ #
227+ # max_memory = get_system_total_memory_gb()
228+ # result = True
229+ # for m in memory:
230+ # if m > max_memory:
231+ # result = False
232+ # break
233+ # yield assert_equal, result, True,\
234+ # "using more memory than system has (memory is not specified by user)"
235+ #
236+ # os.remove(LOG_FILENAME)
0 commit comments