Salome HOME
merge V9_dev
[modules/yacs.git] / src / yacsloader_swig / Test / testHPDecorator.py
1 # Copyright (C) 2006-2016  CEA/DEN, EDF R&D
2 #
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19
20 import pilot
21 import SALOMERuntime
22 import unittest
23
24 class TestHPDecortator(unittest.TestCase):
25     def test0(self):
26         """ First test coming from the big boss."""
27         SALOMERuntime.RuntimeSALOME.setRuntime()
28         r=SALOMERuntime.getSALOMERuntime()
29         pg=pilot.PlayGround()
30         pg.loadFromKernelCatalog()
31         assert(len(pg.getData())!=0)
32         p=r.createProc("p0")
33         td=p.createType("double","double")
34         tdd=p.createSequenceTc("seqdouble","seqdouble",td)
35         hp1=p.createContainer("HP1","HPSalome")
36         hp4=p.createContainer("HP4","HPSalome")
37         #
38         n0=r.createScriptNode("Salome","n0")
39         n0.setExecutionMode("remote")
40         out0_0=n0.edAddOutputPort("o1",tdd)
41         n0.setScript("""o1=[float(i)+0.1 for i in range(1000)]""")
42         n0.setContainer(hp4)
43         p.edAddChild(n0)
44         #
45         n1_0=r.createForEachLoop("n1_0",td)
46         p.edAddChild(n1_0)
47         p.edAddCFLink(n0,n1_0)
48         p.edAddLink(out0_0,n1_0.edGetSeqOfSamplesPort())
49         ##
50         n1_0_sc=r.createScriptNode("Salome","n1_0_sc")
51         n1_0.edAddChild(n1_0_sc)
52         n1_0_sc.setExecutionMode("remote")
53         n1_0_sc.setScript("""2*i1""")
54         i1_0_sc=n1_0_sc.edAddInputPort("i1",td)
55         p.edAddLink(n1_0.edGetSamplePort(),i1_0_sc)
56         n1_0_sc.setContainer(hp4)
57         ##
58         #
59         n1_1=r.createForEachLoop("n1_1",td)
60         p.edAddChild(n1_1)
61         p.edAddCFLink(n0,n1_1)
62         p.edAddLink(out0_0,n1_1.edGetSeqOfSamplesPort())
63         ##
64         n1_1_sc=r.createScriptNode("Salome","n1_1_sc")
65         n1_1.edAddChild(n1_1_sc)
66         n1_1_sc.setExecutionMode("remote")
67         n1_1_sc.setScript("""3*i1""")
68         n1_1.setWeight(4.)
69         i1_1_sc=n1_1_sc.edAddInputPort("i1",td)
70         p.edAddLink(n1_1.edGetSamplePort(),i1_1_sc)
71         n1_1_sc.setContainer(hp1)
72         ##
73         hp1.setProperty("nb_proc_per_node","1")
74         hp4.setProperty("nb_proc_per_node","4")
75         pg.setData([("m0",8),("m1",8),("m2",8),("m3",8)]) # virtual machine with 32 cores spread over 4 nodes
76         assert(n1_0.getWeight().getSimpleLoopWeight()==-1.)
77         assert(n1_1.getWeight().getSimpleLoopWeight()==4.)
78         p.fitToPlayGround(pg)########### ZE CALL
79         fyto=pilot.ForTestOmlyHPContCls()
80         assert(hp4.getSizeOfPool()==8)# 32/4
81         n1_0_sc.getContainer().forYourTestsOnly(fyto)
82         assert(fyto.getContainerType()=="HPContainerShared")
83         pd=fyto.getPD()
84         assert(isinstance(pd,pilot.ContigPartDefinition))
85         assert(pd.getStart()==0 and pd.getStop()==16)
86         assert(fyto.getIDS()==(0,1,2,3))
87         #
88         assert(hp1.getSizeOfPool()==32)# 32/1
89         fyto=pilot.ForTestOmlyHPContCls()
90         n1_1_sc.getContainer().forYourTestsOnly(fyto)
91         assert(fyto.getContainerType()=="HPContainerShared")
92         pd=fyto.getPD()
93         assert(isinstance(pd,pilot.ContigPartDefinition))
94         assert(pd.getStart()==16 and pd.getStop()==32)
95         assert(fyto.getIDS()==(16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31))
96         assert(n1_0.edGetNbOfBranchesPort().getPyObj()==4)
97         assert(n1_1.edGetNbOfBranchesPort().getPyObj()==16)
98         #
99         fyto=pilot.ForTestOmlyHPContCls()
100         n0.getContainer().forYourTestsOnly(fyto)
101         assert(fyto.getContainerType()=="HPContainerShared")
102         pd=fyto.getPD()
103         assert(isinstance(pd,pilot.AllPartDefinition))
104         assert(list(fyto.getIDS())==list(range(8)))
105         #############################
106         #  Change weight of ForEach #
107         #############################
108         n1_0.setWeight(1)
109         p.fitToPlayGround(pg)########### ZE CALL
110         assert(hp4.getSizeOfPool()==8)# 32/4
111         n1_0_sc.getContainer().forYourTestsOnly(fyto)
112         assert(fyto.getContainerType()=="HPContainerShared")
113         pd=fyto.getPD()
114         assert(isinstance(pd,pilot.ContigPartDefinition))
115         assert(pd.getStart()==0 and pd.getStop()==16)
116         assert(fyto.getIDS()==(0,1,2,3))
117         assert(hp1.getSizeOfPool()==32)# 32/1
118         fyto=pilot.ForTestOmlyHPContCls()
119         n1_1_sc.getContainer().forYourTestsOnly(fyto)
120         assert(fyto.getContainerType()=="HPContainerShared")
121         pd=fyto.getPD()
122         assert(isinstance(pd,pilot.ContigPartDefinition))
123         assert(pd.getStart()==16 and pd.getStop()==32)
124         assert(fyto.getIDS()==(16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31))
125         assert(n1_0.edGetNbOfBranchesPort().getPyObj()==4)
126         assert(n1_1.edGetNbOfBranchesPort().getPyObj()==16)
127         #
128         fyto=pilot.ForTestOmlyHPContCls()
129         n0.getContainer().forYourTestsOnly(fyto)
130         assert(fyto.getContainerType()=="HPContainerShared")
131         pd=fyto.getPD()
132         assert(isinstance(pd,pilot.AllPartDefinition))
133         assert(list(fyto.getIDS())==list(range(8)))
134         pass
135
136     def test1(self):
137         """ Second test as test0 + script node in // with 2 FE"""
138         SALOMERuntime.RuntimeSALOME.setRuntime()
139         r=SALOMERuntime.getSALOMERuntime()
140         pg=pilot.PlayGround()
141         pg.loadFromKernelCatalog()
142         assert(len(pg.getData())!=0)
143         p=r.createProc("p0")
144         td=p.createType("double","double")
145         tdd=p.createSequenceTc("seqdouble","seqdouble",td)
146         hp1=p.createContainer("HP1","HPSalome")
147         hp4=p.createContainer("HP4","HPSalome")
148         #
149         n0=r.createScriptNode("Salome","n0")
150         n0.setExecutionMode("remote")
151         out0_0=n0.edAddOutputPort("o1",tdd)
152         n0.setScript("""o1=[float(i)+0.1 for i in range(1000)]""")
153         n0.setContainer(hp4)
154         p.edAddChild(n0)
155         #
156         n1_0=r.createForEachLoop("n1_0",td)
157         p.edAddChild(n1_0)
158         p.edAddCFLink(n0,n1_0)
159         p.edAddLink(out0_0,n1_0.edGetSeqOfSamplesPort())
160         n1_0.setWeight(1.)
161         ##
162         n1_0_sc=r.createScriptNode("Salome","n1_0_sc")
163         n1_0.edAddChild(n1_0_sc)
164         n1_0_sc.setExecutionMode("remote")
165         n1_0_sc.setScript("""2*i1""")
166         i1_0_sc=n1_0_sc.edAddInputPort("i1",td)
167         p.edAddLink(n1_0.edGetSamplePort(),i1_0_sc)
168         n1_0_sc.setContainer(hp4)
169         ##
170         #
171         n1_1=r.createForEachLoop("n1_1",td)
172         p.edAddChild(n1_1)
173         p.edAddCFLink(n0,n1_1)
174         p.edAddLink(out0_0,n1_1.edGetSeqOfSamplesPort())
175         n1_1.setWeight(4.)
176         ##
177         n1_1_sc=r.createScriptNode("Salome","n1_1_sc")
178         n1_1.edAddChild(n1_1_sc)
179         n1_1_sc.setExecutionMode("remote")
180         n1_1_sc.setScript("""3*i1""")
181         i1_1_sc=n1_1_sc.edAddInputPort("i1",td)
182         p.edAddLink(n1_1.edGetSamplePort(),i1_1_sc)
183         n1_1_sc.setContainer(hp1)
184         #
185         n1_2=r.createScriptNode("Salome","n1_2")
186         p.edAddChild(n1_2)
187         n1_2.setExecutionMode("remote")
188         n1_2.setContainer(hp4)
189         n1_2.setScript("""my_container""")
190         p.edAddCFLink(n0,n1_2)
191         ##
192         hp1.setProperty("nb_proc_per_node","1")
193         hp4.setProperty("nb_proc_per_node","4")
194         pg.setData([("m0",8),("m1",8),("m2",8),("m3",8),("m4",4)]) # virtual machine with 32 cores spread over 4 nodes
195         assert(n1_0.getWeight().getSimpleLoopWeight()==1.)
196         assert(n1_1.getWeight().getSimpleLoopWeight()==4.)
197         p.fitToPlayGround(pg)########### ZE CALL
198         assert(hp4.getSizeOfPool()==9)# 36/4
199         fyto=pilot.ForTestOmlyHPContCls()
200         n1_0_sc.getContainer().forYourTestsOnly(fyto)
201         assert(fyto.getContainerType()=="HPContainerShared")
202         pd=fyto.getPD()
203         assert(isinstance(pd,pilot.ContigPartDefinition))
204         assert(pd.getStart()==0 and pd.getStop()==16)
205         assert(fyto.getIDS()==(0,1,2,3))
206         #
207         assert(hp1.getSizeOfPool()==36)# 36/1
208         fyto=pilot.ForTestOmlyHPContCls()
209         n1_1_sc.getContainer().forYourTestsOnly(fyto)
210         assert(fyto.getContainerType()=="HPContainerShared")
211         pd=fyto.getPD()
212         assert(isinstance(pd,pilot.ContigPartDefinition))
213         assert(pd.getStart()==20 and pd.getStop()==36)
214         assert(fyto.getIDS()==(20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35))
215         assert(n1_0.edGetNbOfBranchesPort().getPyObj()==4)
216         assert(n1_1.edGetNbOfBranchesPort().getPyObj()==16)
217         #
218         fyto=pilot.ForTestOmlyHPContCls()
219         n0.getContainer().forYourTestsOnly(fyto)
220         assert(fyto.getContainerType()=="HPContainerShared")
221         pd=fyto.getPD()
222         assert(isinstance(pd,pilot.AllPartDefinition))
223         assert(list(fyto.getIDS())==list(range(9)))
224         fyto=pilot.ForTestOmlyHPContCls()
225         n1_2.getContainer().forYourTestsOnly(fyto)
226         assert(fyto.getContainerType()=="HPContainerShared")
227         pd=fyto.getPD()
228         assert(isinstance(pd,pilot.ContigPartDefinition))
229         assert(list(fyto.getIDS())==[4])
230         pass
231
232     @unittest.skip("requires 2 machines in catalog")
233     def test2(self):
234         """ This test is desactivated because it requires multi nodes. To be moved at the right place to support this.
235         This test is not launched here because it requires 2 machines in catalog"""
236         m1="dsp0764200"
237         m2="dsp0764412"
238         SALOMERuntime.RuntimeSALOME.setRuntime()
239         r=SALOMERuntime.getSALOMERuntime()
240         pg=pilot.PlayGround()
241         pg.loadFromKernelCatalog()
242         assert(len(pg.getData())!=0)
243         p=r.createProc("p0")
244         td=p.createType("double","double")
245         tdd=p.createSequenceTc("seqdouble","seqdouble",td)
246         hp1=p.createContainer("HP1","HPSalome")
247         #
248         n0=r.createScriptNode("Salome","n0")
249         n0.setExecutionMode("remote")
250         out0_0=n0.edAddOutputPort("o1",tdd)
251         n0.setScript("""o1=[float(i)+0.1 for i in range(1000)]""")
252         n0.setContainer(hp1)
253         p.edAddChild(n0)
254         ##
255         n1_0_sc=r.createScriptNode("Salome","n1_0_sc")
256         p.edAddChild(n1_0_sc)
257         p.edAddCFLink(n0,n1_0_sc)
258         n1_0_sc.setExecutionMode("remote")
259         n1_0_sc.setScript("""assert(my_container.getHostName()=="%s")"""%m1)
260         n1_0_sc.setContainer(hp1)
261         ##
262         n1_1_sc=r.createScriptNode("Salome","n1_1_sc")
263         p.edAddChild(n1_1_sc)
264         p.edAddCFLink(n0,n1_1_sc)
265         n1_1_sc.setExecutionMode("remote")
266         n1_1_sc.setScript("""assert(my_container.getHostName()=="%s")"""%m2)
267         n1_1_sc.setContainer(hp1)
268         ##
269         hp1.setProperty("nb_proc_per_node","1")
270         pg.setData([(m1,8),(m2,8)])
271         p.fitToPlayGround(pg)########### ZE CALL
272         assert(hp1.getSizeOfPool()==16)# 16/1
273         fyto=pilot.ForTestOmlyHPContCls()
274         n1_0_sc.getContainer().forYourTestsOnly(fyto)
275         assert(fyto.getContainerType()=="HPContainerShared")
276         pd=fyto.getPD()
277         assert(isinstance(pd,pilot.ContigPartDefinition))
278         assert(pd.getStart()==0 and pd.getStop()==8)
279         assert(fyto.getIDS()==(0,1,2,3,4,5,6,7))
280         #
281         fyto=pilot.ForTestOmlyHPContCls()
282         n1_1_sc.getContainer().forYourTestsOnly(fyto)
283         assert(fyto.getContainerType()=="HPContainerShared")
284         pd=fyto.getPD()
285         assert(isinstance(pd,pilot.ContigPartDefinition))
286         assert(pd.getStart()==8 and pd.getStop()==16)
287         assert(fyto.getIDS()==(8,9,10,11,12,13,14,15))
288         #
289         exe=pilot.ExecutorSwig()
290         assert(p.getState()==pilot.READY)
291         exe.RunW(p,0)
292         assert(p.getState()==pilot.DONE)
293         pass
294
295     def test3(self):
296         """ First test coming from the big boss."""
297         SALOMERuntime.RuntimeSALOME.setRuntime()
298         r=SALOMERuntime.getSALOMERuntime()
299         pg=pilot.PlayGround()
300         pg.loadFromKernelCatalog()
301         assert(len(pg.getData())!=0)
302         p=r.createProc("p0")
303         td=p.createType("double","double")
304         tdd=p.createSequenceTc("seqdouble","seqdouble",td)
305         hp1=r.createContainer("HPSalome") ; hp1.setName("HP1")
306         #
307         n0=r.createScriptNode("Salome","n0")
308         n0.setExecutionMode("local")
309         out0_0=n0.edAddOutputPort("o1",tdd)
310         n0.setScript("""o1=[float(i)+0.1 for i in range(1000)]""")
311         p.edAddChild(n0)
312         #
313         n1_0=r.createForEachLoop("n1_0",td)
314         n2_0=r.createForEachLoop("n2_0",td)
315         p.edAddChild(n1_0)
316         p.edAddChild(n2_0)
317         p.edAddCFLink(n0,n1_0)
318         p.edAddCFLink(n1_0,n2_0)
319         p.edAddLink(out0_0,n1_0.edGetSeqOfSamplesPort())
320         p.edAddLink(out0_0,n2_0.edGetSeqOfSamplesPort())
321         ##
322         n1_0_sc=r.createScriptNode("Salome","n1_0_sc")
323         n1_0.edAddChild(n1_0_sc)
324         n1_0_sc.setExecutionMode("remote")
325         n1_0_sc.setScript("""2*i1""")
326         i1_0_sc=n1_0_sc.edAddInputPort("i1",td)
327         p.edAddLink(n1_0.edGetSamplePort(),i1_0_sc)
328         n1_0_sc.setContainer(hp1)
329         ##
330         n2_0_sc=r.createScriptNode("Salome","n2_0_sc")
331         n2_0.edAddChild(n2_0_sc)
332         n2_0_sc.setExecutionMode("remote")
333         n2_0_sc.setScript("""2*i1""")
334         i2_0_sc=n2_0_sc.edAddInputPort("i1",td)
335         p.edAddLink(n2_0.edGetSamplePort(),i2_0_sc)
336         n2_0_sc.setContainer(hp1)
337         ##
338         hp1.setProperty("nb_proc_per_node","1")
339         pg.setData([("localhost",3)])
340         p.fitToPlayGround(pg)########### ZE CALL
341         assert(hp1.getSizeOfPool()==3)
342         fyto=pilot.ForTestOmlyHPContCls()
343         n1_0_sc.getContainer().forYourTestsOnly(fyto)
344         assert(fyto.getContainerType()=="HPContainerShared")
345         pd=fyto.getPD()
346         assert(isinstance(pd,pilot.AllPartDefinition))
347         assert(fyto.getIDS()==(0,1,2))
348         fyto=pilot.ForTestOmlyHPContCls()
349         n2_0_sc.getContainer().forYourTestsOnly(fyto)
350         assert(fyto.getContainerType()=="HPContainerShared")
351         pd=fyto.getPD()
352         assert(isinstance(pd,pilot.AllPartDefinition))
353         assert(fyto.getIDS()==(0,1,2))
354         assert(n1_0.edGetNbOfBranchesPort().getPyObj()==3)
355         assert(n2_0.edGetNbOfBranchesPort().getPyObj()==3)
356         #
357         exe=pilot.ExecutorSwig()
358         assert(p.getState()==pilot.READY)
359         exe.RunW(p,0)
360         assert(len(set(hp1.getKernelContainerNames()))==3)
361         pass
362     
363     def test4(self):
364         """ two branch whose on with one elementary node and on foreach"""
365         SALOMERuntime.RuntimeSALOME.setRuntime()
366         r=SALOMERuntime.getSALOMERuntime()
367         pg=pilot.PlayGround()
368         pg.loadFromKernelCatalog()
369         assert(len(pg.getData())!=0)
370         p=r.createProc("p0")
371         td=p.createType("double","double")
372         tdd=p.createSequenceTc("seqdouble","seqdouble",td)
373         hp1=p.createContainer("HP1","HPSalome")        
374         #
375         ##
376         n0=r.createScriptNode("Salome","n0")
377         n0.setExecutionMode("remote")
378         out0_0=n0.edAddOutputPort("o1",tdd)
379         n0.setScript("""o1=[float(i)+0.1 for i in range(1000)]""")
380         n0.setContainer(hp1)
381         p.edAddChild(n0)
382         #
383         b0 = r.createBloc("Bloc0")
384         p.edAddChild(b0)
385         p.edAddCFLink(n0,b0)
386         ##
387         n1_0=r.createForEachLoop("n1_0",td)
388         b0.edAddChild(n1_0)
389         p.edAddLink(out0_0,n1_0.edGetSeqOfSamplesPort())
390         n1_0.setWeight(10.)
391         ##
392         n1_0_sc=r.createScriptNode("Salome","n1_0_sc")
393         n1_0.edAddChild(n1_0_sc)
394         n1_0_sc.setExecutionMode("remote")
395         n1_0_sc.setScript("""2*i1""")
396         i1_0_sc=n1_0_sc.edAddInputPort("i1",td)
397         p.edAddLink(n1_0.edGetSamplePort(),i1_0_sc)
398         n1_0_sc.setContainer(hp1)
399         ##
400         n1_0_1=r.createScriptNode("Salome","n1_0_1")
401         n1_0_1.setExecutionMode("remote")
402         n1_0_1.setScript("""a=2""")
403         b0.edAddChild(n1_0_1)
404         p.edAddCFLink(n1_0,n1_0_1)
405         n1_0_1.setContainer(hp1)  
406         n1_0_1.setWeight(20.)        
407         ##
408         #
409         n1_1=r.createForEachLoop("n1_1",td)
410         p.edAddChild(n1_1)
411         p.edAddCFLink(n0,n1_1)
412         p.edAddLink(out0_0,n1_1.edGetSeqOfSamplesPort())
413         n1_1.setWeight(100.)
414         ##
415         n1_1_sc=r.createScriptNode("Salome","n1_1_sc")
416         n1_1.edAddChild(n1_1_sc)
417         n1_1_sc.setExecutionMode("remote")
418         n1_1_sc.setScript("""3*i1""")
419         i1_1_sc=n1_1_sc.edAddInputPort("i1",td)
420         p.edAddLink(n1_1.edGetSamplePort(),i1_1_sc)
421         n1_1_sc.setContainer(hp1)
422         
423         hp1.setProperty("nb_proc_per_node","1")
424         pg.setData([("m0",12)])
425         w=pilot.ComplexWeight()
426         b0.getWeightRegardingDPL(w)
427         assert(w.getElementaryWeight()==20.)
428         assert(w.calculateTotalLength(1)==30.)
429         assert(w.calculateTotalLength(2)==25.)
430         p.fitToPlayGround(pg)########### ZE CALL
431         assert(n1_0.edGetNbOfBranchesPort().getPyObj()==7)
432         assert(n1_1.edGetNbOfBranchesPort().getPyObj()==5)
433         #
434         fyto=pilot.ForTestOmlyHPContCls()
435         n1_0_sc.getContainer().forYourTestsOnly(fyto)
436         assert(fyto.getContainerType()=="HPContainerShared")
437         pd=fyto.getPD()
438         assert(isinstance(pd,pilot.ContigPartDefinition))
439         print (pd.getStart(),pd.getStop())
440         assert(pd.getStart()==0 and pd.getStop()==7)
441         
442         #########################
443         ## change HPcontainer
444         ## very important: if you change HPcontainer you have to reload the graph
445         #########################
446         p=r.createProc("p0")
447         n0=r.createScriptNode("Salome","n0")
448         n0.setExecutionMode("remote")
449         out0_0=n0.edAddOutputPort("o1",tdd)
450         n0.setScript("""o1=[float(i)+0.1 for i in range(1000)]""")
451         n0.setContainer(hp1)
452         p.edAddChild(n0)
453         #
454         b0 = r.createBloc("Bloc0")
455         p.edAddChild(b0)
456         p.edAddCFLink(n0,b0)
457         ##
458         n1_0=r.createForEachLoop("n1_0",td)
459         b0.edAddChild(n1_0)
460         p.edAddLink(out0_0,n1_0.edGetSeqOfSamplesPort())
461         ##
462         n1_0_sc=r.createScriptNode("Salome","n1_0_sc")
463         n1_0.edAddChild(n1_0_sc)
464         n1_0_sc.setExecutionMode("remote")
465         n1_0_sc.setScript("""2*i1""")
466         i1_0_sc=n1_0_sc.edAddInputPort("i1",td)
467         p.edAddLink(n1_0.edGetSamplePort(),i1_0_sc)
468         n1_0_sc.setContainer(hp1)
469         ##
470         n1_0_1=r.createForEachLoop("n1_0_1",td)
471         b0.edAddChild(n1_0_1)
472         p.edAddLink(out0_0,n1_0_1.edGetSeqOfSamplesPort())
473         p.edAddCFLink(n1_0,n1_0_1)
474         ##
475         n1_0_1sc=r.createScriptNode("Salome","n1_0_1sc")
476         n1_0_1.edAddChild(n1_0_1sc)
477         n1_0_1sc.setExecutionMode("remote")
478         n1_0_1sc.setScript("""a=2""")
479         i1_0_1sc=n1_0_1sc.edAddInputPort("i1",td)
480         p.edAddLink(n1_0_1.edGetSamplePort(),i1_0_1sc)
481         ##
482         #
483         n1_1=r.createForEachLoop("n1_1",td)
484         p.edAddChild(n1_1)
485         p.edAddCFLink(n0,n1_1)
486         p.edAddLink(out0_0,n1_1.edGetSeqOfSamplesPort())
487         ##
488         n1_1_sc=r.createScriptNode("Salome","n1_1_sc")
489         n1_1.edAddChild(n1_1_sc)
490         n1_1_sc.setExecutionMode("remote")
491         n1_1_sc.setScript("""3*i1""")
492         i1_1_sc=n1_1_sc.edAddInputPort("i1",td)
493         p.edAddLink(n1_1.edGetSamplePort(),i1_1_sc)
494         n1_1_sc.setContainer(hp1)
495         ##
496         ##
497         hp4=p.createContainer("HP4","HPSalome")
498         hp4.setProperty("nb_proc_per_node","4")
499         n1_0.setWeight(40.)
500         n1_0_1.setWeight(20)
501         n1_1.setWeight(100.)
502         n1_0_1sc.setContainer(hp4)
503         w=pilot.ComplexWeight()
504         b0.getWeightRegardingDPL(w)
505         assert(w.getElementaryWeight()==-1.)
506         assert(w.calculateTotalLength(4)==30.)
507         assert(w.calculateTotalLength(8)==15.)
508         pg.setData([("m0",120)])
509         p.fitToPlayGround(pg)########### ZE CALL
510         assert(n1_0.edGetNbOfBranchesPort().getPyObj()==64)
511         assert(n1_0_1.edGetNbOfBranchesPort().getPyObj()==16)
512         assert(n1_1.edGetNbOfBranchesPort().getPyObj()==56)
513         #
514         fyto=pilot.ForTestOmlyHPContCls()
515         n1_0_sc.getContainer().forYourTestsOnly(fyto)
516         assert(fyto.getContainerType()=="HPContainerShared")
517         pd=fyto.getPD()
518         assert(isinstance(pd,pilot.ContigPartDefinition))
519         assert(pd.getStart()==0 and pd.getStop()==64)
520         pass
521
522     pass
523
524 if __name__ == '__main__':
525     unittest.main()