Salome HOME
Correction of bug for HPContainers shared by different scripts.
[modules/yacs.git] / src / yacsloader_swig / Test / testSaveLoadRun.py
1 # Copyright (C) 2006-2014  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 unittest
21 import pilot
22 import SALOMERuntime
23 import loader
24
25 import datetime
26
27 class TestSaveLoadRun(unittest.TestCase):
28   def setUp(self):
29     SALOMERuntime.RuntimeSALOME.setRuntime()
30     self.r=SALOMERuntime.getSALOMERuntime()
31     pass
32
33   def test0(self):
34     """First test of HP Container no loop here only the 3 sorts of python nodes (the Distributed is it still used and useful ?) """
35     fname="TestSaveLoadRun0.xml"
36     nbOfNodes=8
37     sqrtOfNumberOfTurn=1000 # 3000 -> 3.2s/Node, 1000 -> 0.1s/Node
38     l=loader.YACSLoader()
39     p=self.r.createProc("prTest0")
40     td=p.createType("double","double")
41     ti=p.createType("int","int")
42     cont=p.createContainer("gg","HPSalome")
43     cont.setSizeOfPool(4)
44     cont.setProperty("name","localhost")
45     cont.setProperty("hostname","localhost")
46     script0="""
47 def ff(nb,dbg):
48     from math import cos
49     import datetime
50     
51     ref=datetime.datetime.now()
52     t=0. ; pas=1./float(nb)
53     for i in xrange(nb):
54         for j in xrange(nb):
55             x=j*pas
56             t+=1.+cos(1.*(x*3.14159))
57             pass
58         pass
59     print "coucou from script0-%i  -> %s"%(dbg,str(datetime.datetime.now()-ref))
60     return t
61 """
62     script1="""
63 from math import cos
64 import datetime
65 ref=datetime.datetime.now()
66 o2=0. ; pas=1./float(i1)
67 for i in xrange(i1):
68   for j in xrange(i1):
69     x=j*pas
70     o2+=1.+cos(1.*(x*3.14159))
71     pass
72 print "coucou from script1-%i  -> %s"%(dbg,str(datetime.datetime.now()-ref))
73 """
74     for i in xrange(nbOfNodes):
75       node0=self.r.createFuncNode("DistPython","node%i"%(i))
76       p.edAddChild(node0)
77       node0.setFname("ff")
78       node0.setContainer(cont)
79       node0.setScript(script0)
80       nb=node0.edAddInputPort("nb",ti) ; nb.edInitInt(sqrtOfNumberOfTurn)
81       dbg=node0.edAddInputPort("dbg",ti) ; dbg.edInitInt(i+1)
82       out0=node0.edAddOutputPort("s",td)
83       #
84       nodeMiddle=self.r.createFuncNode("Salome","node%i_1"%(i))
85       p.edAddChild(nodeMiddle)
86       p.edAddCFLink(node0,nodeMiddle)
87       nodeMiddle.setFname("ff")
88       nodeMiddle.setContainer(cont)
89       nodeMiddle.setScript(script0)
90       nb=nodeMiddle.edAddInputPort("nb",ti) ; nb.edInitInt(sqrtOfNumberOfTurn)
91       dbg=nodeMiddle.edAddInputPort("dbg",ti) ; dbg.edInitInt(i+1)
92       out0=nodeMiddle.edAddOutputPort("s",td)
93       nodeMiddle.setExecutionMode("remote")
94       #
95       nodeEnd=self.r.createScriptNode("Salome","node%i_2"%(i+1))
96       p.edAddChild(nodeEnd)
97       p.edAddCFLink(nodeMiddle,nodeEnd)
98       nodeEnd.setContainer(cont)
99       nodeEnd.setScript(script1)
100       i1=nodeEnd.edAddInputPort("i1",ti) ; i1.edInitInt(sqrtOfNumberOfTurn)
101       dbg=nodeEnd.edAddInputPort("dbg",ti) ; dbg.edInitInt(i)
102       o2=nodeEnd.edAddOutputPort("o2",td)
103       nodeEnd.setExecutionMode("remote")
104       pass
105     p.saveSchema(fname)
106     p=l.load(fname)
107     ex=pilot.ExecutorSwig()
108     self.assertEqual(p.getState(),pilot.READY)
109     st=datetime.datetime.now()
110     # 1st exec
111     ex.RunW(p,0)
112     print "Time spend of test0 to run 1st %s"%(str(datetime.datetime.now()-st))
113     self.assertEqual(p.getState(),pilot.DONE)
114     # 2nd exec using the same already launched remote python interpreters
115     st=datetime.datetime.now()
116     ex.RunW(p,0)
117     print "Time spend of test0 to run 2nd %s"%(str(datetime.datetime.now()-st))
118     self.assertEqual(p.getState(),pilot.DONE)
119     # 3rd exec using the same already launched remote python interpreters
120     st=datetime.datetime.now()
121     ex.RunW(p,0)
122     print "Time spend of test0 to run 3rd %s"%(str(datetime.datetime.now()-st))
123     self.assertEqual(p.getState(),pilot.DONE)
124     pass
125
126   def test1(self):
127     """ HP Container again like test0 but the initialization key of HPContainer is used here."""
128     fname="TestSaveLoadRun1.xml"
129     nbOfNodes=8
130     sqrtOfNumberOfTurn=1000 # 3000 -> 3.2s/Node, 1000 -> 0.1s/Node
131     l=loader.YACSLoader()
132     p=self.r.createProc("prTest1")
133     td=p.createType("double","double")
134     ti=p.createType("int","int")
135     cont=p.createContainer("gg","HPSalome")
136     cont.setSizeOfPool(4)
137     cont.setProperty("InitializeScriptKey","aa=123.456")
138     cont.setProperty("name","localhost")
139     cont.setProperty("hostname","localhost")
140     script0="""
141 def ff(nb,dbg):
142     from math import cos
143     import datetime
144     
145     ref=datetime.datetime.now()
146     t=0. ; pas=1./float(nb)
147     for i in xrange(nb):
148         for j in xrange(nb):
149             x=j*pas
150             t+=1.+cos(1.*(x*3.14159))
151             pass
152         pass
153     print "coucou from script0-%i  -> %s"%(dbg,str(datetime.datetime.now()-ref))
154     return t
155 """
156     # here in script1 aa is refered ! aa will exist thanks to HPCont Init Script
157     script1="""
158 from math import cos
159 import datetime
160 ref=datetime.datetime.now()
161 o2=0. ; pas=1./float(i1)
162 for i in xrange(i1):
163   for j in xrange(i1):
164     x=j*pas
165     o2+=1.+cos(1.*(x*3.14159))
166     pass
167 print "coucou %lf from script1-%i  -> %s"%(aa,dbg,str(datetime.datetime.now()-ref))
168 aa+=1.
169 """
170     #
171     for i in xrange(nbOfNodes):
172       nodeMiddle=self.r.createFuncNode("Salome","node%i_1"%(i)) # PyFuncNode remote
173       p.edAddChild(nodeMiddle)
174       nodeMiddle.setFname("ff")
175       nodeMiddle.setContainer(cont)
176       nodeMiddle.setScript(script0)
177       nb=nodeMiddle.edAddInputPort("nb",ti) ; nb.edInitInt(sqrtOfNumberOfTurn)
178       dbg=nodeMiddle.edAddInputPort("dbg",ti) ; dbg.edInitInt(i+1)
179       out0=nodeMiddle.edAddOutputPort("s",td)
180       nodeMiddle.setExecutionMode("remote")
181       #
182       nodeEnd=self.r.createScriptNode("Salome","node%i_2"%(i+1)) # PythonNode remote
183       p.edAddChild(nodeEnd)
184       p.edAddCFLink(nodeMiddle,nodeEnd)
185       nodeEnd.setContainer(cont)
186       nodeEnd.setScript(script1)
187       i1=nodeEnd.edAddInputPort("i1",ti) ; i1.edInitInt(sqrtOfNumberOfTurn)
188       dbg=nodeEnd.edAddInputPort("dbg",ti) ; dbg.edInitInt(i)
189       o2=nodeEnd.edAddOutputPort("o2",td)
190       nodeEnd.setExecutionMode("remote")
191       pass
192     #
193     p.saveSchema(fname)
194     p=l.load(fname)
195     self.assertEqual(p.edGetDirectDescendants()[0].getContainer().getProperty("InitializeScriptKey"),"aa=123.456")
196     # 1st exec
197     ex=pilot.ExecutorSwig()
198     self.assertEqual(p.getState(),pilot.READY)
199     st=datetime.datetime.now()
200     ex.RunW(p,0)
201     print "Time spend of test1 to 1st run %s"%(str(datetime.datetime.now()-st))
202     self.assertEqual(p.getState(),pilot.DONE)
203     # 2nd exec
204     st=datetime.datetime.now()
205     ex.RunW(p,0)
206     print "Time spend of test1 to 2nd run %s"%(str(datetime.datetime.now()-st))
207     self.assertEqual(p.getState(),pilot.DONE)
208     # 3rd exec
209     st=datetime.datetime.now()
210     ex.RunW(p,0)
211     print "Time spend of test1 to 3rd run %s"%(str(datetime.datetime.now()-st))
212     self.assertEqual(p.getState(),pilot.DONE)
213     pass
214
215   def test2(self):
216     """ Test on HP Containers in foreach context."""
217     script0="""def ff():
218     global aa
219     print "%%lf - %%s"%%(aa,str(my_container))
220     return 16*[%i],0
221 """
222     script1="""from math import cos
223 import datetime
224 ref=datetime.datetime.now()
225 o2=0. ; pas=1./float(i1)
226 for i in xrange(i1):
227   for j in xrange(i1):
228     x=j*pas
229     o2+=1.+cos(1.*(x*3.14159))
230     pass
231 print "coucou %lf from script  -> %s"%(aa,str(datetime.datetime.now()-ref))
232 aa+=1.
233 o3=0
234 """
235     script2="""o9=sum(i8)
236 """
237     fname="TestSaveLoadRun2.xml"
238     nbOfNodes=8
239     sqrtOfNumberOfTurn=1000 # 3000 -> 3.2s/Node, 1000 -> 0.1s/Node
240     l=loader.YACSLoader()
241     p=self.r.createProc("prTest1")
242     td=p.createType("double","double")
243     ti=p.createType("int","int")
244     tdi=p.createSequenceTc("seqint","seqint",ti)
245     tdd=p.createSequenceTc("seqdouble","seqdouble",td)
246     cont=p.createContainer("gg","HPSalome")
247     cont.setSizeOfPool(4)
248     cont.setProperty("InitializeScriptKey","aa=123.456")
249     cont.setProperty("name","localhost")
250     cont.setProperty("hostname","localhost")
251     #
252     node0=self.r.createFuncNode("Salome","PyFunction0") # PyFuncNode remote
253     p.edAddChild(node0)
254     node0.setFname("ff")
255     node0.setContainer(cont)
256     node0.setScript(script0%(sqrtOfNumberOfTurn))
257     out0_0=node0.edAddOutputPort("o1",tdi)
258     out1_0=node0.edAddOutputPort("o2",ti)
259     node0.setExecutionMode("remote")
260     #
261     node1=self.r.createForEachLoop("node1",ti)
262     p.edAddChild(node1)
263     p.edAddCFLink(node0,node1)
264     p.edAddLink(out0_0,node1.edGetSeqOfSamplesPort())
265     node1.edGetNbOfBranchesPort().edInitInt(8)
266     #
267     node2=self.r.createScriptNode("Salome","PyScript3")
268     node1.edAddChild(node2)
269     node2.setContainer(cont)
270     node2.setScript(script1)
271     i1=node2.edAddInputPort("i1",ti)
272     p.edAddLink(node1.edGetSamplePort(),i1)
273     out0_2=node2.edAddOutputPort("o2",td)
274     out1_2=node2.edAddOutputPort("o3",ti)
275     node2.setExecutionMode("remote")
276     #
277     node3=self.r.createScriptNode("Salome","PyScript7")
278     p.edAddChild(node3)
279     node3.setScript(script2)
280     p.edAddCFLink(node1,node3)
281     i8=node3.edAddInputPort("i8",tdd)
282     o9=node3.edAddOutputPort("o9",td)
283     p.edAddLink(out0_2,i8)
284     #
285     p.saveSchema(fname)
286     p=l.load(fname)
287     o9=p.getChildByName("PyScript7").getOutputPort("o9")
288     self.assertTrue(len(p.edGetDirectDescendants()[1].getChildByName("PyScript3").getContainer().getProperty("InitializeScriptKey"))!=0)
289     # 1st exec
290     refExpected=16016013.514623128
291     ex=pilot.ExecutorSwig()
292     self.assertEqual(p.getState(),pilot.READY)
293     st=datetime.datetime.now()
294     ex.RunW(p,0)
295     print "Time spend of test2 to 1st run %s"%(str(datetime.datetime.now()-st))
296     self.assertEqual(p.getState(),pilot.DONE)
297     self.assertAlmostEqual(refExpected,o9.getPyObj(),5)
298     # 2nd exec
299     st=datetime.datetime.now()
300     ex.RunW(p,0)
301     print "Time spend of test2 to 2nd run %s"%(str(datetime.datetime.now()-st))
302     self.assertEqual(p.getState(),pilot.DONE)
303     self.assertAlmostEqual(refExpected,o9.getPyObj(),5)
304     # 3rd exec
305     st=datetime.datetime.now()
306     ex.RunW(p,0)
307     print "Time spend of test2 to 3rd run %s"%(str(datetime.datetime.now()-st))
308     self.assertEqual(p.getState(),pilot.DONE)
309     self.assertAlmostEqual(refExpected,o9.getPyObj(),5)
310     pass
311
312   def test3(self):
313     """ Test that focuses on parallel load of containers."""
314     script0="""def ff():
315     global aa
316     print "%%lf - %%s"%%(aa,str(my_container))
317     return 100*[%i],0
318 """
319     script1="""from math import cos
320 import datetime
321 ref=datetime.datetime.now()
322 o2=0. ; pas=1./float(i1)
323 for i in xrange(i1):
324   for j in xrange(i1):
325     x=j*pas
326     o2+=1.+cos(1.*(x*3.14159))
327     pass
328 print "coucou %lf from script  -> %s"%(aa,str(datetime.datetime.now()-ref))
329 aa+=1.
330 o3=0
331 """
332     script2="""o9=sum(i8)
333 """
334     fname="TestSaveLoadRun3.xml"
335     nbOfNodes=8
336     sqrtOfNumberOfTurn=10
337     l=loader.YACSLoader()
338     p=self.r.createProc("prTest1")
339     td=p.createType("double","double")
340     ti=p.createType("int","int")
341     tdi=p.createSequenceTc("seqint","seqint",ti)
342     tdd=p.createSequenceTc("seqdouble","seqdouble",td)
343     cont=p.createContainer("gg","HPSalome")
344     cont.setSizeOfPool(8)
345     cont.setProperty("InitializeScriptKey","aa=123.456")
346     cont.setProperty("name","localhost")
347     cont.setProperty("hostname","localhost")
348     #
349     node0=self.r.createFuncNode("Salome","PyFunction0") # PyFuncNode remote
350     p.edAddChild(node0)
351     node0.setFname("ff")
352     node0.setContainer(cont)
353     node0.setScript(script0%(sqrtOfNumberOfTurn))
354     out0_0=node0.edAddOutputPort("o1",tdi)
355     out1_0=node0.edAddOutputPort("o2",ti)
356     node0.setExecutionMode("remote")
357     #
358     node1=self.r.createForEachLoop("node1",ti)
359     p.edAddChild(node1)
360     p.edAddCFLink(node0,node1)
361     p.edAddLink(out0_0,node1.edGetSeqOfSamplesPort())
362     node1.edGetNbOfBranchesPort().edInitInt(16)
363     #
364     node2=self.r.createScriptNode("Salome","PyScript3")
365     node1.edAddChild(node2)
366     node2.setContainer(cont)
367     node2.setScript(script1)
368     i1=node2.edAddInputPort("i1",ti)
369     p.edAddLink(node1.edGetSamplePort(),i1)
370     out0_2=node2.edAddOutputPort("o2",td)
371     out1_2=node2.edAddOutputPort("o3",ti)
372     node2.setExecutionMode("remote")
373     #
374     node3=self.r.createScriptNode("Salome","PyScript7")
375     p.edAddChild(node3)
376     node3.setScript(script2)
377     p.edAddCFLink(node1,node3)
378     i8=node3.edAddInputPort("i8",tdd)
379     o9=node3.edAddOutputPort("o9",td)
380     p.edAddLink(out0_2,i8)
381     #
382     p.saveSchema(fname)
383     p=l.load(fname)
384     o9=p.getChildByName("PyScript7").getOutputPort("o9")
385     self.assertTrue(len(p.edGetDirectDescendants()[1].getChildByName("PyScript3").getContainer().getProperty("InitializeScriptKey"))!=0)
386     # 1st exec
387     refExpected=11000.008377058712
388     ex=pilot.ExecutorSwig()
389     self.assertEqual(p.getState(),pilot.READY)
390     st=datetime.datetime.now()
391     ex.RunW(p,0)
392     print "Time spend of test3 to 1st run %s"%(str(datetime.datetime.now()-st))
393     self.assertEqual(p.getState(),pilot.DONE)
394     self.assertAlmostEqual(refExpected,o9.getPyObj(),5)
395     # 2nd exec
396     st=datetime.datetime.now()
397     ex.RunW(p,0)
398     print "Time spend of test3 to 2nd run %s"%(str(datetime.datetime.now()-st))
399     self.assertEqual(p.getState(),pilot.DONE)
400     self.assertAlmostEqual(refExpected,o9.getPyObj(),5)
401     # 3rd exec
402     st=datetime.datetime.now()
403     ex.RunW(p,0)
404     print "Time spend of test3 to 3rd run %s"%(str(datetime.datetime.now()-st))
405     self.assertEqual(p.getState(),pilot.DONE)
406     self.assertAlmostEqual(refExpected,o9.getPyObj(),5)
407     pass
408   
409   def test4(self):
410     """Non regression test of multi pyScriptNode, pyFuncNode sharing the same HPContainer instance."""
411     fname="TestSaveLoadRun4.xml"
412     script1="""nb=7
413 ii=0
414 o1=nb*[None]
415 for i in xrange(nb):
416     tmp=(i+10)*[None]
417     for j in xrange(i+10):
418         tmp[j]=ii
419         ii+=1
420         pass
421     o1[i]=tmp
422     pass
423 """
424     l=loader.YACSLoader()
425     ex=pilot.ExecutorSwig()
426     p=self.r.createProc("pr")
427     cont=p.createContainer("gg","HPSalome")
428     cont.setSizeOfPool(10)
429     td=p.createType("int","int")
430     td2=p.createSequenceTc("seqint","seqint",td)
431     td3=p.createSequenceTc("seqintvec","seqintvec",td2)
432     node1=self.r.createScriptNode("","node1")
433     node1.setScript(script1)
434     o1=node1.edAddOutputPort("o1",td3)
435     p.edAddChild(node1)
436     #
437     node2=self.r.createForEachLoop("node2",td2)
438     p.edAddChild(node2)
439     p.edAddCFLink(node1,node2)
440     p.edAddLink(o1,node2.edGetSeqOfSamplesPort())
441     node2.edGetNbOfBranchesPort().edInitInt(2)
442     node20=self.r.createBloc("node20")
443     node2.edAddChild(node20)
444     node200=self.r.createForEachLoop("node200",td)
445     node20.edAddChild(node200)
446     node200.edGetNbOfBranchesPort().edInitInt(10)
447     p.edAddLink(node2.edGetSamplePort(),node200.edGetSeqOfSamplesPort())
448     node2000=self.r.createScriptNode("","node2000")
449     node2000.setContainer(cont)
450     node2000.setExecutionMode("remote")
451     node200.edAddChild(node2000)
452     i5=node2000.edAddInputPort("i5",td)
453     o6=node2000.edAddOutputPort("o6",td)
454     node2000.setScript("o6=2+i5")
455     p.edAddLink(node200.edGetSamplePort(),i5)
456     #
457     node3=self.r.createForEachLoop("node3",td)
458     p.edAddChild(node3)
459     p.edAddCFLink(node2,node3)
460     p.edAddLink(o6,node3.edGetSeqOfSamplesPort())
461     node3.edGetNbOfBranchesPort().edInitInt(2)
462     node30=self.r.createBloc("node30")
463     node3.edAddChild(node30)
464     node300=self.r.createForEachLoop("node300",td)
465     node30.edAddChild(node300)
466     node300.edGetNbOfBranchesPort().edInitInt(10)
467     p.edAddLink(node3.edGetSamplePort(),node300.edGetSeqOfSamplesPort())
468     node3000=self.r.createScriptNode("","node3000")
469     node3000.setContainer(cont)
470     node3000.setExecutionMode("remote")
471     node300.edAddChild(node3000)
472     i14=node3000.edAddInputPort("i14",td)
473     o15=node3000.edAddOutputPort("o15",td)
474     node3000.setScript("o15=3+i14")
475     p.edAddLink(node300.edGetSamplePort(),i14)
476     #
477     node4=self.r.createScriptNode("","node4")
478     node4.setScript("o9=i8")
479     p.edAddChild(node4)
480     i8=node4.edAddInputPort("i8",td3)
481     o9=node4.edAddOutputPort("o9",td3)
482     p.edAddCFLink(node3,node4)
483     p.edAddLink(o15,i8)
484     p.saveSchema(fname)
485     p=l.load(fname)
486     ex = pilot.ExecutorSwig()
487     self.assertEqual(p.getState(),pilot.READY)
488     ex.RunW(p,0)
489     self.assertEqual(p.getState(),pilot.DONE)
490     zeResu=p.getChildByName("node4").getOutputPort("o9").get()
491     self.assertEqual(zeResu,[[5,6,7,8,9,10,11,12,13,14],[15,16,17,18,19,20,21,22,23,24,25],[26,27,28,29,30,31,32,33,34,35,36,37],[38,39,40,41,42,43,44,45,46,47,48,49,50],[51,52,53,54,55,56,57,58,59,60,61,62,63,64],[65,66,67,68,69,70,71,72,73,74,75,76,77,78,79], [80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95]])
492     pass
493
494   def test5(self):
495     """Non regression test 2 of multi pyNode, pyFuncNode sharing the same HPContainer instance."""
496     fname="TestSaveLoadRun5.xml"
497     script1="""nb=7
498 ii=0
499 o1=nb*[None]
500 for i in xrange(nb):
501     tmp=(i+10)*[None]
502     for j in xrange(i+10):
503         tmp[j]=ii
504         ii+=1
505         pass
506     o1[i]=tmp
507     pass
508 """
509     l=loader.YACSLoader()
510     ex=pilot.ExecutorSwig()
511     p=self.r.createProc("pr")
512     cont=p.createContainer("gg","HPSalome")
513     cont.setSizeOfPool(10)
514     td=p.createType("int","int")
515     td2=p.createSequenceTc("seqint","seqint",td)
516     td3=p.createSequenceTc("seqintvec","seqintvec",td2)
517     node1=self.r.createScriptNode("","node1")
518     node1.setScript(script1)
519     o1=node1.edAddOutputPort("o1",td3)
520     p.edAddChild(node1)
521     #
522     node2=self.r.createForEachLoop("node2",td2)
523     p.edAddChild(node2)
524     p.edAddCFLink(node1,node2)
525     p.edAddLink(o1,node2.edGetSeqOfSamplesPort())
526     node2.edGetNbOfBranchesPort().edInitInt(2)
527     node20=self.r.createBloc("node20")
528     node2.edAddChild(node20)
529     node200=self.r.createForEachLoop("node200",td)
530     node20.edAddChild(node200)
531     node200.edGetNbOfBranchesPort().edInitInt(10)
532     p.edAddLink(node2.edGetSamplePort(),node200.edGetSeqOfSamplesPort())
533     node2000=self.r.createFuncNode("Salome","node2000")
534     node2000.setFname("ff")
535     node2000.setContainer(cont)
536     node2000.setExecutionMode("remote")
537     node200.edAddChild(node2000)
538     i5=node2000.edAddInputPort("i5",td)
539     o6=node2000.edAddOutputPort("o6",td)
540     node2000.setScript("def ff(x):\n  return 2+x")
541     p.edAddLink(node200.edGetSamplePort(),i5)
542     #
543     node3=self.r.createForEachLoop("node3",td)
544     p.edAddChild(node3)
545     p.edAddCFLink(node2,node3)
546     p.edAddLink(o6,node3.edGetSeqOfSamplesPort())
547     node3.edGetNbOfBranchesPort().edInitInt(2)
548     node30=self.r.createBloc("node30")
549     node3.edAddChild(node30)
550     node300=self.r.createForEachLoop("node300",td)
551     node30.edAddChild(node300)
552     node300.edGetNbOfBranchesPort().edInitInt(10)
553     p.edAddLink(node3.edGetSamplePort(),node300.edGetSeqOfSamplesPort())
554     node3000=self.r.createFuncNode("Salome","node3000")
555     node3000.setFname("ff")
556     node3000.setContainer(cont)
557     node3000.setExecutionMode("remote")
558     node300.edAddChild(node3000)
559     i14=node3000.edAddInputPort("i14",td)
560     o15=node3000.edAddOutputPort("o15",td)
561     node3000.setScript("def ff(x):\n  return 3+x")
562     p.edAddLink(node300.edGetSamplePort(),i14)
563     #
564     node4=self.r.createScriptNode("","node4")
565     node4.setScript("o9=i8")
566     p.edAddChild(node4)
567     i8=node4.edAddInputPort("i8",td3)
568     o9=node4.edAddOutputPort("o9",td3)
569     p.edAddCFLink(node3,node4)
570     p.edAddLink(o15,i8)
571     p.saveSchema(fname)
572     p=l.load(fname)
573     ex = pilot.ExecutorSwig()
574     self.assertEqual(p.getState(),pilot.READY)
575     ex.RunW(p,0)
576     self.assertEqual(p.getState(),pilot.DONE)
577     zeResu=p.getChildByName("node4").getOutputPort("o9").get()
578     self.assertEqual(zeResu,[[5,6,7,8,9,10,11,12,13,14],[15,16,17,18,19,20,21,22,23,24,25],[26,27,28,29,30,31,32,33,34,35,36,37],[38,39,40,41,42,43,44,45,46,47,48,49,50],[51,52,53,54,55,56,57,58,59,60,61,62,63,64],[65,66,67,68,69,70,71,72,73,74,75,76,77,78,79], [80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95]])
579     pass
580
581   pass
582
583 import os
584 U = os.getenv('USER')
585 f=open("/tmp/" + U + "/UnitTestsResult", 'a')
586 f.write("  --- TEST src/yacsloader: testSaveLoadRun.py\n")
587 suite = unittest.makeSuite(TestSaveLoadRun)
588 result=unittest.TextTestRunner(f, descriptions=1, verbosity=1).run(suite)
589 f.close()
590 sys.exit(not result.wasSuccessful())