IfProxyDoSomething(ob,"unlinkOnDestructor");
}
-PythonNode::PythonNode(const PythonNode& other, ComposedNode *father):InlineNode(other,father),_autoSqueeze(other._autoSqueeze)
+PythonNode::PythonNode(const PythonNode& other, ComposedNode *father):
+InlineNode(other,father),_autoSqueeze(other._autoSqueeze),_nonSqueezableOutputNodes(other._nonSqueezableOutputNodes)
{
_pynode = Engines::PyScriptNode::_nil();
_implementation=IMPL_NAME;
DEBTRACE( "++++++++++++++ End PyNode::execute: " << getName() << " ++++++++++++++++++++" );
}
+/*!
+ * [EDF28562]
+ * \param in squeezeExceptions list on output port name excluded from the squeeze mecanism
+ */
+void PythonNode::setSqueezeStatusWithExceptions(bool sqStatus, const std::vector<std::string>& squeezeExceptions)
+{
+ this->setSqueezeStatus(sqStatus);
+ this->_nonSqueezableOutputNodes = std::set<std::string>(squeezeExceptions.begin(), squeezeExceptions.end());
+}
+
void PythonNode::squeezeMemorySafe()
{
AutoGIL agil;
}
for(auto p : _setOfOutputPort)
{
+ if (!this->_nonSqueezableOutputNodes.empty() && this->_nonSqueezableOutputNodes.find(p->getName()) != this->_nonSqueezableOutputNodes.end())
+ continue;
PyDict_DelItemString(_context,p->getName().c_str());
OutputPyPort *p2(static_cast<OutputPyPort *>(p));
p2->putWithoutForward(Py_None);
}
for(auto p : _setOfOutputPort)
{
+ if (!this->_nonSqueezableOutputNodes.empty() && this->_nonSqueezableOutputNodes.find(p->getName()) != this->_nonSqueezableOutputNodes.end())
+ continue;
OutputPyPort *p2(static_cast<OutputPyPort *>(p));
p2->putWithoutForward(Py_None);
}
ex=pilot.ExecutorSwig()
ex.setMaxNbOfThreads(NB_OF_PARALLEL_THREADS)
ex.RunW(p,0)
+ self.assertEqual(p.getState(),pilot.DONE)
salome.cm.ShutdownContainers()
print("End of computation {}".format( str(datetime.datetime.now()-st) ) )
if p.getChildByName("end").getOutputPort("ozeret").getPyObj() != [3*i for i in range(NB_OF_PARALLEL_NODES)]:
raise RuntimeError("Ooops")
+
+ def test1(self):
+ """
+ [EDF28562] : test of exclusion output port of squeezeMemory mecanism
+ """
+ salome.salome_init()
+ import KernelBasis
+ KernelBasis.SetVerbosityActivated(False)
+ SALOMERuntime.RuntimeSALOME.setRuntime()
+ r=SALOMERuntime.getSALOMERuntime()
+ p=r.createProc("Squeeze")
+ pyobj=p.createInterfaceTc("python:obj:1.0","pyobj",[])
+ cont=p.createContainer("gg","Salome")
+ cont.setProperty("nb_parallel_procs","1")
+ cont.setAttachOnCloningStatus(True)
+ cont.setProperty("attached_on_cloning","1")
+ cont.setProperty("type","multi")
+ cont.setProperty("container_name","gilles")
+ startNode = r.createScriptNode("Salome","startNode")
+ startNode.setExecutionMode("remote")
+ startNode.setContainer(cont)
+ startNode.setSqueezeStatus(True)
+ startNode.setScript("""
+o1,o2,o3,o4 = 31,32,33,34
+""")
+ o1 = startNode.edAddOutputPort("o1",pyobj)
+ o2 = startNode.edAddOutputPort("o2",pyobj)
+ o3 = startNode.edAddOutputPort("o3",pyobj)
+ o4 = startNode.edAddOutputPort("o4",pyobj)
+ p.edAddChild(startNode)
+ endNode = r.createScriptNode("Salome","endNode")
+ endNode.setExecutionMode("remote")
+ endNode.setContainer(cont)
+ endNode.setSqueezeStatus(True)
+ endNode.setScript("""
+o5,o6 = 45,46
+""")
+ o5 = endNode.edAddOutputPort("o5",pyobj)
+ o6 = endNode.edAddOutputPort("o6",pyobj)
+ p.edAddChild(endNode)
+ p.edAddCFLink(startNode,endNode)
+ # disable proxy
+ salome.cm.SetOverrideEnvForContainersSimple([("SALOME_BIG_OBJ_ON_DISK_THRES","-1")])
+ # First part squeeze.
+ ex=pilot.ExecutorSwig()
+ ex.RunW(p,0)
+ self.assertEqual(p.getState(),pilot.DONE)
+ for outp in ["o1","o2","o3","o4"]:
+ self.assertTrue( p.getChildByName("startNode").getOutputPort(outp).getPyObj() is None )
+ for outp in ["o5","o6"]:
+ self.assertTrue( p.getChildByName("endNode").getOutputPort(outp).getPyObj() is None )
+ #### Now it s time
+ #KernelBasis.SetVerbosityActivated(True)
+ startNode.setSqueezeStatusWithExceptions(True,["o1","o3"])#<- The key point is here
+ endNode.setSqueezeStatusWithExceptions(True,["o5"])#<- The key point is here
+ ex=pilot.ExecutorSwig()
+ ex.RunW(p,0)
+ self.assertEqual(p.getState(),pilot.DONE)
+ salome.cm.ShutdownContainers()
+ for outp in ["o2","o4"]:
+ self.assertTrue( p.getChildByName("startNode").getOutputPort(outp).getPyObj() is None )
+ for outp in ["o6"]:
+ self.assertTrue( p.getChildByName("endNode").getOutputPort(outp).getPyObj() is None )
+ #
+ for outp,valExp in [("o1",31),("o3",33)]:
+ self.assertEqual( p.getChildByName("startNode").getOutputPort(outp).getPyObj(), valExp )
+ for outp,valExp in [("o5",45)]:
+ self.assertEqual( p.getChildByName("endNode").getOutputPort(outp).getPyObj(), valExp )
+
if __name__ == '__main__':
with tempfile.TemporaryDirectory() as dir_test: