+ def test4(self):
+ """ two branch whose on with one elementary node and on foreach"""
+ SALOMERuntime.RuntimeSALOME.setRuntime()
+ r=SALOMERuntime.getSALOMERuntime()
+ pg=pilot.PlayGround()
+ pg.loadFromKernelCatalog()
+ assert(len(pg.getData())!=0)
+ p=r.createProc("p0")
+ td=p.createType("double","double")
+ tdd=p.createSequenceTc("seqdouble","seqdouble",td)
+ hp1=p.createContainer("HP1","HPSalome")
+ #
+ ##
+ n0=r.createScriptNode("Salome","n0")
+ n0.setExecutionMode("remote")
+ out0_0=n0.edAddOutputPort("o1",tdd)
+ n0.setScript("""o1=[float(i)+0.1 for i in range(1000)]""")
+ n0.setContainer(hp1)
+ p.edAddChild(n0)
+ #
+ b0 = r.createBloc("Bloc0")
+ p.edAddChild(b0)
+ p.edAddCFLink(n0,b0)
+ ##
+ n1_0=r.createForEachLoop("n1_0",td)
+ b0.edAddChild(n1_0)
+ p.edAddLink(out0_0,n1_0.edGetSeqOfSamplesPort())
+ n1_0.setWeight(10.)
+ ##
+ n1_0_sc=r.createScriptNode("Salome","n1_0_sc")
+ n1_0.edAddChild(n1_0_sc)
+ n1_0_sc.setExecutionMode("remote")
+ n1_0_sc.setScript("""2*i1""")
+ i1_0_sc=n1_0_sc.edAddInputPort("i1",td)
+ p.edAddLink(n1_0.edGetSamplePort(),i1_0_sc)
+ n1_0_sc.setContainer(hp1)
+ ##
+ n1_0_1=r.createScriptNode("Salome","n1_0_1")
+ n1_0_1.setExecutionMode("remote")
+ n1_0_1.setScript("""a=2""")
+ b0.edAddChild(n1_0_1)
+ p.edAddCFLink(n1_0,n1_0_1)
+ n1_0_1.setContainer(hp1)
+ n1_0_1.setWeight(20.)
+ ##
+ #
+ n1_1=r.createForEachLoop("n1_1",td)
+ p.edAddChild(n1_1)
+ p.edAddCFLink(n0,n1_1)
+ p.edAddLink(out0_0,n1_1.edGetSeqOfSamplesPort())
+ n1_1.setWeight(100.)
+ ##
+ n1_1_sc=r.createScriptNode("Salome","n1_1_sc")
+ n1_1.edAddChild(n1_1_sc)
+ n1_1_sc.setExecutionMode("remote")
+ n1_1_sc.setScript("""3*i1""")
+ i1_1_sc=n1_1_sc.edAddInputPort("i1",td)
+ p.edAddLink(n1_1.edGetSamplePort(),i1_1_sc)
+ n1_1_sc.setContainer(hp1)
+
+ hp1.setProperty("nb_proc_per_node","1")
+ pg.setData([("m0",12)])
+ w=pilot.ComplexWeight()
+ b0.getWeightRegardingDPL(w)
+ assert(w.getElementaryWeight()==20.)
+ assert(w.calculateTotalLength(1)==30.)
+ assert(w.calculateTotalLength(2)==25.)
+ p.fitToPlayGround(pg)########### ZE CALL
+ assert(n1_0.edGetNbOfBranchesPort().getPyObj()==7)
+ assert(n1_1.edGetNbOfBranchesPort().getPyObj()==5)
+ #
+ fyto=pilot.ForTestOmlyHPContCls()
+ n1_0_sc.getContainer().forYourTestsOnly(fyto)
+ assert(fyto.getContainerType()=="HPContainerShared")
+ pd=fyto.getPD()
+ assert(isinstance(pd,pilot.ContigPartDefinition))
+ print (pd.getStart(),pd.getStop())
+ assert(pd.getStart()==0 and pd.getStop()==7)
+
+ #########################
+ ## change HPcontainer
+ ## very important: if you change HPcontainer you have to reload the graph
+ #########################
+ p=r.createProc("p0")
+ n0=r.createScriptNode("Salome","n0")
+ n0.setExecutionMode("remote")
+ out0_0=n0.edAddOutputPort("o1",tdd)
+ n0.setScript("""o1=[float(i)+0.1 for i in range(1000)]""")
+ n0.setContainer(hp1)
+ p.edAddChild(n0)
+ #
+ b0 = r.createBloc("Bloc0")
+ p.edAddChild(b0)
+ p.edAddCFLink(n0,b0)
+ ##
+ n1_0=r.createForEachLoop("n1_0",td)
+ b0.edAddChild(n1_0)
+ p.edAddLink(out0_0,n1_0.edGetSeqOfSamplesPort())
+ ##
+ n1_0_sc=r.createScriptNode("Salome","n1_0_sc")
+ n1_0.edAddChild(n1_0_sc)
+ n1_0_sc.setExecutionMode("remote")
+ n1_0_sc.setScript("""2*i1""")
+ i1_0_sc=n1_0_sc.edAddInputPort("i1",td)
+ p.edAddLink(n1_0.edGetSamplePort(),i1_0_sc)
+ n1_0_sc.setContainer(hp1)
+ ##
+ n1_0_1=r.createForEachLoop("n1_0_1",td)
+ b0.edAddChild(n1_0_1)
+ p.edAddLink(out0_0,n1_0_1.edGetSeqOfSamplesPort())
+ p.edAddCFLink(n1_0,n1_0_1)
+ ##
+ n1_0_1sc=r.createScriptNode("Salome","n1_0_1sc")
+ n1_0_1.edAddChild(n1_0_1sc)
+ n1_0_1sc.setExecutionMode("remote")
+ n1_0_1sc.setScript("""a=2""")
+ i1_0_1sc=n1_0_1sc.edAddInputPort("i1",td)
+ p.edAddLink(n1_0_1.edGetSamplePort(),i1_0_1sc)
+ ##
+ #
+ n1_1=r.createForEachLoop("n1_1",td)
+ p.edAddChild(n1_1)
+ p.edAddCFLink(n0,n1_1)
+ p.edAddLink(out0_0,n1_1.edGetSeqOfSamplesPort())
+ ##
+ n1_1_sc=r.createScriptNode("Salome","n1_1_sc")
+ n1_1.edAddChild(n1_1_sc)
+ n1_1_sc.setExecutionMode("remote")
+ n1_1_sc.setScript("""3*i1""")
+ i1_1_sc=n1_1_sc.edAddInputPort("i1",td)
+ p.edAddLink(n1_1.edGetSamplePort(),i1_1_sc)
+ n1_1_sc.setContainer(hp1)
+ ##
+ ##
+ hp4=p.createContainer("HP4","HPSalome")
+ hp4.setProperty("nb_proc_per_node","4")
+ n1_0.setWeight(40.)
+ n1_0_1.setWeight(20)
+ n1_1.setWeight(100.)
+ n1_0_1sc.setContainer(hp4)
+ w=pilot.ComplexWeight()
+ b0.getWeightRegardingDPL(w)
+ assert(w.getElementaryWeight()==0.)
+ assert(w.calculateTotalLength(4)==30.)
+ assert(w.calculateTotalLength(8)==15.)
+ pg.setData([("m0",120)])
+ p.fitToPlayGround(pg)########### ZE CALL
+ assert(n1_0.edGetNbOfBranchesPort().getPyObj()==64)
+ assert(n1_0_1.edGetNbOfBranchesPort().getPyObj()==16)
+ assert(n1_1.edGetNbOfBranchesPort().getPyObj()==56)
+ #
+ fyto=pilot.ForTestOmlyHPContCls()
+ n1_0_sc.getContainer().forYourTestsOnly(fyto)
+ assert(fyto.getContainerType()=="HPContainerShared")
+ pd=fyto.getPD()
+ assert(isinstance(pd,pilot.ContigPartDefinition))
+ assert(pd.getStart()==0 and pd.getStop()==64)
+ pass
+