diff --git a/contrib/onelab/OnelabClients.cpp b/contrib/onelab/OnelabClients.cpp index b606ac933db533571d51e844a4632f57234bb8d9..2baffbc96ef450a73892f9dc41c8ea5835fea36e 100644 --- a/contrib/onelab/OnelabClients.cpp +++ b/contrib/onelab/OnelabClients.cpp @@ -482,17 +482,18 @@ void localSolverClient::addNumberChoice(std::string name, double val, bool readO get(ps, name); if(ps.size()){ choices = ps[0].getChoices(); + ps[0].setReadOnly(readOnly); + ps[0].setValue(val); + choices.push_back(val); + ps[0].setChoices(choices); + //ps[0].setAttribute("Highlight","Coral"); + set(ps[0]); } else{ - ps.resize(1); - ps[0].setName(name); - } - //ps[0].setAttribute("Highlight","Coral"); - ps[0].setReadOnly(readOnly); - ps[0].setValue(val); - choices.push_back(val); - ps[0].setChoices(choices); - set(ps[0]); + OLMsg::Error("The parameter <%s> does not exist", name.c_str()); + // ps.resize(1); + // ps[0].setName(name); + } } void localSolverClient::PostArray(std::vector<std::string> choices) @@ -504,9 +505,10 @@ void localSolverClient::PostArray(std::vector<std::string> choices) std::string fileName = getWorkingDir()+choices[4*i]; //checkIfPresent or make available locally double val=find_in_array(lin,col,read_array(fileName,' ')); - addNumberChoice(longName(choices[4*i+3]),val,true); + std::string paramName = choices[4*i+3]; + addNumberChoice(paramName,val,true); OLMsg::Info("Upload parameter <%s>=%e from file <%s>", - choices[4*i+3].c_str(),val,fileName.c_str()); + paramName.c_str(),val,fileName.c_str()); i++; } } @@ -654,7 +656,7 @@ bool remoteClient::syncOutputFile(const std::string &wdir, const std::string &fi void MetaModel::construct() { - OLMsg::Info("Metamodel now CONSTRUCTING"); + OLMsg::Info("===== CONSTRUCTING"); std::string fileName = getWorkingDir() + genericNameFromArgs + onelabExtension; openOnelabBlock(); parse_onefile(fileName); @@ -664,7 +666,7 @@ void MetaModel::construct() } void MetaModel::analyze() { - OLMsg::Info("Metamodel now ANALYZING"); + OLMsg::Info("===== ANALYZING"); std::string fileName = getWorkingDir() + genericNameFromArgs + onelabExtension; openOnelabBlock(); OLMsg::Info("Parse file <%s> %s", fileName.c_str(), @@ -673,7 +675,7 @@ void MetaModel::analyze() { } void MetaModel::compute() { - OLMsg::Info("Metamodel now COMPUTING"); + OLMsg::Info("===== COMPUTING"); std::string fileName = getWorkingDir() + genericNameFromArgs + onelabExtension; openOnelabBlock(); OLMsg::Info("Parse file <%s> %s", fileName.c_str(), @@ -732,7 +734,7 @@ void MetaModel::PostArray(std::vector<std::string> choices) void InterfacedClient::analyze() { std::vector<std::string> choices, split; - OLMsg::Info("Analyze <%s> changed=%d", getName().c_str(), + OLMsg::Info("Analyzes <%s> changed=%d", getName().c_str(), onelab::server::instance()->getChanged(getName())); setAction("check"); @@ -812,7 +814,7 @@ void InterfacedClient::compute(){ // NATIVE Client void NativeClient::analyze() { - OLMsg::Info("Analyze <%s> changed=%d", getName().c_str(), + OLMsg::Info("Analyzes <%s> changed=%d", getName().c_str(), onelab::server::instance()->getChanged(getName())); setAction("check"); if(!run()) @@ -865,7 +867,7 @@ void NativeClient::compute() { void EncapsulatedClient::analyze() { std::vector<std::string> choices, split; - OLMsg::Info("Analyze <%s> changed=%d", getName().c_str(), + OLMsg::Info("Analyzes <%s> changed=%d", getName().c_str(), onelab::server::instance()->getChanged(getName())); setAction("check"); @@ -941,8 +943,7 @@ void EncapsulatedClient::compute(){ OLMsg::SetOnelabString(getName() + "/FullCmdLine", cmd, false); OLMsg::Info("Command line=<%s>",cmd.c_str()); - // the encapsulating localNetworkClient is called - if(!run()) + if(!run()) // localNetworkClient::run() is called OLMsg::Error("Invalid commandline <%s> for client <%s>", getCommandLine().c_str(), getName().c_str()); @@ -1059,7 +1060,7 @@ void RemoteNativeClient::analyze(){ std::string cmd,rmcmd; std::vector<std::string> choices; - OLMsg::Info("Analyze <%s> changed=%d", getName().c_str(), + OLMsg::Info("Analyzes <%s> changed=%d", getName().c_str(), onelab::server::instance()->getChanged(getName())); setAction("check"); @@ -1176,7 +1177,7 @@ void RemoteEncapsulatedClient::compute(){ mySystem("ssh " + getRemoteHost() + " '" + cdcmd + rmcmd + "'"); } - // the client command line is buit and stored in a onelab parameter + // the client command line is built and stored in a onelab parameter std::string cmd; cmd.assign("ssh " + getRemoteHost() + " '"); if(getRemoteDir().size()) @@ -1185,10 +1186,9 @@ void RemoteEncapsulatedClient::compute(){ cmd.append(" " + getString("Arguments") + " '"); OLMsg::SetOnelabString(getName()+"/FullCmdLine",cmd,false); - // the encapsulating localNetworkClient is called OLMsg::Info("Command line=<%s>",cmd.c_str()); - if(!run()) + if(!run()) // localNetworkClient::run() is called OLMsg::Error("Invalid commandline <%s> for client <%s>", getCommandLine().c_str(), getName().c_str()); diff --git a/contrib/onelab/OnelabClients.h b/contrib/onelab/OnelabClients.h index 9775d37e84b9fca30b4fff833a49bd747f3ce2ed..329297ee9253b4d30d9eb757381cc4c3ac1a97d6 100644 --- a/contrib/onelab/OnelabClients.h +++ b/contrib/onelab/OnelabClients.h @@ -23,12 +23,12 @@ static std::string localFileTag("_"); enum parseMode {REGISTER, ANALYZE, COMPUTE, EXIT}; #if defined(WIN32) -static char dirSep='\\'; +const char dirSep='\\'; static std::string cmdSep(" & "); static std::string removeCmd("del "); static std::string lsCmd("dir "); #else -static char dirSep='/'; +const char dirSep='/'; static std::string cmdSep(" ; "); static std::string removeCmd("rm -rf "); static std::string lsCmd("ls "); diff --git a/contrib/onelab/OnelabMessage.cpp b/contrib/onelab/OnelabMessage.cpp index e2774d0194cc296b9ff6ebf88bf2968dfed56787..df2d3f1f79827aedfaf926f21ccd7394ae3def66 100644 --- a/contrib/onelab/OnelabMessage.cpp +++ b/contrib/onelab/OnelabMessage.cpp @@ -18,7 +18,7 @@ int OLMsg::_commRank = 0; int OLMsg::_commSize = 1; -int OLMsg::_verbosity = 1; +int OLMsg::_verbosity = 4; // int OLMsg::_progressMeterStep = 10; // int OLMsg::_progressMeterCurrent = 0; // std::map<std::string, double> OLMsg::_timers; diff --git a/contrib/onelab/OnelabParser.cpp b/contrib/onelab/OnelabParser.cpp index 3a1efdd6248e29ad7e828dae43f7d8d3c1c2eb2d..86183f92d5e0339425712c7e3fc20476b1470d33 100644 --- a/contrib/onelab/OnelabParser.cpp +++ b/contrib/onelab/OnelabParser.cpp @@ -1627,6 +1627,7 @@ void MetaModel::client_sentence(const std::string &name, if(arguments.size()%4==0){ if(isTodo(REGISTER)){ // predefine the parameters to upload + // commented because it is better to require an explicit declaration // for(unsigned int i = 0; i < arguments.size(); i++){ // if(i%4==3){ // std::string str=resolveGetVal(arguments[i]); @@ -1658,7 +1659,7 @@ void MetaModel::client_sentence(const std::string &name, arguments.size(), action.c_str()); } else if(!action.compare("alwaysCompute")){ - if(isTodo(ANALYZE)){ + if(isTodo(REGISTER) || isTodo(ANALYZE)){ localSolverClient *c; if((c=findClientByName(name))){ c->compute(); @@ -1669,7 +1670,8 @@ void MetaModel::client_sentence(const std::string &name, } } else if(!action.compare("merge")){ - if(isTodo(COMPUTE) && !OLMsg::GetErrorCount() && (OLMsg::hasGmsh)){ + //if(isTodo(COMPUTE) && !OLMsg::GetErrorCount() && (OLMsg::hasGmsh)){ + if( arguments.size() && isTodo(COMPUTE) && !OLMsg::GetErrorCount() && (OLMsg::hasGmsh)){ std::vector<std::string> choices; for(unsigned int i = 0; i < arguments.size(); i++){ choices.push_back(resolveGetVal(arguments[i])); @@ -1684,7 +1686,7 @@ void MetaModel::client_sentence(const std::string &name, } } else if(!action.compare("frontPage")){ - if(OLMsg::hasGmsh){ + if( arguments.size() && OLMsg::hasGmsh ){ std::vector<std::string> choices; for(unsigned int i = 0; i < arguments.size(); i++){ choices.push_back(resolveGetVal(arguments[i])); @@ -1693,9 +1695,9 @@ void MetaModel::client_sentence(const std::string &name, if((c=findClientByName(name))) { if(isTodo(REGISTER) && !OLMsg::GetErrorCount()) if(onelab::server::instance()->getChanged(c->getName())){ - c->compute(); + //c->compute(); c->GmshMerge(choices); - OLMsg::SetOnelabNumber("Gmsh/NeedReloadGeom",1,false); + //OLMsg::SetOnelabNumber("Gmsh/NeedReloadGeom",1,false); //onelab::server::instance()->setChanged(false, c->getName()); } } diff --git a/contrib/onelab/metamodel.cpp b/contrib/onelab/metamodel.cpp index ff339bbdd2a8b83e7deea586d02e45b84d516527..20535cff22aa7a2157f58640d792b93eb440ec44 100644 --- a/contrib/onelab/metamodel.cpp +++ b/contrib/onelab/metamodel.cpp @@ -47,20 +47,21 @@ int metamodel(const std::string &action){ OLMsg::hasGmsh = OLMsg::GetOnelabNumber("IsMetamodel"); OLMsg::ResetErrorCounter(); - parseMode todo; - if(action == "compute") - todo = COMPUTE; - else{ - todo = ANALYZE; - } - std::string modelName = OLMsg::GetOnelabString("Arguments/FileName"); std::string workingDir = OLMsg::GetOnelabString("Arguments/WorkingDir"); std::string clientName = "meta"; MetaModel *myModel = new MetaModel("meta", workingDir, "meta", modelName); + + parseMode todo; + if(action == "compute") + todo = COMPUTE; + else{ + todo = ANALYZE; + } myModel->setTodo(todo); + if(OLMsg::GetErrorCount()) myModel->setTodo(EXIT); if(OLMsg::GetOnelabNumber("LOGFILES")){ std::string mystdout = FixWindowsQuotes(workingDir + "stdout.txt"); @@ -71,10 +72,8 @@ int metamodel(const std::string &action){ freopen(mystderr.c_str(),"w",stderr); } - if(OLMsg::GetErrorCount()) myModel->setTodo(EXIT); - if( myModel->isTodo(ANALYZE)){ - myModel->analyze(); + //myModel->analyze(); the constructor myModel makes the analysis } else if( myModel->isTodo(COMPUTE)){ myModel->compute(); diff --git a/contrib/onelab/python/OnelabClient.py b/contrib/onelab/python/OnelabClient.py index bcc4b236cba6dacfdbdfcf28f5e1f1f187a49414..a1af19b4471bd2214799cd5073445bc79cb60561 100755 --- a/contrib/onelab/python/OnelabClient.py +++ b/contrib/onelab/python/OnelabClient.py @@ -66,6 +66,7 @@ class client : _GMSH_PARSE_STRING = 21 _GMSH_PARAMETER = 23 _GMSH_PARAMETER_QUERY = 24 + _GMSH_CONNECT = 27 def _receive(self) : def buffered_receive(l) : @@ -110,6 +111,15 @@ class client : self._get_parameter(p) return p.value + def sub_client(self, name, command): + self._send(self._GMSH_CONNECT, name) + (t, msg) = self._receive() + print ("python receive : ", t, msg) + if t == self._GMSH_CONNECT and msg : + print "python launch : "+ command + " -onelab "+ msg + os.system(command + " -onelab " + name + " " + msg) + + def merge_file(self, filename) : if not self.socket : return