From: Ovidiu Mircescu Date: Thu, 4 Jun 2020 15:09:18 +0000 (+0200) Subject: Workload manager: more tests and other improvements. X-Git-Tag: V9_6_0a1~7^2~12 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b6959bd64b339efd38dbcf24a561d43806f6ffee;p=modules%2Fyacs.git Workload manager: more tests and other improvements. --- diff --git a/src/engine/Container.cxx b/src/engine/Container.cxx index 2843aa574..c560739d3 100644 --- a/src/engine/Container.cxx +++ b/src/engine/Container.cxx @@ -32,7 +32,7 @@ const char Container::KIND_ENTRY[]="container_kind"; const char Container::AOC_ENTRY[]="attached_on_cloning"; -const char Container::STORE_CONTEXT_PROPERTY[]="store_context"; +const char Container::USE_PYCACHE_PROPERTY[]="use_py_cache"; Container::Container():_isAttachedOnCloning(false),_proc(0) { @@ -106,11 +106,11 @@ void Container::setProperties(const std::map& propertie setProperty((*it).first,(*it).second); } -bool Container::storeContext() +bool Container::isUsingPythonCache() { bool found = false; std::string str_value; - str_value = getProperty(STORE_CONTEXT_PROPERTY); + str_value = getProperty(USE_PYCACHE_PROPERTY); const char* yes_values[] = {"YES", "Yes", "yes", "TRUE", "True", "true", "1", "ON", "on", "On"}; for(const char* v : yes_values) @@ -122,11 +122,11 @@ bool Container::storeContext() return found; } -void Container::setStoreContext(bool v) +void Container::usePythonCache(bool v) { if(v) - setProperty(STORE_CONTEXT_PROPERTY, "1"); + setProperty(USE_PYCACHE_PROPERTY, "1"); else - setProperty(STORE_CONTEXT_PROPERTY, "0"); + setProperty(USE_PYCACHE_PROPERTY, "0"); } diff --git a/src/engine/Container.hxx b/src/engine/Container.hxx index 4f94da390..d2cd8d485 100644 --- a/src/engine/Container.hxx +++ b/src/engine/Container.hxx @@ -55,8 +55,8 @@ namespace YACS const std::string& resource_name, const std::string& container_name); virtual bool canAcceptImposedResource(); - virtual bool storeContext(); - virtual void setStoreContext(bool v); + virtual bool isUsingPythonCache(); + virtual void usePythonCache(bool v); virtual std::string getPlacementId(const Task *askingNode) const = 0; virtual std::string getFullPlacementId(const Task *askingNode) const = 0; //Edition only methods @@ -86,7 +86,7 @@ namespace YACS virtual void shutdown(int level) = 0; static const char KIND_ENTRY[]; static const char AOC_ENTRY[]; - static const char STORE_CONTEXT_PROPERTY[]; + static const char USE_PYCACHE_PROPERTY[]; protected: std::string _name; mutable bool _isAttachedOnCloning; diff --git a/src/engine/Executor.cxx b/src/engine/Executor.cxx index c46ebf2e8..24603ef0a 100644 --- a/src/engine/Executor.cxx +++ b/src/engine/Executor.cxx @@ -1419,8 +1419,7 @@ void Executor::loadTask(Task *task, const WorkloadManager::RunInfo& runInfo) try { std::ostringstream container_name; - container_name << runInfo.resource.name << "-" - << runInfo.type.name << "-" << runInfo.index; + container_name << runInfo.type.name << "-" << runInfo.index; task->imposeResource(runInfo.resource.name, container_name.str()); traceExec(task, "load", ComputePlacement(task)); task->load(); diff --git a/src/genericgui/FormAdvParamContainer.cxx b/src/genericgui/FormAdvParamContainer.cxx index c88a27901..935828299 100644 --- a/src/genericgui/FormAdvParamContainer.cxx +++ b/src/genericgui/FormAdvParamContainer.cxx @@ -64,6 +64,7 @@ FormAdvParamContainer::FormAdvParamContainer(std::map& connect(sb_procNode, SIGNAL(valueChanged(const QString&)), this, SLOT(onModifyProcs(const QString&))); connect(sb_nbprocpar, SIGNAL(valueChanged(const QString&)), this, SLOT(onModifyProcPar(const QString&))); connect(sb_nbproc, SIGNAL(valueChanged(const QString&)), this, SLOT(onModifyProcRes(const QString&))); + connect(ch_pycache,SIGNAL(stateChanged(int)),this,SLOT(onModifyUsePyCache(int))); } FormAdvParamContainer::~FormAdvParamContainer() @@ -113,6 +114,11 @@ void FormAdvParamContainer::FillPanel(const std::string& resource, YACS::ENGINE: else le_workdir->setText(""); + if(_container) + ch_pycache->setCheckState(_container->isUsingPythonCache()?Qt::Checked:Qt::Unchecked); + else + ch_pycache->setCheckState(Qt::Unchecked); + if(_properties.count("container_name")) le_contname->setText(_properties["container_name"].c_str()); else @@ -532,3 +538,20 @@ void FormAdvParamContainer::onModifyResourceList(const QString &text) if (properties["resource_list"] != text.toStdString()) onModified(); } + +void FormAdvParamContainer::onModifyUsePyCache(int val) +{ + if (!_container) + return; + bool val2(false); + if(val==Qt::Unchecked) + val2=false; + if(val==Qt::Checked) + val2=true; + bool prop = _container->isUsingPythonCache(); + int prop2((int)val2); + std::ostringstream oss; oss << prop2; + _container->usePythonCache(val2); + if(prop!=val2) + onModified(); +} diff --git a/src/genericgui/FormAdvParamContainer.hxx b/src/genericgui/FormAdvParamContainer.hxx index 3fba141c3..88e00f2b0 100644 --- a/src/genericgui/FormAdvParamContainer.hxx +++ b/src/genericgui/FormAdvParamContainer.hxx @@ -67,7 +67,7 @@ public slots: void onModifyProcRes(const QString &text); void onModifyCompoList(const QString &text); void onModifyResourceList(const QString &text); - + void onModifyUsePyCache(int val); protected: bool _advanced; diff --git a/src/genericgui/FormAdvParamContainer.ui b/src/genericgui/FormAdvParamContainer.ui index ac8225796..3129f6154 100644 --- a/src/genericgui/FormAdvParamContainer.ui +++ b/src/genericgui/FormAdvParamContainer.ui @@ -74,6 +74,13 @@ + + + Use python cache + + + + Parallel parameters @@ -145,7 +152,7 @@ - + Qt::Vertical diff --git a/src/genericgui/FormContainer.cxx b/src/genericgui/FormContainer.cxx index e649ecfbb..5a88fb7f9 100644 --- a/src/genericgui/FormContainer.cxx +++ b/src/genericgui/FormContainer.cxx @@ -36,7 +36,6 @@ FormContainer::FormContainer(QWidget *parent):FormContainerBase(parent),cb_type( FormContainer::FillPanel(0); // --- set widgets before signal connexion to avoid false modif detection connect(cb_type, SIGNAL(activated(const QString&)),this, SLOT(onModifyType(const QString&))); connect(ch_aoc,SIGNAL(stateChanged(int)),this,SLOT(onModifyAOC(int))); - connect(ch_pycache,SIGNAL(stateChanged(int)),this,SLOT(onModifyStorePyCache(int))); } FormContainer::~FormContainer() @@ -50,7 +49,6 @@ void FormContainer::FillPanel(YACS::ENGINE::Container *container) if(container) { ch_aoc->setCheckState(container->isAttachedOnCloning()?Qt::Checked:Qt::Unchecked); - ch_pycache->setCheckState(container->storeContext()?Qt::Checked:Qt::Unchecked); } cb_type->clear(); cb_type->addItem("mono"); @@ -96,21 +94,3 @@ void FormContainer::onModifyAOC(int val) if(prop!=val2) onModified(); } - -void FormContainer::onModifyStorePyCache(int val) -{ - if (!_container) - return; - bool val2(false); - if(val==Qt::Unchecked) - val2=false; - if(val==Qt::Checked) - val2=true; - bool prop = _container->storeContext(); - int prop2((int)val2); - std::ostringstream oss; oss << prop2; - //_properties[YACS::ENGINE::Container::AOC_ENTRY]=oss.str(); - _container->setStoreContext(val2); - if(prop!=val2) - onModified(); -} diff --git a/src/genericgui/FormContainer.hxx b/src/genericgui/FormContainer.hxx index 190048f39..d7a601761 100644 --- a/src/genericgui/FormContainer.hxx +++ b/src/genericgui/FormContainer.hxx @@ -43,7 +43,6 @@ public: public slots: void onModifyType(const QString &text); void onModifyAOC(int val); - void onModifyStorePyCache(int val); private: QComboBox *cb_type; }; diff --git a/src/genericgui/FormParamContainer.ui b/src/genericgui/FormParamContainer.ui index 52a8e539e..010589813 100644 --- a/src/genericgui/FormParamContainer.ui +++ b/src/genericgui/FormParamContainer.ui @@ -113,13 +113,6 @@ - - - - Store python cache - - - diff --git a/src/runtime/PythonNode.cxx b/src/runtime/PythonNode.cxx index 33f7fb307..579d49b8b 100644 --- a/src/runtime/PythonNode.cxx +++ b/src/runtime/PythonNode.cxx @@ -549,7 +549,7 @@ void PythonNode::executeRemote() squeezeMemoryRemote(); } // - if(!storeContext()) + if(!isUsingPythonCache()) { if(!CORBA::is_nil(_pynode)) { @@ -744,17 +744,17 @@ bool PythonNode::canAcceptImposedResource() std::string PythonNode::pythonEntryName()const { - if(storeContext()) + if(isUsingPythonCache()) return "DEFAULT_NAME_FOR_UNIQUE_PYTHON_NODE_ENTRY"; else return getName(); } -bool PythonNode::storeContext()const +bool PythonNode::isUsingPythonCache()const { bool found = false; if(_container) - found = _container->storeContext(); + found = _container->isUsingPythonCache(); return found; } diff --git a/src/runtime/PythonNode.hxx b/src/runtime/PythonNode.hxx index 9db3862b7..12ba7891d 100644 --- a/src/runtime/PythonNode.hxx +++ b/src/runtime/PythonNode.hxx @@ -91,7 +91,7 @@ namespace YACS void imposeResource(const std::string& resource_name, const std::string& container_name) override; bool canAcceptImposedResource()override; - bool storeContext()const; + bool isUsingPythonCache()const; std::string getContainerLog(); PythonNode* cloneNode(const std::string& name); virtual std::string typeName() { return "YACS__ENGINE__PythonNode"; } diff --git a/src/yacsloader/samples/wlm_2foreach_with_cache.xml b/src/yacsloader/samples/wlm_2foreach_with_cache.xml new file mode 100644 index 000000000..653489c2f --- /dev/null +++ b/src/yacsloader/samples/wlm_2foreach_with_cache.xml @@ -0,0 +1,203 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Begin ForEach1 + Begin ForEach2 + Begin End + ForEach1 End + ForEach2 End + + Begin t0 + End t0 + + + Begin vals + End vals + + + Begin vals + ForEach1 SmplsCollection + + + Begin vals + ForEach2 SmplsCollection + + + Begin nbbranches + ForEach2 nbBranches + + + Begin nbbranches + ForEach1 nbBranches + + + ForEach1 evalSamples + ForEach1.PyNode1 v + + + ForEach2 evalSamples + ForEach2.PyNode2 v + + + ForEach1.PyNode1 result + End r1 + + + ForEach2.PyNode2 result + End r2 + + + ForEach1nbBranches + 1 + + + ForEach2nbBranches + 1 + + + + + + + + + diff --git a/src/yacsloader_swig/Test/runUnitTest.sh b/src/yacsloader_swig/Test/runUnitTest.sh index 5c3c745c0..5b014bffc 100755 --- a/src/yacsloader_swig/Test/runUnitTest.sh +++ b/src/yacsloader_swig/Test/runUnitTest.sh @@ -28,8 +28,8 @@ sleep 3 export TESTCOMPONENT_ROOT_DIR=`pwd`/../runtime #python3 -m unittest discover -MODULES_TO_TEST=testEdit testExec testFEDyn testFEDyn2 testLoader testProgress \ -testRefcount testResume testSave testSaveLoadRun testValidationChecks +MODULES_TO_TEST="testEdit testExec testLoader testProgress testRefcount \ +testResume testSave testSaveLoadRun testValidationChecks" python3 -m unittest $MODULES_TO_TEST ret=$? diff --git a/src/yacsloader_swig/Test/testPynodeWithCache.py b/src/yacsloader_swig/Test/testPynodeWithCache.py index 0dd3f817c..e40d0c4e4 100755 --- a/src/yacsloader_swig/Test/testPynodeWithCache.py +++ b/src/yacsloader_swig/Test/testPynodeWithCache.py @@ -68,7 +68,7 @@ class TestEdit(unittest.TestCase): # if no property is set, the old executor is used proc.setProperty("executor", "workloadmanager") # reuse the same python context for every execution - cont.setStoreContext(True) + cont.usePythonCache(True) # save & reload schema_file = os.path.join(dir_test,"pynode_with_cache1.xml") proc.saveSchema(schema_file) @@ -107,7 +107,7 @@ class TestEdit(unittest.TestCase): proc.edAddChild(n2) proc.edAddCFLink(n1,n2) # reuse the same python context for every execution - cont.setStoreContext(True) + cont.usePythonCache(True) # save & reload schema_file = os.path.join(dir_test,"pynode_with_cache2.xml") proc.saveSchema(schema_file) diff --git a/src/yacsloader_swig/Test/testWorkloadManager.py b/src/yacsloader_swig/Test/testWorkloadManager.py index 6b522e741..8377ccf42 100755 --- a/src/yacsloader_swig/Test/testWorkloadManager.py +++ b/src/yacsloader_swig/Test/testWorkloadManager.py @@ -53,7 +53,24 @@ class TestEdit(unittest.TestCase): # lower time means some resources are overloaded self.assertTrue(execution_time > 13) # The containers need some time to be launched. - # We need some room for that. + # We need some delay to add to the 15s. + self.assertTrue(execution_time < 20) + + def test2(self): + """ Two parallel foreach-s with different containers and python nodes + using cache. + """ + proc = self.l.load("samples/wlm_2foreach_with_cache.xml") + self.e.RunW(proc,0) + ok = proc.getChildByName("End").getOutputPort("ok") + self.assertTrue(ok) + total_time = proc.getChildByName("End").getOutputPort("total_time") + # theoretical time should be 16s + execution_time = total_time.getPyObj() + # lower time means some resources are overloaded + self.assertTrue(execution_time > 14) + # The containers need some time to be launched. + # We need some delay to add to the 15s. self.assertTrue(execution_time < 20) if __name__ == '__main__':