From bc996c150892705be3b2b9b2466e106d8cb2ec7f Mon Sep 17 00:00:00 2001 From: Ovidiu Mircescu Date: Tue, 2 Jun 2020 12:58:07 +0200 Subject: [PATCH] GUI update for workload manager. --- src/engine/Container.cxx | 26 ++++++++++++++++++++++++++ src/engine/Container.hxx | 3 +++ src/genericgui/FormContainer.cxx | 22 ++++++++++++++++++++++ src/genericgui/FormContainer.hxx | 1 + src/genericgui/FormParamContainer.ui | 7 +++++++ src/runtime/PythonNode.cxx | 20 ++++---------------- src/runtime/PythonNode.hxx | 3 +-- 7 files changed, 64 insertions(+), 18 deletions(-) diff --git a/src/engine/Container.cxx b/src/engine/Container.cxx index 7dbbac645..2843aa574 100644 --- a/src/engine/Container.cxx +++ b/src/engine/Container.cxx @@ -32,6 +32,8 @@ const char Container::KIND_ENTRY[]="container_kind"; const char Container::AOC_ENTRY[]="attached_on_cloning"; +const char Container::STORE_CONTEXT_PROPERTY[]="store_context"; + Container::Container():_isAttachedOnCloning(false),_proc(0) { } @@ -104,3 +106,27 @@ void Container::setProperties(const std::map& propertie setProperty((*it).first,(*it).second); } +bool Container::storeContext() +{ + bool found = false; + std::string str_value; + str_value = getProperty(STORE_CONTEXT_PROPERTY); + const char* yes_values[] = {"YES", "Yes", "yes", "TRUE", "True", "true", "1", + "ON", "on", "On"}; + for(const char* v : yes_values) + if(str_value == v) + { + found = true; + break; + } + return found; +} + +void Container::setStoreContext(bool v) +{ + if(v) + setProperty(STORE_CONTEXT_PROPERTY, "1"); + else + setProperty(STORE_CONTEXT_PROPERTY, "0"); +} + diff --git a/src/engine/Container.hxx b/src/engine/Container.hxx index 9ec9e594d..4f94da390 100644 --- a/src/engine/Container.hxx +++ b/src/engine/Container.hxx @@ -55,6 +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 std::string getPlacementId(const Task *askingNode) const = 0; virtual std::string getFullPlacementId(const Task *askingNode) const = 0; //Edition only methods @@ -84,6 +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[]; protected: std::string _name; mutable bool _isAttachedOnCloning; diff --git a/src/genericgui/FormContainer.cxx b/src/genericgui/FormContainer.cxx index 00fb5b3ce..e649ecfbb 100644 --- a/src/genericgui/FormContainer.cxx +++ b/src/genericgui/FormContainer.cxx @@ -36,6 +36,7 @@ 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() @@ -47,7 +48,10 @@ void FormContainer::FillPanel(YACS::ENGINE::Container *container) DEBTRACE("FormContainer::FillPanel"); FormContainerBase::FillPanel(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"); cb_type->addItem("multi"); @@ -92,3 +96,21 @@ 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 d7a601761..190048f39 100644 --- a/src/genericgui/FormContainer.hxx +++ b/src/genericgui/FormContainer.hxx @@ -43,6 +43,7 @@ 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 010589813..52a8e539e 100644 --- a/src/genericgui/FormParamContainer.ui +++ b/src/genericgui/FormParamContainer.ui @@ -113,6 +113,13 @@ + + + + Store python cache + + + diff --git a/src/runtime/PythonNode.cxx b/src/runtime/PythonNode.cxx index 9ac3c6105..33f7fb307 100644 --- a/src/runtime/PythonNode.cxx +++ b/src/runtime/PythonNode.cxx @@ -76,8 +76,6 @@ const char PyFuncNode::SCRIPT_FOR_SERIALIZATION[]="import pickle\n" " args=pickle.loads(st)\n" " return args\n"; -const char PythonNode::KEEP_CONTEXT_PROPERTY[]="keep_context"; - PythonEntry::PythonEntry():_context(0),_pyfuncSer(0),_pyfuncUnser(0),_pyfuncSimpleSer(0) { } @@ -551,7 +549,7 @@ void PythonNode::executeRemote() squeezeMemoryRemote(); } // - if(!keepContext()) + if(!storeContext()) { if(!CORBA::is_nil(_pynode)) { @@ -746,27 +744,17 @@ bool PythonNode::canAcceptImposedResource() std::string PythonNode::pythonEntryName()const { - if(keepContext()) + if(storeContext()) return "DEFAULT_NAME_FOR_UNIQUE_PYTHON_NODE_ENTRY"; else return getName(); } -bool PythonNode::keepContext()const +bool PythonNode::storeContext()const { bool found = false; if(_container) - { - std::string str_value = _container->getProperty(KEEP_CONTEXT_PROPERTY); - const char* yes_values[] = {"YES", "Yes", "yes", "TRUE", "True", "true", "1", - "ON", "on", "On"}; - for(const char* v : yes_values) - if(str_value == v) - { - found = true; - break; - } - } + found = _container->storeContext(); return found; } diff --git a/src/runtime/PythonNode.hxx b/src/runtime/PythonNode.hxx index a18409bd7..9db3862b7 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 keepContext()const; + bool storeContext()const; std::string getContainerLog(); PythonNode* cloneNode(const std::string& name); virtual std::string typeName() { return "YACS__ENGINE__PythonNode"; } @@ -108,7 +108,6 @@ namespace YACS static const char SCRIPT_FOR_SERIALIZATION[]; static const char REMOTE_NAME[]; static const char DPL_INFO_NAME[]; - static const char KEEP_CONTEXT_PROPERTY[]; protected: bool _autoSqueeze = false; Engines::PyScriptNode_var _pynode; -- 2.39.2