# Project name, upper case
STRING(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC)
-SET(${PROJECT_NAME_UC}_MAJOR_VERSION 7)
-SET(${PROJECT_NAME_UC}_MINOR_VERSION 7)
+SET(${PROJECT_NAME_UC}_MAJOR_VERSION 8)
+SET(${PROJECT_NAME_UC}_MINOR_VERSION 0)
SET(${PROJECT_NAME_UC}_PATCH_VERSION 0)
SET(${PROJECT_NAME_UC}_VERSION
${${PROJECT_NAME_UC}_MAJOR_VERSION}.${${PROJECT_NAME_UC}_MINOR_VERSION}.${${PROJECT_NAME_UC}_PATCH_VERSION})
IF(SALOME_BUILD_GUI)
# Graphviz
FIND_PACKAGE(SalomeGraphviz REQUIRED)
- # Qt4
- FIND_PACKAGE(SalomeQt4 REQUIRED COMPONENTS QtCore QtGui)
+ # Qt
+ IF(NOT SALOME_GUI_BUILD_WITH_QT5)
+ FIND_PACKAGE(SalomeQt4 REQUIRED COMPONENTS QtCore QtGui)
+ ELSE()
+ FIND_PACKAGE(SalomeQt5 REQUIRED)
+ ENDIF()
ENDIF(SALOME_BUILD_GUI)
##
# Ensure the variables are always defined for the configure:
SET(KERNEL_ROOT_DIR "${KERNEL_ROOT_DIR}")
SET(GUI_ROOT_DIR "${GUI_ROOT_DIR}")
-SET(QT4_ROOT_DIR "${QT4_ROOT_DIR}")
+IF(NOT SALOME_GUI_BUILD_WITH_QT5)
+ SET(QT_ROOT_DIR "${QT4_ROOT_DIR}")
+ELSE()
+ SET(QT_ROOT_DIR "${QT5_ROOT_DIR}")
+ENDIF()
SET(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/include" "${PROJECT_BINARY_DIR}/include")
# Build variables that will be expanded when configuring Salome<MODULE>Config.cmake:
-SALOME_CONFIGURE_PREPARE(Qt4)
+IF(NOT SALOME_GUI_BUILD_WITH_QT5)
+ SALOME_CONFIGURE_PREPARE(Qt4)
+ELSE()
+ SALOME_CONFIGURE_PREPARE(Qt5)
+ENDIF()
CONFIGURE_PACKAGE_CONFIG_FILE(${PROJECT_NAME}Config.cmake.in
${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}"
PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE_LOCAL CMAKE_INSTALL_PREFIX
- KERNEL_ROOT_DIR GUI_ROOT_DIR QT4_ROOT_DIR)
+ KERNEL_ROOT_DIR GUI_ROOT_DIR QT_ROOT_DIR)
# - in the install tree (VSR 16/08/2013: TEMPORARILY COMMENT THIS - TO REMOVE?):
# Get the relative path of the include directory so
# ${PROJECT_BINARY_DIR}/to_install/${PROJECT_NAME}Config.cmake
# INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}"
# PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE_LOCAL CMAKE_INSTALL_PREFIX
-# KERNEL_ROOT_DIR GUI_ROOT_DIR QT4_ROOT_DIR)
+# KERNEL_ROOT_DIR GUI_ROOT_DIR QT_ROOT_DIR)
WRITE_BASIC_PACKAGE_VERSION_FILE(${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
VERSION ${${PROJECT_NAME_UC}_VERSION}
ENDIF()
ENDIF()
-IF(NOT DEFINED NO_CXX11_SUPPORT)
- SET(NO_CXX11_SUPPORT ON)
-ENDIF()
IF(NOT NO_CXX11_SUPPORT)
# C++11 support
INCLUDE(CheckCXXCompilerFlag)
-e, --dump-on-error[=file] Stop on first error and dump state
-f, --dump-final[=file] dump final state
-g, --dump[=nbsec] dump state
+ -i, --init_port[=value] Initialisation value of a port, specified as
+ bloc.node.port=value.
-k, --kill-port=port Kill Salome application running on the specified
port if the driver process is killed (with SIGINT
or SIGTERM)
driver -g30 -fmystate.xml schema.xml
+Change the values of some input ports before execution
+----------------------------------------------------------------------
+::
+
+ driver -imynode.i=5 -imynode.d=.7 -imynode.b=False -imynode.s=lili schema.xml
+
+In this example, the ports "i", "d", "b" and "s" of the node "mynode" are initialized and the schema is launched.
+
+Only the ports of the following types can be initialized this way:
+
+ - int
+ - double
+ - bool
+ - string
How to manage several SALOME sessions
----------------------------------------------------------------------
bases
engine
runtime
+ pmml
yacsloader
yacsloader_swig
)
for(list<InputPort *>::iterator iter2=_setOfInputPort.begin();iter2!=_setOfInputPort.end();iter2++)
(*iter2)->exInit(start);
_inGate.exReset();
- if(_state == YACS::DISABLED)
- {
- exDisabledState(); // to refresh propagation of DISABLED state
- return;
- }
}
void ElementaryNode::init(bool start)
{
DEBTRACE("ElementaryNode::init " << getName() << " " << start << " " << _state);
initCommonPartWithoutStateManagement(start);
+ if(_state == YACS::DISABLED)
+ {
+ exDisabledState(); // to refresh propagation of DISABLED state
+ return ;
+ }
setState(YACS::READY);
}
//#define _DEVDEBUG_
#include "YacsTrace.hxx"
-int Executor::_maxThreads(50);
-size_t Executor::_threadStackSize(1048576); // Default thread stack size is 1MB
+int Executor::_maxThreads(1000);
+size_t Executor::_threadStackSize(262144); // Default thread stack size is 256 kB == 2**18 because threads launched by YACS are lightweight
Executor::Executor():_nbOfConcurrentThreads(0), _semForMaxThreads(_maxThreads),_keepGoingOnFail(false),_DPLScopeSensitive(false)
{
double val = atof(value.c_str());
inputPort->edInit(val);
}
+ break;
case Int:
{
int val = atoi(value.c_str());
inputPort->edInit(val);
}
+ break;
case String:
inputPort->edInit(value.c_str());
+ break;
case Bool:
{
- bool val = (! value.compare("False") ) && (! value.compare("0") );
- inputPort->edInit(val);
+ if((!value.compare("False")) || (!value.compare("false")))
+ inputPort->edInit(false);
+ else if ((!value.compare("True")) || (!value.compare("true")))
+ inputPort->edInit(true);
+ else
+ {
+ int val = atoi(value.c_str());
+ inputPort->edInit(val);
+ }
}
+ break;
default:
DEBTRACE("Proc::setInPortValue: filtered type: " << inputPort->edGetType()->kind());
}
YACSEvalSeqAny.hxx
YACSEvalResource.hxx
YACSEvalSession.hxx
+ YACSEvalSessionInternal.hxx
YACSEvalObserver.hxx
YACSEvalExecParams.hxx
)
YACSEvalSeqAny.cxx
YACSEvalResource.cxx
YACSEvalSession.cxx
+ YACSEvalSessionInternal.cxx
YACSEvalObserver.cxx
)
throw YACS::Exception("YACSEvalNonConstLocker::checkNonLocked : this is locked and trying to invoke non-const method !");
}
+void YACSEvalNonConstLocker::checkLocked() const
+{
+ if(!_isLocked)
+ throw YACS::Exception("YACSEvalNonConstLocker::checkLocked : this is NOT locked whereas it should be !");
+}
+
YACSEvalVirtualYACSContainer::YACSEvalVirtualYACSContainer():_gf(0),_cont(0)
{
}
if(_cont)
_cont->decrRef();
_cont=cont;
- _cont->incrRef();
+ if(_cont)
+ _cont->incrRef();
_propertyMap=listOfPropertiesInYACSContainer();
}
std::string YACSEvalVirtualYACSContainer::getValueOfKey(const char *key) const
{
+ std::string skey(key);
+ if(skey==HOSTNAME_KEY)
+ return _chosenHost;
std::map<std::string,std::string>::const_iterator it;
- it=_overloadedPropertyMap.find(key);
+ it=_overloadedPropertyMap.find(skey);
if(it!=_overloadedPropertyMap.end())
return (*it).second;
- it=_propertyMap.find(key);
+ it=_propertyMap.find(skey);
if(it!=_propertyMap.end())
return (*it).second;
return std::string();
void YACSEvalVirtualYACSContainer::setProperty(const std::string& key, const std::string &value)
{
checkNonLocked();
- _overloadedPropertyMap[key]=value;
+ if(key==HOSTNAME_KEY)
+ setWantedMachine(value);
+ else
+ _overloadedPropertyMap[key]=value;
}
-void YACSEvalVirtualYACSContainer::apply()
+void YACSEvalVirtualYACSContainer::apply(bool interactiveStatus)
{
YACS::ENGINE::SalomeContainer *cont0(dynamic_cast<YACS::ENGINE::SalomeContainer *>(_cont));
YACS::ENGINE::SalomeHPContainer *cont1(dynamic_cast<YACS::ENGINE::SalomeHPContainer *>(_cont));
- if(cont0)
- {
- cont0->setProperty(HOSTNAME_KEY,getValueOfKey(HOSTNAME_KEY));
- return ;
- }
- else if(cont1)
- {
- cont1->setProperty(HOSTNAME_KEY,getValueOfKey(HOSTNAME_KEY));
- return ;
- }
- else
+ if(!cont0 && !cont1)
throw YACS::Exception("YACSEvalVirtualYACSContainer::apply : unrecognized container !");
+ if(interactiveStatus)
+ _cont->setProperty(HOSTNAME_KEY,getValueOfKey(HOSTNAME_KEY));
+ else
+ {// in cluster mode no hostname and policy set to cycl by default
+ _cont->setProperty(HOSTNAME_KEY,std::string());
+ _cont->setProperty("policy","cycl");
+ }
+}
+
+std::string YACSEvalVirtualYACSContainer::getName() const
+{
+ checkNotNullYACSContainer();
+ return _cont->getName();
}
unsigned int YACSEvalVirtualYACSContainer::getValueOfKeyUInt(const char *key) const
return props;
}
+void YACSEvalVirtualYACSContainer::checkNotNullYACSContainer() const
+{
+ if(!_cont)
+ throw YACS::Exception("YACSEvalVirtualYACSContainer::checkNotNullYACSContainer : internal YACS container is NULL !");
+}
+
YACSEvalResource::~YACSEvalResource()
{
}
return const_cast<YACSEvalVirtualYACSContainer *>(&_containers[i]);
}
-void YACSEvalResource::apply()
+void YACSEvalResource::apply(bool interactiveStatus)
{
for(std::vector< YACSEvalVirtualYACSContainer >::iterator it=_containers.begin();it!=_containers.end();it++)
- (*it).apply();
+ (*it).apply(interactiveStatus);
}
void YACSEvalResource::fitWithCurrentCatalogAbs()
_containers[i].set(this,conts[i]);
}
+void YACSEvalParamsForCluster::setExclusiveness(bool newStatus)
+{
+ if(newStatus)
+ throw YACS::Exception("YACSEvalParamsForCluster::setExclusiveness : exclusive mode set to true is not implemented yet !");
+}
+
+void YACSEvalParamsForCluster::checkConsistency() const
+{
+ if(_remoteWorkingDir.empty())
+ throw YACS::Exception("YACSEvalParamsForCluster::checkConsistency : remote work dir is not set !");
+ if(_localWorkingDir.empty())
+ throw YACS::Exception("YACSEvalParamsForCluster::checkConsistency : local work dir is not set !");
+ if(_wcKey.empty())
+ throw YACS::Exception("YACSEvalParamsForCluster::checkConsistency : WC key is not set !");
+ if(_nbOfProcs==0)
+ throw YACS::Exception("YACSEvalParamsForCluster::checkConsistency : nb procs must be != 0 !");
+}
+
YACSEvalListOfResources::YACSEvalListOfResources(int maxLevOfPara, ResourcesManager_cpp *rm, const YACS::ENGINE::DeploymentTree& dt):_maxLevOfPara(maxLevOfPara),_rm(rm),_dt(new YACS::ENGINE::DeploymentTree(dt))
{
std::vector<YACS::ENGINE::Container *> conts(_dt->getAllContainers());
throw YACS::Exception(oss.str());
}
const ParserResourcesType& elt((*it2).second);
- status[ii]=(elt.ClusterInternalProtocol==sh || elt.ClusterInternalProtocol==rsh || elt.ClusterInternalProtocol==ssh);
+ status[ii]=(elt.Batch==none);
}
std::size_t trueRet(std::count(status.begin(),status.end(),true)),falseRet(std::count(status.begin(),status.end(),false));
if(trueRet==sz && falseRet==0)
unsigned int YACSEvalListOfResources::getNumberOfProcsDeclared() const
{
- std::vector<std::string> chosen(getAllChosenMachines());
- unsigned int ret(0);
- for(std::vector<std::string>::const_iterator it=chosen.begin();it!=chosen.end();it++)
- ret+=getNumberOfProcOfResource(*it);
- return ret;
+ if(isInteractive())
+ {
+ std::vector<std::string> chosen(getAllChosenMachines());
+ unsigned int ret(0);
+ for(std::vector<std::string>::const_iterator it=chosen.begin();it!=chosen.end();it++)
+ ret+=getNumberOfProcOfResource(*it);
+ return ret;
+ }
+ else
+ return _paramsInCaseOfCluster.getNbProcs();
+}
+
+void YACSEvalListOfResources::checkOKForRun() const
+{
+ if(!isInteractive())
+ _paramsInCaseOfCluster.checkConsistency();
}
void YACSEvalListOfResources::apply()
{
+ bool interactiveSt(isInteractive());
for(std::vector<YACSEvalResource *>::iterator it=_resources.begin();it!=_resources.end();it++)
- (*it)->apply();
+ (*it)->apply(interactiveSt);
}
YACSEvalListOfResources::~YACSEvalListOfResources()
throw YACS::Exception("YACSEvalListOfResources::notifyWantedMachine : internal error !");
const ParserResourcesType& oldPRT((*itOld).second);
const ParserResourcesType& newPRT((*itNew).second);
- if(oldPRT.ClusterInternalProtocol==newPRT.ClusterInternalProtocol)
+ bool oldISt(oldPRT.Batch==none),newISt(newPRT.Batch==none);//interactive status
+ if(oldISt==newISt)
return ;
// the batch/interactive mode has changed -> try to change for all.
std::queue<std::string> sts;
try
{
- for(std::vector<YACSEvalResource *>::const_iterator it=_resources.begin();it!=_resources.end();it++)
- {
- std::size_t sz((*it)->size());
- for(std::size_t i=0;i<sz;i++)
- {
- YACSEvalVirtualYACSContainer *cont((*it)->at(i));
- if(cont==sender)
- continue;
- sts.push(cont->findDefault(newPRT.ClusterInternalProtocol==sh));
- }
- }
+ if(newISt)
+ {// switching from interactive to batch -> In batch every YACSEvalVirtualYACSContainer instances in this must lie on newMachine.
+ for(std::vector<YACSEvalResource *>::const_iterator it=_resources.begin();it!=_resources.end();it++)
+ {
+ std::vector<std::string> fms((*it)->getAllFittingMachines());
+ std::vector<std::string>::iterator it0(std::find(fms.begin(),fms.end(),newMachine));
+ if(it0==fms.end())
+ {
+ std::ostringstream oss; oss << "In the context of switch to batch the requested cluster machine \"" << newMachine << "\" is not compatible for following list of containers : " << std::endl;
+ std::size_t sz((*it)->size());
+ for(std::size_t i=0;i<sz;i++)
+ {
+ YACSEvalVirtualYACSContainer *cont((*it)->at(i));
+ if(cont)
+ oss << " \"" << cont->getName() << "\", ";
+ }
+ throw YACS::Exception(oss.str());
+ }
+ std::size_t sz((*it)->size());
+ for(std::size_t i=0;i<sz;i++)
+ {
+ std::size_t sz((*it)->size());
+ for(std::size_t i=0;i<sz;i++)
+ {
+ YACSEvalVirtualYACSContainer *cont((*it)->at(i));
+ if(cont==sender)
+ continue;
+ sts.push(newMachine);
+ }
+ }
+ }
+ }
+ else
+ {
+ for(std::vector<YACSEvalResource *>::const_iterator it=_resources.begin();it!=_resources.end();it++)
+ {
+ std::size_t sz((*it)->size());
+ for(std::size_t i=0;i<sz;i++)
+ {
+ YACSEvalVirtualYACSContainer *cont((*it)->at(i));
+ if(cont==sender)
+ continue;
+ sts.push(cont->findDefault(false));
+ }
+ }
+ }
}
catch(YACS::Exception& e)
{
if(it==zeList.end())
throw YACS::Exception("YACSEvalListOfResources::hasRightInteractiveStatus : internal error !");
const ParserResourcesType& elt((*it).second);
- bool myStatus(elt.ClusterInternalProtocol==sh);
+ bool myStatus(elt.Batch==none);
return myStatus==isInteractive;
}
YACSEVALYFX_EXPORT void lock() { _isLocked=true; }
YACSEVALYFX_EXPORT bool isLocked() const { return _isLocked; }
YACSEVALYFX_EXPORT void checkNonLocked() const;
+ YACSEVALYFX_EXPORT void checkLocked() const;
private:
bool _isLocked;
};
YACSEVALYFX_EXPORT std::string getValueOfKey(const char *key) const;
YACSEVALYFX_EXPORT void setProperty(const std::string& key, const std::string &value);
YACSEVALYFX_EXPORT void resetOverloadedProps() { checkNonLocked(); _overloadedPropertyMap.clear(); }
- void apply();
+ YACSEVALYFX_EXPORT std::string getName() const;
+ void apply(bool interactiveStatus);
public:
YACSEvalVirtualYACSContainer();
void set(YACSEvalResource *gf, YACS::ENGINE::Container *cont);
unsigned int getNbProcPerNode() const { return getValueOfKeyUInt(NB_PROC_PER_NODE_KEY); }
unsigned int getValueOfKeyUInt(const char *key) const;
std::map<std::string,std::string> listOfPropertiesInYACSContainer() const;
+ void checkNotNullYACSContainer() const;
public:
static const char CONTAINER_NAME_KEY[];
static const char CPU_CLOCK_KEY[];
YACSEVALYFX_EXPORT void setWantedMachine(const std::string& machine);
YACSEVALYFX_EXPORT std::size_t size() const { return _containers.size(); }
YACSEVALYFX_EXPORT YACSEvalVirtualYACSContainer *at(std::size_t i) const;
- YACSEVALYFX_EXPORT void apply();
+ YACSEVALYFX_EXPORT void apply(bool interactiveStatus);
public:
void fitWithCurrentCatalogAbs();
void aggregate(ParserResourcesType& entry) const;
class ResourcesManager_cpp;
+class YACSEvalParamsForCluster
+{
+public:
+ YACSEvalParamsForCluster():_exclusiveness(false),_nbOfProcs(1) { }
+ bool getExclusiveness() const { return _exclusiveness; }
+ void setExclusiveness(bool newStatus);
+ std::string getRemoteWorkingDir() const { return _remoteWorkingDir; }
+ void setRemoteWorkingDir(const std::string& remoteWorkingDir) { _remoteWorkingDir=remoteWorkingDir; }
+ std::string getLocalWorkingDir() const { return _localWorkingDir; }
+ void setLocalWorkingDir(const std::string& localWorkingDir) { _localWorkingDir=localWorkingDir; }
+ std::string getWCKey() const { return _wcKey; }
+ void setWCKey(const std::string& wcKey) { _wcKey=wcKey; }
+ unsigned int getNbProcs() const { return _nbOfProcs; }
+ void setNbProcs(unsigned int nbProcs) { _nbOfProcs=nbProcs; }
+ void setMaxDuration(const std::string& maxDuration) { _maxDuration=maxDuration; }
+ std::string getMaxDuration() const { return _maxDuration; }
+ void checkConsistency() const;
+private:
+ bool _exclusiveness;
+ std::string _remoteWorkingDir;
+ std::string _localWorkingDir;
+ std::string _wcKey;
+ std::string _maxDuration;
+ unsigned int _nbOfProcs;
+};
+
class YACSEvalListOfResources : public YACSEvalNonConstLocker
{
public:
YACSEVALYFX_EXPORT YACSEvalResource *at(std::size_t i) const;
YACSEVALYFX_EXPORT bool isInteractive() const;
YACSEVALYFX_EXPORT unsigned int getNumberOfProcsDeclared() const;
+ YACSEVALYFX_EXPORT void checkOKForRun() const;
+ YACSEVALYFX_EXPORT YACSEvalParamsForCluster& getAddParamsForCluster() { return _paramsInCaseOfCluster; }
+ YACSEVALYFX_EXPORT const YACSEvalParamsForCluster& getAddParamsForCluster() const { return _paramsInCaseOfCluster; }
void apply();
YACSEVALYFX_EXPORT ~YACSEvalListOfResources();
public:
int _maxLevOfPara;
std::vector<YACSEvalResource *> _resources;
YACS::ENGINE::DeploymentTree *_dt;
+ YACSEvalParamsForCluster _paramsInCaseOfCluster;
};
#endif
// Author : Anthony Geay (EDF R&D)
#include "YACSEvalSession.hxx"
+#include "YACSEvalSessionInternal.hxx"
+
#include "Exception.hxx"
#include <Python.h>
const char YACSEvalSession::CORBA_CONFIG_ENV_VAR_NAME[]="OMNIORB_CONFIG";
-YACSEvalSession::YACSEvalSession():_isLaunched(false),_port(-1),_salomeInstanceModule(0),_salomeInstance(0)
+YACSEvalSession::YACSEvalSession():_isLaunched(false),_port(-1),_salomeInstanceModule(0),_salomeInstance(0),_internal(new YACSEvalSessionInternal)
{
if(!Py_IsInitialized())
Py_Initialize();
YACSEvalSession::~YACSEvalSession()
{
+ delete _internal;
if(isLaunched())
{
PyObject *terminateSession(PyObject_GetAttrString(_salomeInstance,const_cast<char *>("stop")));//new
class YACSEvalSession
{
+public:
+ class YACSEvalSessionInternal;
public:
YACSEVALYFX_EXPORT YACSEvalSession();
YACSEVALYFX_EXPORT ~YACSEvalSession();
YACSEVALYFX_EXPORT void checkLaunched() const;
YACSEVALYFX_EXPORT int getPort() const;
YACSEVALYFX_EXPORT std::string getCorbaConfigFileName() const;
+public:
+ YACSEvalSessionInternal *getInternal() { checkLaunched(); return _internal; }
private:
static std::string GetPathToAdd();
public:
std::string _corbaConfigFileName;
PyObject *_salomeInstanceModule;
PyObject *_salomeInstance;
+ YACSEvalSessionInternal *_internal;
};
#endif
--- /dev/null
+// Copyright (C) 2012-2016 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// Author : Anthony Geay (EDF R&D)
+
+#include "YACSEvalSessionInternal.hxx"
+#include "YACSEvalSession.hxx"
+
+#include "PyStdout.hxx"
+#include "AutoGIL.hxx"
+#include "Exception.hxx"
+
+YACSEvalSession::YACSEvalSessionInternal::YACSEvalSessionInternal():_orb(CORBA::ORB::_nil()),_sl(Engines::SalomeLauncher::_nil())
+{
+}
+
+void YACSEvalSession::YACSEvalSessionInternal::checkSalomeLauncher()
+{
+ if(CORBA::is_nil(_sl))
+ throw YACS::Exception("YACSEvalSessionInternal::checkSalomeLauncher : salome launcher is null !");
+}
+
+Engines::SalomeLauncher_var YACSEvalSession::YACSEvalSessionInternal::goFetchingSalomeLauncherInNS()
+{
+ if(!CORBA::is_nil(_sl))
+ return _sl;
+ int argc(0);
+ _orb=CORBA::ORB_init(argc,0);
+ if(CORBA::is_nil(_orb))
+ throw YACS::Exception("YACSEvalSessionInternal contrctor : ORB is null !");
+ //
+ const char methName[]="goFetchingSalomeLauncherInNS";
+ const char fetchPyCmd[]="import salome,CORBA\nsalome.salome_init()\nsl=salome.naming_service.Resolve(\"/SalomeLauncher\")\nif not CORBA.is_nil(sl):\n return salome.orb.object_to_string(sl)\nelse:\n raise Exception(\"Impossible to locate salome launcher !\")";
+ YACS::ENGINE::AutoPyRef func(YACS::ENGINE::evalPy(methName,fetchPyCmd));
+ YACS::ENGINE::AutoPyRef val(YACS::ENGINE::evalFuncPyWithNoParams(func));
+ std::string ior(PyString_AsString(val));
+ CORBA::Object_var obj(string_to_object(ior));
+ if(CORBA::is_nil(obj))
+ throw YACS::Exception("goFetchingSalomeLauncherInNS : fetched ior is NIL !");
+ _sl=Engines::SalomeLauncher::_narrow(obj);
+ checkSalomeLauncher();
+ return _sl;
+}
+
+Engines::SalomeLauncher_var YACSEvalSession::YACSEvalSessionInternal::getNotNullSL()
+{
+ checkSalomeLauncher();
+ return _sl;
+}
--- /dev/null
+// Copyright (C) 2012-2016 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// Author : Anthony Geay (EDF R&D)
+
+#ifndef __YACSEVALSESSIONINTERNAL_HXX__
+#define __YACSEVALSESSIONINTERNAL_HXX__
+
+#include "YACSEvalSession.hxx"
+
+#include "SALOMEconfig.h"
+#include CORBA_CLIENT_HEADER(SALOME_Launcher)
+#include "omniORB4/CORBA.h"
+
+#include <string>
+
+class YACSEvalSession::YACSEvalSessionInternal
+{
+public:
+ YACSEvalSessionInternal();
+ CORBA::Object_var string_to_object(const std::string& ior) { return _orb->string_to_object(ior.c_str()); }
+ Engines::SalomeLauncher_var goFetchingSalomeLauncherInNS();
+ Engines::SalomeLauncher_var getNotNullSL();
+private:
+ void checkSalomeLauncher();
+private:
+ CORBA::ORB_var _orb;
+ Engines::SalomeLauncher_var _sl;
+};
+
+#endif
#include <Python.h>
-class MyAutoThreadSaver
-{
-public:
- MyAutoThreadSaver():_save(PyEval_SaveThread()) { }
- ~MyAutoThreadSaver() { PyEval_RestoreThread(_save); }
-private:
- PyThreadState *_save;
-};
-
YACSEvalYFX *YACSEvalYFX::BuildFromFile(const std::string& xmlOfScheme)
{
YACS::ENGINE::RuntimeSALOME::setRuntime();
{
checkPortsForEvaluation(inputsOfInterest,outputsOfInterest);
_pattern->setOutPortsOfInterestForEvaluation(outputsOfInterest);
- _pattern->generateGraph();
}
void YACSEvalYFX::unlockAll()
bool YACSEvalYFX::run(YACSEvalSession *session, int& nbOfBranches)
{
- _pattern->assignRandomVarsInputs();
- YACSEvalListOfResources *rss(giveResources());
- if(!rss->isInteractive())
- throw YACS::Exception("YACSEvalYFX::run : not implemented yet for non interactive !");
- YACSEvalSession *mySession(session);
- YACS::AutoCppPtr<YACSEvalSession> loc;
+ _pattern->generateGraph();
if(!session)
{
throw YACS::Exception("YACSEvalYFX::run : input session in null !");
- /*loc=new YACSEvalSession;
- mySession=loc;*/
}
+ session->launch();
+ YACSEvalListOfResources *rss(giveResources());
+ rss->checkOKForRun();
+ _pattern->assignRandomVarsInputs();
rss->apply();
nbOfBranches=_pattern->assignNbOfBranches();
- mySession->launch();
- YACS::ENGINE::Executor exe;
- exe.setKeepGoingProperty(!_params.getStopASAPAfterErrorStatus());
- //
- _pattern->emitStart();
- {
- MyAutoThreadSaver locker;
- exe.RunW(getUndergroundGeneratedGraph());
- }
- return getUndergroundGeneratedGraph()->getState()==YACS::DONE;
+ return _pattern->go(_params.getStopASAPAfterErrorStatus(),session);
}
void YACSEvalYFX::registerObserver(YACSEvalObserver *observer)
#include "YACSEvalYFXPattern.hxx"
#include "YACSEvalResource.hxx"
#include "YACSEvalSeqAny.hxx"
+#include "YACSEvalSession.hxx"
#include "YACSEvalObserver.hxx"
+#include "YACSEvalSessionInternal.hxx"
#include "YACSEvalAutoPtr.hxx"
#include "ElementaryNode.hxx"
#include "PythonNode.hxx"
#include "InlineNode.hxx"
#include "ServiceNode.hxx"
+#include "PyStdout.hxx"
+#include "AutoGIL.hxx"
#include "ResourcesManager.hxx"
#include <sstream>
#include <iterator>
-const char YACSEvalYFXPattern::DFT_PROC_NAME[]="YFX";
+////
+#include <stdlib.h>
const char YACSEvalYFXPattern::ST_OK[]="ALL_OK";
const std::size_t YACSEvalYFXPattern::MAX_LGTH_OF_INP_DUMP=10000;
-const char YACSEvalYFXRunOnlyPattern::FIRST_FE_SUBNODE_NAME[]="Bloc";
+const char YACSEvalYFXGraphGen::DFT_PROC_NAME[]="YFX";
-const char YACSEvalYFXRunOnlyPattern::GATHER_NODE_NAME[]="__gather__";
+const char YACSEvalYFXGraphGen::FIRST_FE_SUBNODE_NAME[]="Bloc";
+
+const char YACSEvalYFXGraphGen::GATHER_NODE_NAME[]="__gather__";
+
+class MyAutoThreadSaver
+{
+public:
+ MyAutoThreadSaver():_save(PyEval_SaveThread()) { }
+ ~MyAutoThreadSaver() { PyEval_RestoreThread(_save); }
+private:
+ PyThreadState *_save;
+};
std::vector< YACSEvalInputPort *> YACSEvalYFXPattern::getFreeInputPorts() const
{
{
}
-YACS::ENGINE::TypeCode *YACSEvalYFXPattern::createSeqTypeCodeFrom(YACS::ENGINE::Proc *scheme, const std::string& zeType)
+YACS::ENGINE::TypeCode *YACSEvalYFXPattern::CreateSeqTypeCodeFrom(YACS::ENGINE::Proc *scheme, const std::string& zeType)
{
std::ostringstream oss; oss << "list[" << zeType << "]";
YACS::ENGINE::TypeCode *tc(scheme->getTypeCode(zeType));
/////////////////////
-YACSEvalYFXRunOnlyPattern::YACSEvalYFXRunOnlyPattern(YACSEvalYFX *boss, YACS::ENGINE::Proc *scheme, bool ownScheme, YACS::ENGINE::ComposedNode *runNode):YACSEvalYFXPattern(boss,scheme,ownScheme),_runNode(runNode),_generatedGraph(0),_FEInGeneratedGraph(0),_obs(new YACSEvalYFXRunOnlyPatternInternalObserver(this))
+YACSEvalYFXRunOnlyPattern::YACSEvalYFXRunOnlyPattern(YACSEvalYFX *boss, YACS::ENGINE::Proc *scheme, bool ownScheme, YACS::ENGINE::ComposedNode *runNode):YACSEvalYFXPattern(boss,scheme,ownScheme),_lockedStatus(false),_runNode(runNode),_gen(0),_obs(new YACSEvalYFXRunOnlyPatternInternalObserver(this))
{
if(!_runNode)
throw YACS::Exception("YACSEvalYFXRunOnlyPattern : internal run node must be not null !");
YACSEvalYFXRunOnlyPattern::~YACSEvalYFXRunOnlyPattern()
{
delete _obs;
+ delete _gen;
}
void YACSEvalYFXRunOnlyPattern::setOutPortsOfInterestForEvaluation(const std::vector<YACSEvalOutputPort *>& outputsOfInterest)
{
checkNonLocked();
_outputsOfInterest=outputsOfInterest;
+ _lockedStatus=true;
}
void YACSEvalYFXRunOnlyPattern::resetOutputsOfInterest()
{
checkLocked();
_outputsOfInterest.clear();
+ _lockedStatus=false;
}
void YACSEvalYFXRunOnlyPattern::generateGraph()
{
- static const char LISTPYOBJ_STR[]="list[pyobj]";
- if(_outputsOfInterest.empty())
- return ;
- YACS::ENGINE::RuntimeSALOME::setRuntime();
- YACS::ENGINE::RuntimeSALOME *r(YACS::ENGINE::getSALOMERuntime());
- _generatedGraph=r->createProc(DFT_PROC_NAME);
- YACS::ENGINE::TypeCode *pyobjTC(_generatedGraph->createInterfaceTc("python:obj:1.0","pyobj",std::list<YACS::ENGINE::TypeCodeObjref *>()));
- std::ostringstream oss; oss << "Loop_" << _runNode->getName();
- _generatedGraph->createType(YACSEvalAnyDouble::TYPE_REPR,"double");
- _generatedGraph->createType(YACSEvalAnyInt::TYPE_REPR,"int");
- //
- YACS::ENGINE::InlineNode *n0(r->createScriptNode(YACS::ENGINE::PythonNode::KIND,"__initializer__"));
- _generatedGraph->edAddChild(n0);
- YACS::ENGINE::TypeCode *listPyobjTC(_generatedGraph->createSequenceTc(LISTPYOBJ_STR,LISTPYOBJ_STR,pyobjTC));
- YACS::ENGINE::OutputPort *sender(n0->edAddOutputPort("sender",listPyobjTC));
- std::ostringstream var0;
- for(std::vector< YACSEvalInputPort >::const_iterator it=_inputs.begin();it!=_inputs.end();it++)
- {
- if((*it).isRandomVar())
- {
- var0 << (*it).getName() << ",";
- YACS::ENGINE::TypeCode *tc(createSeqTypeCodeFrom(_generatedGraph,(*it).getTypeOfData()));
- YACS::ENGINE::InputPort *inp(n0->edAddInputPort((*it).getName(),tc));
- YACS::ENGINE::InputPyPort *inpc(dynamic_cast<YACS::ENGINE::InputPyPort *>(inp));
- if(!inpc)
- throw YACS::Exception("YACSEvalYFXRunOnlyPattern::generateGraph : internal error 1 !");
- (*it).setUndergroundPortToBeSet(inpc);
- }
- }
- std::ostringstream n0Script; n0Script << "sender=zip(" << var0.str() << ")\n";
- n0->setScript(n0Script.str());
- //
- YACS::ENGINE::ForEachLoop *n1(r->createForEachLoop(oss.str(),pyobjTC));
- _FEInGeneratedGraph=n1;
- _generatedGraph->edAddChild(n1);
- _generatedGraph->edAddCFLink(n0,n1);
- _generatedGraph->edAddDFLink(sender,n1->edGetSeqOfSamplesPort());
- YACS::ENGINE::InlineNode *n2(r->createScriptNode(YACS::ENGINE::PythonNode::KIND,GATHER_NODE_NAME));
- _generatedGraph->edAddChild(n2);
- _generatedGraph->edAddCFLink(n1,n2);
- //
- YACS::ENGINE::Bloc *n10(r->createBloc(FIRST_FE_SUBNODE_NAME));
- n1->edAddChild(n10);
- YACS::ENGINE::InlineNode *n100(r->createScriptNode(YACS::ENGINE::PythonNode::KIND,"__dispatch__"));
- YACS::ENGINE::Node *n101(_runNode->cloneWithoutCompAndContDeepCpy(0,true));
- n10->edAddChild(n100);
- n10->edAddChild(n101);
- YACS::ENGINE::InputPort *dispatchIn(n100->edAddInputPort("i0",pyobjTC));
- n10->edAddCFLink(n100,n101);
- n1->edAddDFLink(n1->edGetSamplePort(),dispatchIn);
- std::ostringstream var1;
- for(std::vector< YACSEvalInputPort >::const_iterator it=_inputs.begin();it!=_inputs.end();it++)
- {
- if((*it).isRandomVar())
- {
- var1 << (*it).getName() << ",";
- YACS::ENGINE::OutputPort *myOut(n100->edAddOutputPort((*it).getName(),_generatedGraph->getTypeCode((*it).getTypeOfData())));
- std::string tmpPortName(_runNode->getInPortName((*it).getUndergroundPtr()));
- YACS::ENGINE::InputPort *myIn(n101->getInputPort(tmpPortName));
- n10->edAddDFLink(myOut,myIn);
- }
- }
- std::ostringstream n100Script; n100Script << var1.str() << "=i0\n";
- n100->setScript(n100Script.str());
- for(std::vector< YACSEvalOutputPort * >::const_iterator it=_outputsOfInterest.begin();it!=_outputsOfInterest.end();it++)
- {
- YACS::ENGINE::TypeCode *tc(createSeqTypeCodeFrom(_generatedGraph,(*it)->getTypeOfData()));
- YACS::ENGINE::InputPort *myIn(n2->edAddInputPort((*it)->getName(),tc));
- std::string tmpPortName(_runNode->getOutPortName((*it)->getUndergroundPtr()));
- YACS::ENGINE::OutputPort *myOut(n101->getOutputPort(tmpPortName));
- _generatedGraph->edAddDFLink(myOut,myIn);
- }
- _generatedGraph->updateContainersAndComponents();
+ delete _gen;
+ if(getResourcesInternal()->isInteractive())
+ _gen=new YACSEvalYFXGraphGenInteractive(this);
+ else
+ _gen=new YACSEvalYFXGraphGenCluster(this);
+ _gen->generateGraph();
}
void YACSEvalYFXRunOnlyPattern::resetGeneratedGraph()
{
- delete _generatedGraph;
- _generatedGraph=0;
- resetResources();
+ if(_gen)
+ _gen->resetGeneratedGraph();
}
int YACSEvalYFXRunOnlyPattern::assignNbOfBranches()
{
checkAlreadyComputedResources();
- if(!_generatedGraph)
- throw YACS::Exception("YACSEvalYFXRunOnlyPattern::assignNbOfBranches : the generated graph has not been created !");
- std::list<YACS::ENGINE::Node *> nodes(_generatedGraph->getChildren());
- YACS::ENGINE::ForEachLoop *zeMainNode(0);
- for(std::list<YACS::ENGINE::Node *>::const_iterator it=nodes.begin();it!=nodes.end();it++)
- {
- YACS::ENGINE::ForEachLoop *isZeMainNode(dynamic_cast<YACS::ENGINE::ForEachLoop *>(*it));
- if(isZeMainNode)
- {
- if(!zeMainNode)
- zeMainNode=isZeMainNode;
- else
- throw YACS::Exception("YACSEvalYFXRunOnlyPattern::assignNbOfBranches : internal error 1 !");
- }
- }
- if(!zeMainNode)
- throw YACS::Exception("YACSEvalYFXRunOnlyPattern::assignNbOfBranches : internal error 2 !");
- unsigned int nbProcsDeclared(getResourcesInternal()->getNumberOfProcsDeclared());
- nbProcsDeclared=std::max(nbProcsDeclared,4u);
- int nbOfBranch=1;
- if(getParallelizeStatus())
- {
- nbOfBranch=(nbProcsDeclared/getResourcesInternal()->getMaxLevelOfParallelism());
- nbOfBranch=std::max(nbOfBranch,1);
- }
- YACS::ENGINE::InputPort *zeInputToSet(zeMainNode->edGetNbOfBranchesPort());
- YACS::ENGINE::AnyInputPort *zeInputToSetC(dynamic_cast<YACS::ENGINE::AnyInputPort *>(zeInputToSet));
- if(!zeInputToSetC)
- throw YACS::Exception("YACSEvalYFXRunOnlyPattern::assignNbOfBranches : internal error 3 !");
- YACS::ENGINE::Any *a(YACS::ENGINE::AtomAny::New(nbOfBranch));
- zeInputToSetC->put(a);
- zeInputToSetC->exSaveInit();
- a->decrRef();
- return nbOfBranch;
+ if(!_gen)
+ throw YACS::Exception("YACSEvalYFXRunOnlyPattern::assignNbOfBranches : generator is NULL ! Please invoke generateGraph before !");
+ return _gen->assignNbOfBranches();
}
void YACSEvalYFXRunOnlyPattern::assignRandomVarsInputs()
bool YACSEvalYFXRunOnlyPattern::isLocked() const
{
- return _generatedGraph!=0;
+ return _lockedStatus;
}
YACSEvalListOfResources *YACSEvalYFXRunOnlyPattern::giveResources()
YACS::ENGINE::Proc *YACSEvalYFXRunOnlyPattern::getUndergroundGeneratedGraph() const
{
- return _generatedGraph;
+ return getGenerator()->getUndergroundGeneratedGraph();
}
std::string YACSEvalYFXRunOnlyPattern::getErrorDetailsInCaseOfFailure() const
if(st==ST_OK)
throw YACS::Exception("YACSEvalYFXRunOnlyPattern::getErrorDetailsInCaseOfFailure : The execution of scheme has been carried out to the end without any problem !");
// All the problem can only comes from foreach -> scan it
- YACS::ENGINE::ForEachLoop *fe(findTopForEach());
+ YACS::ENGINE::ForEachLoop *fe(getUndergroundForEach());
YACS::ENGINE::NodeStateNameMap nsm;
unsigned nbB(fe->getNumberOfBranchesCreatedDyn());
std::ostringstream oss;
for(unsigned j=0;j<nbB;j++)
{
- YACS::ENGINE::Node *nn(fe->getChildByNameExec(FIRST_FE_SUBNODE_NAME,j));
+ YACS::ENGINE::Node *nn(fe->getChildByNameExec(YACSEvalYFXGraphGen::FIRST_FE_SUBNODE_NAME,j));
YACS::ENGINE::Bloc *nnc(dynamic_cast<YACS::ENGINE::Bloc *>(nn));
if(!nnc)
throw YACS::Exception("YACSEvalYFXRunOnlyPattern::getErrorDetailsInCaseOfFailure : internal error 1 ! The direct son of main foreach is expected to be a Bloc !");
std::string YACSEvalYFXRunOnlyPattern::getStatusOfRunStr() const
{
- YACS::StatesForNode st(_generatedGraph->getState());
+ YACS::StatesForNode st(getUndergroundGeneratedGraph()->getState());
switch(st)
{
case YACS::READY:
std::vector<YACSEvalSeqAny *> YACSEvalYFXRunOnlyPattern::getResults() const
{
- if(_generatedGraph->getState()!=YACS::DONE)
- throw YACS::Exception("YACSEvalYFXRunOnlyPattern::getResults : the execution did not finished correctly ! getResults should not be called !");
- std::vector<YACSEvalSeqAny *> ret(_outputsOfInterest.size());
- YACS::ENGINE::Node *node(_generatedGraph->getChildByName(GATHER_NODE_NAME));
- YACS::ENGINE::PythonNode *nodeC(dynamic_cast<YACS::ENGINE::PythonNode *>(node));
- if(!nodeC)
- throw YACS::Exception("YACSEvalYFXRunOnlyPattern::getResults : internal error !");
- std::size_t ii(0);
- for(std::vector< YACSEvalOutputPort * >::const_iterator it=_outputsOfInterest.begin();it!=_outputsOfInterest.end();it++,ii++)
- {
- YACS::ENGINE::InPort *input(nodeC->getInPort((*it)->getName()));
- YACS::ENGINE::InputPyPort *inputC(dynamic_cast<YACS::ENGINE::InputPyPort *>(input));
- if(!inputC)
- {
- std::ostringstream oss; oss << "YACSEvalYFXRunOnlyPattern::getResults : internal error for input \"" << (*it)->getName() << "\"";
- throw YACS::Exception(oss.str());
- }
- ret[ii]=BuildValueInPort(inputC);
- }
- return ret;
+ return _gen->getResults();
}
/*!
*/
std::vector<YACSEvalSeqAny *> YACSEvalYFXRunOnlyPattern::getResultsInCaseOfFailure(std::vector<unsigned int>& passedIds) const
{
- YACS::StatesForNode st(_generatedGraph->getState());
+ YACS::StatesForNode st(getUndergroundGeneratedGraph()->getState());
if(st==YACS::DONE)
{
passedIds.clear();
return ret;
}
getStatusOfRunStr();// To check that the status is recognized.
- std::list<YACS::ENGINE::Node *> lns(_generatedGraph->edGetDirectDescendants());
- YACS::ENGINE::ForEachLoop *fe(findTopForEach());
+ std::list<YACS::ENGINE::Node *> lns(getUndergroundGeneratedGraph()->edGetDirectDescendants());
+ YACS::ENGINE::ForEachLoop *fe(getUndergroundForEach());
//
YACS::ENGINE::Executor exe;
std::vector<YACS::ENGINE::SequenceAny *> outputs;
{
YACS::ENGINE::OutputPort *p((*it1)->getUndergroundPtr());
std::string st(_runNode->getOutPortName(p));
- std::ostringstream oss; oss << FIRST_FE_SUBNODE_NAME << '.' << _runNode->getName() << '.' << st;
+ std::ostringstream oss; oss << YACSEvalYFXGraphGen::FIRST_FE_SUBNODE_NAME << '.' << _runNode->getName() << '.' << st;
st=oss.str();
YACS::ENGINE::ForEachLoop::InterceptorizeNameOfPort(st);
std::vector<std::string>::iterator it2(std::find(nameOfOutputs.begin(),nameOfOutputs.end(),st));
YACSEvalObserver *obs(getObserver());
if(!obs)
return ;
- obs->notifyNumberOfSamplesToEval(getBoss(),_FEInGeneratedGraph->getNbOfElementsToBeProcessed());
+ obs->notifyNumberOfSamplesToEval(getBoss(),getUndergroundForEach()->getNbOfElementsToBeProcessed());
+}
+
+bool YACSEvalYFXRunOnlyPattern::go(bool stopASAP, YACSEvalSession *session) const
+{
+ emitStart();
+ return getGenerator()->go(stopASAP,session);
+}
+
+YACS::ENGINE::ForEachLoop *YACSEvalYFXRunOnlyPattern::getUndergroundForEach() const
+{
+ return getGenerator()->getUndergroundForEach();
}
bool YACSEvalYFXRunOnlyPattern::IsMatching(YACS::ENGINE::Proc *scheme, YACS::ENGINE::ComposedNode *& runNode)
}
}
-YACS::ENGINE::ForEachLoop *YACSEvalYFXRunOnlyPattern::findTopForEach() const
+YACSEvalYFXGraphGen *YACSEvalYFXRunOnlyPattern::getGenerator() const
+{
+ if(!_gen)
+ throw YACS::Exception("getGenerator : generator is NULL !");
+ return _gen;
+}
+
+/////////////////////
+
+YACSEvalYFXGraphGen::YACSEvalYFXGraphGen(YACSEvalYFXRunOnlyPattern *boss):_boss(boss),_generatedGraph(0),_FEInGeneratedGraph(0)
+{
+ if(!_boss)
+ throw YACS::Exception("YACSEvalYFXGraphGen constructor : boss is NULL !");
+}
+
+YACSEvalYFXGraphGen::~YACSEvalYFXGraphGen()
+{
+ //delete _generatedGraph;// -> TODO : AGY why ?
+}
+
+void YACSEvalYFXGraphGen::resetGeneratedGraph()
+{
+ delete _generatedGraph;
+ _generatedGraph=0; _FEInGeneratedGraph=0;
+}
+
+bool YACSEvalYFXGraphGen::isLocked() const
{
- std::list<YACS::ENGINE::Node *> lns(_generatedGraph->edGetDirectDescendants());
- YACS::ENGINE::ForEachLoop *fe(0);
- for(std::list<YACS::ENGINE::Node *>::const_iterator it=lns.begin();it!=lns.end();it++)
+ return _generatedGraph!=0;
+}
+
+int YACSEvalYFXGraphGen::assignNbOfBranches()
+{
+ if(!_generatedGraph)
+ throw YACS::Exception("YACSEvalYFXGraphGen::assignNbOfBranches : the generated graph has not been created !");
+ std::list<YACS::ENGINE::Node *> nodes(_generatedGraph->getChildren());
+ YACS::ENGINE::ForEachLoop *zeMainNode(0);
+ for(std::list<YACS::ENGINE::Node *>::const_iterator it=nodes.begin();it!=nodes.end();it++)
+ {
+ YACS::ENGINE::ForEachLoop *isZeMainNode(dynamic_cast<YACS::ENGINE::ForEachLoop *>(*it));
+ if(isZeMainNode)
+ {
+ if(!zeMainNode)
+ zeMainNode=isZeMainNode;
+ else
+ throw YACS::Exception("YACSEvalYFXGraphGen::assignNbOfBranches : internal error 1 !");
+ }
+ }
+ if(!zeMainNode)
+ throw YACS::Exception("YACSEvalYFXGraphGen::assignNbOfBranches : internal error 2 !");
+ unsigned int nbProcsDeclared(getBoss()->getResourcesInternal()->getNumberOfProcsDeclared());
+ nbProcsDeclared=std::max(nbProcsDeclared,4u);
+ int nbOfBranch=1;
+ if(getBoss()->getParallelizeStatus())
{
- fe=dynamic_cast<YACS::ENGINE::ForEachLoop *>(*it);
- if(fe)
- break;
+ nbOfBranch=(nbProcsDeclared/getBoss()->getResourcesInternal()->getMaxLevelOfParallelism());
+ nbOfBranch=std::max(nbOfBranch,1);
}
- if(!fe)
- throw YACS::Exception("YACSEvalYFXRunOnlyPattern::findTopForEach : internal error 2 ! ForEach is not accessible !");
- return fe;
+ YACS::ENGINE::InputPort *zeInputToSet(zeMainNode->edGetNbOfBranchesPort());
+ YACS::ENGINE::AnyInputPort *zeInputToSetC(dynamic_cast<YACS::ENGINE::AnyInputPort *>(zeInputToSet));
+ if(!zeInputToSetC)
+ throw YACS::Exception("YACSEvalYFXGraphGen::assignNbOfBranches : internal error 3 !");
+ YACS::ENGINE::Any *a(YACS::ENGINE::AtomAny::New(nbOfBranch));
+ zeInputToSetC->put(a);
+ zeInputToSetC->exSaveInit();
+ a->decrRef();
+ return nbOfBranch;
+}
+
+void YACSEvalYFXGraphGenInteractive::generateGraph()
+{
+ if(_generatedGraph)
+ { delete _generatedGraph; _generatedGraph=0; _FEInGeneratedGraph=0; }
+ static const char LISTPYOBJ_STR[]="list[pyobj]";
+ if(getBoss()->getOutputsOfInterest().empty())
+ return ;
+ YACS::ENGINE::RuntimeSALOME::setRuntime();
+ YACS::ENGINE::RuntimeSALOME *r(YACS::ENGINE::getSALOMERuntime());
+ _generatedGraph=r->createProc(DFT_PROC_NAME);
+ YACS::ENGINE::TypeCode *pyobjTC(_generatedGraph->createInterfaceTc("python:obj:1.0","pyobj",std::list<YACS::ENGINE::TypeCodeObjref *>()));
+ std::ostringstream oss; oss << "Loop_" << getBoss()->getRunNode()->getName();
+ _generatedGraph->createType(YACSEvalAnyDouble::TYPE_REPR,"double");
+ _generatedGraph->createType(YACSEvalAnyInt::TYPE_REPR,"int");
+ //
+ YACS::ENGINE::InlineNode *n0(r->createScriptNode(YACS::ENGINE::PythonNode::KIND,"__initializer__"));
+ _generatedGraph->edAddChild(n0);
+ YACS::ENGINE::TypeCode *listPyobjTC(_generatedGraph->createSequenceTc(LISTPYOBJ_STR,LISTPYOBJ_STR,pyobjTC));
+ YACS::ENGINE::OutputPort *sender(n0->edAddOutputPort("sender",listPyobjTC));
+ std::ostringstream var0;
+ const std::vector< YACSEvalInputPort >& inputs(getBoss()->getInputs());
+ for(std::vector< YACSEvalInputPort >::const_iterator it=inputs.begin();it!=inputs.end();it++)
+ {
+ if((*it).isRandomVar())
+ {
+ var0 << (*it).getName() << ",";
+ YACS::ENGINE::TypeCode *tc(YACSEvalYFXPattern::CreateSeqTypeCodeFrom(_generatedGraph,(*it).getTypeOfData()));
+ YACS::ENGINE::InputPort *inp(n0->edAddInputPort((*it).getName(),tc));
+ YACS::ENGINE::InputPyPort *inpc(dynamic_cast<YACS::ENGINE::InputPyPort *>(inp));
+ if(!inpc)
+ throw YACS::Exception("YACSEvalYFXRunOnlyPattern::generateGraph : internal error 1 !");
+ (*it).setUndergroundPortToBeSet(inpc);
+ }
+ }
+ std::ostringstream n0Script; n0Script << "sender=zip(" << var0.str() << ")\n";
+ n0->setScript(n0Script.str());
+ //
+ YACS::ENGINE::ForEachLoop *n1(r->createForEachLoop(oss.str(),pyobjTC));
+ _FEInGeneratedGraph=n1;
+ _generatedGraph->edAddChild(n1);
+ _generatedGraph->edAddCFLink(n0,n1);
+ _generatedGraph->edAddDFLink(sender,n1->edGetSeqOfSamplesPort());
+ YACS::ENGINE::InlineNode *n2(r->createScriptNode(YACS::ENGINE::PythonNode::KIND,GATHER_NODE_NAME));
+ _generatedGraph->edAddChild(n2);
+ _generatedGraph->edAddCFLink(n1,n2);
+ //
+ YACS::ENGINE::Bloc *n10(r->createBloc(FIRST_FE_SUBNODE_NAME));
+ n1->edAddChild(n10);
+ YACS::ENGINE::InlineNode *n100(r->createScriptNode(YACS::ENGINE::PythonNode::KIND,"__dispatch__"));
+ YACS::ENGINE::ComposedNode *runNode(getBoss()->getRunNode());
+ YACS::ENGINE::Node *n101(runNode->cloneWithoutCompAndContDeepCpy(0,true));
+ n10->edAddChild(n100);
+ n10->edAddChild(n101);
+ YACS::ENGINE::InputPort *dispatchIn(n100->edAddInputPort("i0",pyobjTC));
+ n10->edAddCFLink(n100,n101);
+ n1->edAddDFLink(n1->edGetSamplePort(),dispatchIn);
+ std::ostringstream var1;
+ for(std::vector< YACSEvalInputPort >::const_iterator it=inputs.begin();it!=inputs.end();it++)
+ {
+ if((*it).isRandomVar())
+ {
+ var1 << (*it).getName() << ",";
+ YACS::ENGINE::OutputPort *myOut(n100->edAddOutputPort((*it).getName(),_generatedGraph->getTypeCode((*it).getTypeOfData())));
+ std::string tmpPortName(runNode->getInPortName((*it).getUndergroundPtr()));
+ YACS::ENGINE::InputPort *myIn(n101->getInputPort(tmpPortName));
+ n10->edAddDFLink(myOut,myIn);
+ }
+ }
+ std::ostringstream n100Script; n100Script << var1.str() << "=i0\n";
+ n100->setScript(n100Script.str());
+ const std::vector<YACSEvalOutputPort *>& outputsOfInt(getBoss()->getOutputsOfInterest());
+ for(std::vector< YACSEvalOutputPort * >::const_iterator it=outputsOfInt.begin();it!=outputsOfInt.end();it++)
+ {
+ YACS::ENGINE::TypeCode *tc(YACSEvalYFXPattern::CreateSeqTypeCodeFrom(_generatedGraph,(*it)->getTypeOfData()));
+ YACS::ENGINE::InputPort *myIn(n2->edAddInputPort((*it)->getName(),tc));
+ std::string tmpPortName(runNode->getOutPortName((*it)->getUndergroundPtr()));
+ YACS::ENGINE::OutputPort *myOut(n101->getOutputPort(tmpPortName));
+ _generatedGraph->edAddDFLink(myOut,myIn);
+ }
+ _generatedGraph->updateContainersAndComponents();
+}
+
+bool YACSEvalYFXGraphGenInteractive::go(bool stopASAP, YACSEvalSession *session) const
+{
+ YACS::ENGINE::Executor exe;
+ exe.setKeepGoingProperty(!stopASAP);
+ {
+ MyAutoThreadSaver locker;
+ exe.RunW(getUndergroundGeneratedGraph());
+ }
+ return getUndergroundGeneratedGraph()->getState()==YACS::DONE;
+}
+
+std::vector<YACSEvalSeqAny *> YACSEvalYFXGraphGenInteractive::getResults() const
+{
+ if(getUndergroundGeneratedGraph()->getState()!=YACS::DONE)
+ throw YACS::Exception("YACSEvalYFXRunOnlyPattern::getResults : the execution did not finished correctly ! getResults should not be called !");
+ const std::vector<YACSEvalOutputPort *>& outputsOfInt(getBoss()->getOutputsOfInterest());
+ std::vector<YACSEvalSeqAny *> ret(outputsOfInt.size());
+ YACS::ENGINE::Node *node(getUndergroundGeneratedGraph()->getChildByName(YACSEvalYFXGraphGen::GATHER_NODE_NAME));
+ YACS::ENGINE::PythonNode *nodeC(dynamic_cast<YACS::ENGINE::PythonNode *>(node));
+ if(!nodeC)
+ throw YACS::Exception("YACSEvalYFXRunOnlyPattern::getResults : internal error !");
+ std::size_t ii(0);
+ for(std::vector< YACSEvalOutputPort * >::const_iterator it=outputsOfInt.begin();it!=outputsOfInt.end();it++,ii++)
+ {
+ YACS::ENGINE::InPort *input(nodeC->getInPort((*it)->getName()));
+ YACS::ENGINE::InputPyPort *inputC(dynamic_cast<YACS::ENGINE::InputPyPort *>(input));
+ if(!inputC)
+ {
+ std::ostringstream oss; oss << "YACSEvalYFXRunOnlyPattern::getResults : internal error for input \"" << (*it)->getName() << "\"";
+ throw YACS::Exception(oss.str());
+ }
+ ret[ii]=YACSEvalYFXPattern::BuildValueInPort(inputC);
+ }
+ return ret;
+}
+
+////////////////////
+
+void YACSEvalYFXGraphGenCluster::generateGraph()
+{
+ if(_generatedGraph)
+ { delete _generatedGraph; _generatedGraph=0; _FEInGeneratedGraph=0; }
+ //
+ const char EFXGenFileName[]="EFXGenFileName";
+ const char EFXGenContent[]="import getpass,datetime,os\nn=datetime.datetime.now()\nreturn os.path.join(os.path.sep,\"tmp\",\"EvalYFX_%s_%s_%s.xml\"%(getpass.getuser(),n.strftime(\"%d%b%y\"),n.strftime(\"%H%M%S\")))";
+ const char EFXGenContent2[]="import getpass,datetime\nn=datetime.datetime.now()\nreturn \"EvalYFX_%s_%s_%s\"%(getpass.getuser(),n.strftime(\"%d%b%y\"),n.strftime(\"%H%M%S\"))";
+ //
+ YACS::ENGINE::AutoPyRef func(YACS::ENGINE::evalPy(EFXGenFileName,EFXGenContent));
+ YACS::ENGINE::AutoPyRef val(YACS::ENGINE::evalFuncPyWithNoParams(func));
+ _locSchemaFile=PyString_AsString(val);
+ func=YACS::ENGINE::evalPy(EFXGenFileName,EFXGenContent2);
+ val=YACS::ENGINE::evalFuncPyWithNoParams(func);
+ _jobName=PyString_AsString(val);
+ //
+ static const char LISTPYOBJ_STR[]="list[pyobj]";
+ if(getBoss()->getOutputsOfInterest().empty())
+ return ;
+ YACS::ENGINE::RuntimeSALOME::setRuntime();
+ YACS::ENGINE::RuntimeSALOME *r(YACS::ENGINE::getSALOMERuntime());
+ _generatedGraph=r->createProc(DFT_PROC_NAME);
+ YACS::ENGINE::TypeCode *pyobjTC(_generatedGraph->createInterfaceTc("python:obj:1.0","pyobj",std::list<YACS::ENGINE::TypeCodeObjref *>()));
+ std::ostringstream oss; oss << "Loop_" << getBoss()->getRunNode()->getName();
+ _generatedGraph->createType(YACSEvalAnyDouble::TYPE_REPR,"double");
+ _generatedGraph->createType(YACSEvalAnyInt::TYPE_REPR,"int");
+ //
+ YACS::ENGINE::InlineNode *n0(r->createScriptNode(YACS::ENGINE::PythonNode::KIND,"__initializer__"));
+ _generatedGraph->edAddChild(n0);
+ YACS::ENGINE::TypeCode *listPyobjTC(_generatedGraph->createSequenceTc(LISTPYOBJ_STR,LISTPYOBJ_STR,pyobjTC));
+ YACS::ENGINE::OutputPort *sender(n0->edAddOutputPort("sender",listPyobjTC));
+ std::ostringstream var0;
+ const std::vector< YACSEvalInputPort >& inputs(getBoss()->getInputs());
+ for(std::vector< YACSEvalInputPort >::const_iterator it=inputs.begin();it!=inputs.end();it++)
+ {
+ if((*it).isRandomVar())
+ {
+ var0 << (*it).getName() << ",";
+ YACS::ENGINE::TypeCode *tc(YACSEvalYFXPattern::CreateSeqTypeCodeFrom(_generatedGraph,(*it).getTypeOfData()));
+ YACS::ENGINE::InputPort *inp(n0->edAddInputPort((*it).getName(),tc));
+ YACS::ENGINE::InputPyPort *inpc(dynamic_cast<YACS::ENGINE::InputPyPort *>(inp));
+ if(!inpc)
+ throw YACS::Exception("YACSEvalYFXRunOnlyPattern::generateGraph : internal error 1 !");
+ (*it).setUndergroundPortToBeSet(inpc);
+ }
+ }
+ std::ostringstream n0Script; n0Script << "sender=zip(" << var0.str() << ")\n";
+ n0->setScript(n0Script.str());
+ //
+ YACS::ENGINE::ForEachLoop *n1(r->createForEachLoop(oss.str(),pyobjTC));
+ _FEInGeneratedGraph=n1;
+ _generatedGraph->edAddChild(n1);
+ _generatedGraph->edAddCFLink(n0,n1);
+ _generatedGraph->edAddDFLink(sender,n1->edGetSeqOfSamplesPort());
+ YACS::ENGINE::InlineNode *n2(r->createScriptNode(YACS::ENGINE::PythonNode::KIND,GATHER_NODE_NAME));
+ _generatedGraph->edAddChild(n2);
+ _generatedGraph->edAddCFLink(n1,n2);
+ //
+ YACS::ENGINE::Bloc *n10(r->createBloc(FIRST_FE_SUBNODE_NAME));
+ n1->edAddChild(n10);
+ YACS::ENGINE::InlineNode *n100(r->createScriptNode(YACS::ENGINE::PythonNode::KIND,"__dispatch__"));
+ YACS::ENGINE::ComposedNode *runNode(getBoss()->getRunNode());
+ YACS::ENGINE::Node *n101(runNode->cloneWithoutCompAndContDeepCpy(0,true));
+ n10->edAddChild(n100);
+ n10->edAddChild(n101);
+ YACS::ENGINE::InputPort *dispatchIn(n100->edAddInputPort("i0",pyobjTC));
+ n10->edAddCFLink(n100,n101);
+ n1->edAddDFLink(n1->edGetSamplePort(),dispatchIn);
+ std::ostringstream var1;
+ for(std::vector< YACSEvalInputPort >::const_iterator it=inputs.begin();it!=inputs.end();it++)
+ {
+ if((*it).isRandomVar())
+ {
+ var1 << (*it).getName() << ",";
+ YACS::ENGINE::OutputPort *myOut(n100->edAddOutputPort((*it).getName(),_generatedGraph->getTypeCode((*it).getTypeOfData())));
+ std::string tmpPortName(runNode->getInPortName((*it).getUndergroundPtr()));
+ YACS::ENGINE::InputPort *myIn(n101->getInputPort(tmpPortName));
+ n10->edAddDFLink(myOut,myIn);
+ }
+ }
+ std::ostringstream n100Script; n100Script << var1.str() << "=i0\n";
+ n100->setScript(n100Script.str());
+ const std::vector<YACSEvalOutputPort *>& outputsOfInt(getBoss()->getOutputsOfInterest());
+ std::ostringstream n2Script; n2Script << "zeRes=[";
+ for(std::vector< YACSEvalOutputPort * >::const_iterator it=outputsOfInt.begin();it!=outputsOfInt.end();it++)
+ {
+ YACS::ENGINE::TypeCode *tc(YACSEvalYFXPattern::CreateSeqTypeCodeFrom(_generatedGraph,(*it)->getTypeOfData()));
+ YACS::ENGINE::InputPort *myIn(n2->edAddInputPort((*it)->getName(),tc));
+ n2Script << (*it)->getName() << ", ";
+ std::string tmpPortName(runNode->getOutPortName((*it)->getUndergroundPtr()));
+ YACS::ENGINE::OutputPort *myOut(n101->getOutputPort(tmpPortName));
+ _generatedGraph->edAddDFLink(myOut,myIn);
+ }
+ n2Script << "]\nf=file(\"" << _jobName << "\",\"w\") ; f.write(str(zeRes)) ; del f";
+ n2->setScript(n2Script.str());
+ _generatedGraph->updateContainersAndComponents();
+}
+
+bool YACSEvalYFXGraphGenCluster::go(bool stopASAP, YACSEvalSession *session) const
+{
+ getUndergroundGeneratedGraph()->saveSchema(_locSchemaFile);
+ YACSEvalListOfResources *rss(getBoss()->getResourcesInternal());
+ const YACSEvalParamsForCluster& cli(rss->getAddParamsForCluster());
+ std::vector<std::string> machines(rss->getAllChosenMachines());
+ if(machines.size()!=1)
+ throw YACS::Exception("YACSEvalYFXGraphGenCluster::go : internal error ! In batch mode and not exactly one machine !");
+ Engines::SalomeLauncher_var sl(session->getInternal()->goFetchingSalomeLauncherInNS());
+ Engines::ResourceParameters rr;
+ rr.name=CORBA::string_dup(machines[0].c_str());
+ rr.hostname=CORBA::string_dup("");
+ rr.can_launch_batch_jobs=true;
+ rr.can_run_containers=true;
+ rr.OS=CORBA::string_dup("Linux");
+ rr.componentList.length(0);
+ rr.nb_proc=rss->getNumberOfProcsDeclared();// <- important
+ rr.mem_mb=1024;
+ rr.cpu_clock=1000;
+ rr.nb_node=1;// useless only nb_proc used.
+ rr.nb_proc_per_node=1;// useless only nb_proc used.
+ rr.policy=CORBA::string_dup("cycl");
+ rr.resList.length(0);
+ Engines::JobParameters jp;
+ jp.job_name=CORBA::string_dup(_jobName.c_str());
+ jp.job_type=CORBA::string_dup("yacs_file");
+ jp.job_file=CORBA::string_dup(_locSchemaFile.c_str());
+ jp.env_file=CORBA::string_dup("");
+ jp.in_files.length(0);
+ jp.out_files.length(1);
+ jp.out_files[0]=CORBA::string_dup(_jobName.c_str());
+ jp.work_directory=CORBA::string_dup(cli.getRemoteWorkingDir().c_str());
+ jp.local_directory=CORBA::string_dup(cli.getLocalWorkingDir().c_str());
+ jp.result_directory=CORBA::string_dup(cli.getLocalWorkingDir().c_str());
+ jp.maximum_duration=CORBA::string_dup(cli.getMaxDuration().c_str());
+ jp.resource_required=rr;
+ jp.queue=CORBA::string_dup("");
+ jp.exclusive=false;
+ jp.mem_per_cpu=rr.mem_mb;
+ jp.wckey=CORBA::string_dup(cli.getWCKey().c_str());
+ jp.extra_params=CORBA::string_dup("");
+ jp.specific_parameters.length(0);
+ jp.launcher_file=CORBA::string_dup("");
+ jp.launcher_args=CORBA::string_dup("");
+ _jobid=sl->createJob(jp);
+ sl->launchJob(_jobid);
+ bool ret(false);
+ while(true)
+ {
+ PyRun_SimpleString("import time ; time.sleep(10)");
+ char *state(sl->getJobState(_jobid));//"CREATED", "IN_PROCESS", "QUEUED", "RUNNING", "PAUSED", "FINISHED" or "FAILED"
+ std::string sstate(state);
+ CORBA::string_free(state);
+ if(sstate=="FINISHED" || sstate=="FAILED")
+ {
+ ret=sstate=="FINISHED";
+ break;
+ }
+ }
+ sl->getJobResults(_jobid,cli.getLocalWorkingDir().c_str());
+ //
+ try
+ {
+ std::ostringstream oss; oss << "import os" << std::endl << "p=os.path.join(\"" << cli.getLocalWorkingDir() << "\",\"" << _jobName << "\")" << std::endl;
+ oss << "if not os.path.exists(p):\n return None\n";
+ oss << "f=file(p,\"r\")" << std::endl;
+ oss << "return eval(f.read())";
+ std::string zeInput(oss.str());
+ YACS::ENGINE::AutoPyRef func(YACS::ENGINE::evalPy("fetch",zeInput));
+ YACS::ENGINE::AutoPyRef val(YACS::ENGINE::evalFuncPyWithNoParams(func));
+ if(!PyList_Check(val))
+ throw YACS::Exception("Fetched file does not contain a list !");
+ Py_ssize_t sz(PyList_Size(val));
+ _res.resize(sz);
+ for(Py_ssize_t i=0;i<sz;i++)
+ {
+ std::vector<double>& res0(_res[i]);
+ PyObject *elt0(PyList_GetItem(val,i));
+ if(!PyList_Check(elt0))
+ throw YACS::Exception("Fetched file does contain a list of list !");
+ Py_ssize_t sz0(PyList_Size(elt0)); res0.resize(sz0);
+ for(Py_ssize_t j=0;j<sz0;j++)
+ {
+ PyObject *elt1(PyList_GetItem(elt0,j));
+ res0[j]=PyFloat_AsDouble(elt1);
+ }
+ }
+ // cleanup
+ std::ostringstream oss1; oss1 << "import os" << std::endl << "p=os.path.join(\"" << cli.getLocalWorkingDir() << "\",\"" << _jobName << "\") ; os.remove(p)" << std::endl;
+ std::string s1(oss1.str());
+ PyRun_SimpleString(s1.c_str());
+ std::ostringstream oss2; oss2 << "import os,shutil" << std::endl << "p=os.path.join(\"" << cli.getLocalWorkingDir() << "\",\"logs\") ; shutil.rmtree(p)" << std::endl;
+ std::string s2(oss2.str());
+ PyRun_SimpleString(s2.c_str());
+ }
+ catch(YACS::Exception& e)
+ {
+ _errors=e.what();
+ return false;
+ }
+ //
+ return ret;
+}
+
+std::vector<YACSEvalSeqAny *> YACSEvalYFXGraphGenCluster::getResults() const
+{
+ std::size_t sz(_res.size());
+ std::vector<YACSEvalSeqAny *> ret(sz);
+ for(std::size_t i=0;i<sz;i++)
+ {
+ YACS::AutoCppPtr<YACSEvalSeqAnyDouble> elt(new YACSEvalSeqAnyDouble(_res[i]));
+ ret[i]=elt.dettach();
+ }
+ return ret;
}
}
class YACSEvalYFX;
+class YACSEvalSession;
class YACSEvalObserver;
class YACSEvalListOfResources;
class ResourcesManager_cpp;
void registerObserver(YACSEvalObserver *observer);
YACSEvalObserver *getObserver() const { return _observer; }
YACSEvalYFX *getBoss() const { return _boss; }
+ YACSEvalListOfResources *getResourcesInternal() const { return _res; }
virtual void setOutPortsOfInterestForEvaluation(const std::vector<YACSEvalOutputPort *>& outputs) = 0;
virtual void resetOutputsOfInterest() = 0;
virtual void generateGraph() = 0;
virtual std::string getStatusOfRunStr() const = 0;
virtual std::vector<YACSEvalSeqAny *> getResults() const = 0;
virtual std::vector<YACSEvalSeqAny *> getResultsInCaseOfFailure(std::vector<unsigned int>& passedIds) const = 0;
- virtual void emitStart() const = 0;
-public:
- static const char DFT_PROC_NAME[];
+ virtual bool go(bool stopASAP, YACSEvalSession *session) const = 0;
+public://for _gen
+ const std::vector< YACSEvalInputPort >& getInputs() const { return _inputs; }
+ static YACS::ENGINE::TypeCode *CreateSeqTypeCodeFrom(YACS::ENGINE::Proc *scheme, const std::string& zeType);
+ static YACSEvalSeqAny *BuildValueInPort(YACS::ENGINE::InputPyPort *port);
protected:
YACSEvalYFXPattern(YACSEvalYFX *boss, YACS::ENGINE::Proc *scheme, bool ownScheme);
- YACS::ENGINE::TypeCode *createSeqTypeCodeFrom(YACS::ENGINE::Proc *scheme, const std::string& zeType);
void setResources(YACSEvalListOfResources *res);
void resetResources();
- YACSEvalListOfResources *getResourcesInternal() const { return _res; }
ResourcesManager_cpp *getCatalogInAppli() const { return _rm; }
- static YACSEvalSeqAny *BuildValueInPort(YACS::ENGINE::InputPyPort *port);
static YACSEvalSeqAny *BuildValueFromEngineFrmt(YACS::ENGINE::SequenceAny *data);
private:
void cleanScheme();
static const std::size_t MAX_LGTH_OF_INP_DUMP;
};
+class YACSEvalYFXGraphGen;
+
class YACSEvalYFXRunOnlyPattern : public YACSEvalYFXPattern
{
public:
std::string getStatusOfRunStr() const;
std::vector<YACSEvalSeqAny *> getResults() const;
std::vector<YACSEvalSeqAny *> getResultsInCaseOfFailure(std::vector<unsigned int>& passedIds) const;
- void emitStart() const;
+ bool go(bool stopASAP, YACSEvalSession *session) const;
//
- YACS::ENGINE::ForEachLoop *getUndergroundForEach() const { return _FEInGeneratedGraph; }
+ YACS::ENGINE::ForEachLoop *getUndergroundForEach() const;
static bool IsMatching(YACS::ENGINE::Proc *scheme, YACS::ENGINE::ComposedNode *& runNode);
-public:
- static const char FIRST_FE_SUBNODE_NAME[];
- static const char GATHER_NODE_NAME[];
private:
+ void emitStart() const;
void buildInputPorts();
void buildOutputPorts();
- YACS::ENGINE::ForEachLoop *findTopForEach() const;
+ YACSEvalYFXGraphGen *getGenerator() const;
+public://for _gen
+ const std::vector<YACSEvalOutputPort *>& getOutputsOfInterest() const { return _outputsOfInterest; }
+ YACS::ENGINE::ComposedNode *getRunNode() const { return _runNode; }
private:
+ bool _lockedStatus;
YACS::ENGINE::ComposedNode *_runNode;
std::vector<YACSEvalOutputPort *> _outputsOfInterest;
+ YACSEvalYFXGraphGen *_gen;
+ YACSEvalYFXRunOnlyPatternInternalObserver *_obs;
+};
+
+class YACSEvalYFXGraphGen
+{
+protected:
+ YACSEvalYFXGraphGen(YACSEvalYFXRunOnlyPattern *boss);
+ YACSEvalYFXRunOnlyPattern *getBoss() const { return _boss; }
+public:
+ virtual ~YACSEvalYFXGraphGen();
+ virtual void generateGraph() = 0;
+ virtual bool go(bool stopASAP, YACSEvalSession *session) const = 0;
+ virtual std::vector<YACSEvalSeqAny *> getResults() const = 0;
+ bool isLocked() const;
+ int assignNbOfBranches();
+ void resetGeneratedGraph();
+ YACS::ENGINE::Proc *getUndergroundGeneratedGraph() const { return _generatedGraph; }
+ YACS::ENGINE::ForEachLoop *getUndergroundForEach() const { return _FEInGeneratedGraph; }
+private:
+ YACSEvalYFXRunOnlyPattern *_boss;
+protected:
YACS::ENGINE::Proc *_generatedGraph;
YACS::ENGINE::ForEachLoop *_FEInGeneratedGraph;
- YACSEvalYFXRunOnlyPatternInternalObserver *_obs;
+public:
+ static const char DFT_PROC_NAME[];
+ static const char FIRST_FE_SUBNODE_NAME[];
+ static const char GATHER_NODE_NAME[];
+};
+
+class YACSEvalYFXGraphGenInteractive : public YACSEvalYFXGraphGen
+{
+public:
+ YACSEvalYFXGraphGenInteractive(YACSEvalYFXRunOnlyPattern *boss):YACSEvalYFXGraphGen(boss) { }
+ void generateGraph();
+ bool go(bool stopASAP, YACSEvalSession *session) const;
+ std::vector<YACSEvalSeqAny *> getResults() const;
+};
+
+class YACSEvalYFXGraphGenCluster : public YACSEvalYFXGraphGen
+{
+public:
+ YACSEvalYFXGraphGenCluster(YACSEvalYFXRunOnlyPattern *boss):YACSEvalYFXGraphGen(boss) { }
+ void generateGraph();
+ bool go(bool stopASAP, YACSEvalSession *session) const;
+ std::vector<YACSEvalSeqAny *> getResults() const;
+private:
+ std::string _locSchemaFile;
+ std::string _jobName;
+ mutable int _jobid;
+ mutable std::string _errors;
+ mutable std::vector< std::vector<double> > _res;
};
#endif
std::vector<std::string> listOfPropertyKeys() const;
std::string getValueOfKey(const char *key) const;
void setProperty(const std::string& key, const std::string &value);
+ std::string getName() const;
private:
YACSEvalVirtualYACSContainer();
};
YACSEvalResource();
};
+class YACSEvalParamsForCluster
+{
+public:
+ bool getExclusiveness() const;
+ void setExclusiveness(bool newStatus);
+ std::string getRemoteWorkingDir();
+ void setRemoteWorkingDir(const std::string& remoteWorkingDir);
+ std::string getLocalWorkingDir();
+ void setLocalWorkingDir(const std::string& localWorkingDir);
+ std::string getWCKey() const;
+ void setWCKey(const std::string& wcKey);
+ unsigned int getNbProcs() const;
+ void setNbProcs(unsigned int nbProcs);
+ void setMaxDuration(const std::string& maxDuration);
+ std::string getMaxDuration() const;
+ void checkConsistency() const;
+private:
+ YACSEvalParamsForCluster();
+};
+
class YACSEvalListOfResources
{
public:
bool isInteractive() const;
YACSEvalResource *at(std::size_t i) const;
unsigned int getNumberOfProcsDeclared() const;
+ void checkOKForRun() const;
+ YACSEvalParamsForCluster& getAddParamsForCluster();
%extend
{
std::size_t __len__() const
efx.lockPortsForEvaluation(inps,outps)
rss=efx.giveResources()
rss[0][0].setWantedMachine("localhost")
+assert(rss.isInteractive())
a,b=efx.run(session) ; assert(a)
efx.unlockAll()
for ii,inp in enumerate(inps):
efx.lockPortsForEvaluation(inps,outps)
rss=efx.giveResources()
rss[0][0].setWantedMachine("localhost")
+assert(rss.isInteractive())
a,b=efx.run(session)
assert(efx.getStatusOfRunStr()=='SOME_SAMPLES_FAILED_AND_ALL_OF_THEM_FAILED_DETERMINISTICALLY')
c,d=efx.getResultsInCaseOfFailure()
--- /dev/null
+# Copyright (C) 2015-2016 CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+# first test using cluster
+
+import os,getpass
+
+CatalogResources="""<?xml version="1.0"?>
+<resources>
+ <machine name="localhost" hostname="dsp0698184" type="single_machine" appliPath="" batchQueue="" userCommands="" protocol="ssh" iprotocol="ssh" workingDirectory="" canLaunchBatchJobs="false" canRunContainers="true" batch="none" mpi="no mpi" userName="" OS="" memInMB="0" CPUFreqMHz="0" nbOfNodes="1" nbOfProcPerNode="4"/>
+ <machine name="athos" hostname="athos" type="cluster" appliPath="/home/H87074/ATHOS_V771/appli_V7_7_1" batchQueue="" userCommands="" protocol="ssh" iprotocol="ssh" workingDirectory="" canLaunchBatchJobs="true" canRunContainers="false" batch="slurm" mpi="no mpi" userName="" OS="" memInMB="0" CPUFreqMHz="0" nbOfNodes="250" nbOfProcPerNode="28"/>
+</resources>"""
+
+def buildScheme(fname):
+ import SALOMERuntime
+ import loader
+ SALOMERuntime.RuntimeSALOME.setRuntime()
+ r=SALOMERuntime.getSALOMERuntime()
+ p0=r.createProc("run")
+ #
+ p=r.createBloc("toto")
+ p0.edAddChild(p)
+ #
+ cont=p0.createContainer("MyWonderfulContainer","Salome")
+ td=p0.createType("double","double")
+ n0=r.createScriptNode("Salome","PyScript0")
+ p.edAddChild(n0)
+ q=n0.edAddInputPort("q",td)
+ ep=n0.edAddOutputPort("ep",td)
+ n0.setScript("ep=1./(4.-q)") # <- force division by 0
+ n0.setExecutionMode("remote")
+ n0.setContainer(cont)
+ p0.saveSchema(fname)
+ pass
+
+fname="test3.xml"
+import evalyfx
+session=evalyfx.YACSEvalSession()
+session.launch()
+buildScheme(fname)
+efx=evalyfx.YACSEvalYFX.BuildFromFile(fname)
+efx.getParams().setStopASAPAfterErrorStatus(False)
+inps=efx.getFreeInputPorts()
+assert(len(inps)==1)
+outps=efx.getFreeOutputPorts()
+inps[0].setSequenceOfValuesToEval([-7.,2.,3.,5.,6.])
+efx.lockPortsForEvaluation(inps,outps)
+#
+rss=efx.giveResources()
+rss[0][0].setWantedMachine("athos")
+cp=rss.getAddParamsForCluster() ; cp.setRemoteWorkingDir(os.path.join("/scratch",getpass.getuser(),"TMP3")) ; cp.setLocalWorkingDir(os.path.join(os.path.expanduser("~"),"TMP52"))
+cp.setWCKey("P11U50:CARBONES") ; cp.setNbProcs(5) ; cp.setMaxDuration("00:05")
+assert(not rss.isInteractive())
+a,b=efx.run(session)
+print("************",a,b)
+print efx.getResults()
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
+INCLUDE(UseQtExt)
+
# --- options ---
# additional include directories
)
# header files / uic wrappings
-QT4_WRAP_UI(_uic_HEADERS ${_uic_files})
+QT_WRAP_UIC(_uic_HEADERS ${_uic_files})
# --- sources ---
# sources / moc wrappings
-QT4_WRAP_CPP(_moc_SOURCES ${_moc_HEADERS})
+QT_WRAP_MOC(_moc_SOURCES ${_moc_HEADERS})
SET(GenericGui_SOURCES
GenericGuiExport.hxx
FILE(COPY ${PROJECT_SOURCE_DIR}/src/pmml/Test/samples DESTINATION . )
INSTALL(TARGETS TestPMML DESTINATION ${SALOME_INSTALL_BINS})
+
+#
+
+SET(LOCAL_TEST_DIR ${SALOME_YACS_INSTALL_TEST}/pmml)
+FILE(COPY ${PROJECT_SOURCE_DIR}/src/pmml/Test/samples DESTINATION "${CMAKE_INSTALL_PREFIX}/${LOCAL_TEST_DIR}")
+INSTALL(TARGETS TestPMML DESTINATION ${LOCAL_TEST_DIR})
+INSTALL(FILES CTestTestfileInstall.cmake DESTINATION ${LOCAL_TEST_DIR} RENAME CTestTestfile.cmake)
--- /dev/null
+# Copyright (C) 2015-2016 CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+IF(NOT WIN32)
+ ADD_TEST(YacsTestPMML TestPMML)
+ SET_TESTS_PROPERTIES(YacsTestPMML PROPERTIES LABELS "${COMPONENT_NAME}")
+ ADD_TEST(YacsPMMLBasicsTest python pmml_swig/PMMLBasicsTestLauncher.py)
+ SET_TESTS_PROPERTIES(YacsPMMLBasicsTest PROPERTIES LABELS "${COMPONENT_NAME}")
+ENDIF(NOT WIN32)
SALOME_GENERATE_TESTS_ENVIRONMENT(tests_env)
ADD_TEST(PMMLBasicsTest ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/PMMLBasicsTest.py)
SET_TESTS_PROPERTIES(PMMLBasicsTest PROPERTIES ENVIRONMENT "${tests_env}")
+
+#
+
+SET(LOCAL_TEST_DIR ${SALOME_YACS_INSTALL_TEST}/pmml/pmml_swig)
+FILE(COPY ${CMAKE_CURRENT_SOURCE_DIR}/PMMLBasicsTest.py DESTINATION "${CMAKE_INSTALL_PREFIX}/${LOCAL_TEST_DIR}")
+FILE(COPY ${CMAKE_CURRENT_SOURCE_DIR}/PMMLBasicsTestLauncher.py DESTINATION "${CMAKE_INSTALL_PREFIX}/${LOCAL_TEST_DIR}")
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2016 CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+import os,sys,subprocess,shutil
+
+# Here the most beautiful part of test :)
+dirALaCon0="Test"
+dirAlaCon1="samples"
+if not os.path.exists(dirALaCon0):
+ os.mkdir(dirALaCon0)
+if not os.path.exists(os.path.join(dirALaCon0,dirAlaCon1)):
+ os.chdir(dirALaCon0)
+ os.symlink(os.path.join("..",dirAlaCon1),dirAlaCon1)
+ os.chdir("..")
+# GO !
+dn=os.path.dirname(__file__)
+p=subprocess.Popen(["python","PMMLBasicsTest.py"],cwd=dn,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
+a,b=p.communicate()
+ret=p.returncode
+# Clean up the wonderful first part stuf
+shutil.rmtree(dirALaCon0)
+sys.exit(ret)
private:
PyGILState_STATE _gstate;
};
+
+ class AutoPyRef
+ {
+ public:
+ AutoPyRef(PyObject *pyobj=0):_pyobj(pyobj) { }
+ ~AutoPyRef() { release(); }
+ AutoPyRef(const AutoPyRef& other):_pyobj(other._pyobj) { if(_pyobj) Py_XINCREF(_pyobj); }
+ AutoPyRef& operator=(const AutoPyRef& other) { if(_pyobj==other._pyobj) return *this; release(); _pyobj=other._pyobj; Py_XINCREF(_pyobj); return *this; }
+ operator PyObject *() { return _pyobj; }
+ void set(PyObject *pyobj) { if(pyobj==_pyobj) return ; release(); _pyobj=pyobj; }
+ PyObject *get() { return _pyobj; }
+ bool isNull() const { return _pyobj==0; }
+ PyObject *retn() { if(_pyobj) Py_XINCREF(_pyobj); return _pyobj; }
+ private:
+ void release() { if(_pyobj) Py_XDECREF(_pyobj); _pyobj=0; }
+ private:
+ PyObject *_pyobj;
+ };
}
}
//
#include "PyStdout.hxx"
+#include "Exception.hxx"
+#include "AutoGIL.hxx"
+
#include <structmember.h>
+
#include <string>
+#include <sstream>
+
+#ifdef WIN32
+#include <process.h>
+#define getpid _getpid
+#endif
namespace YACS
{
return (PyObject*)self;
}
+PyObject *evalPy(const std::string& funcName, const std::string& strToEval)
+{
+ std::ostringstream oss0; oss0 << "def " << funcName << "():\n";
+ std::string::size_type i0(0);
+ while(i0<strToEval.length() && i0!=std::string::npos)
+ {
+ std::string::size_type i2(strToEval.find('\n',i0));
+ std::string::size_type lgth(i2!=std::string::npos?i2-i0:std::string::npos);
+ std::string part(strToEval.substr(i0,lgth));
+ if(!part.empty())
+ oss0 << " " << part << "\n";
+ i0=i2!=std::string::npos?i2+1:std::string::npos;
+ }
+ std::string zeCodeStr(oss0.str());
+ std::ostringstream stream;
+ stream << "/tmp/PythonNode_";
+ stream << getpid();
+ AutoPyRef context(PyDict_New());
+ PyDict_SetItemString( context, "__builtins__", PyEval_GetBuiltins() );
+ AutoPyRef code(Py_CompileString(zeCodeStr.c_str(), "kkkk", Py_file_input));
+ if(code.isNull())
+ {
+ std::string errorDetails;
+ PyObject *new_stderr(newPyStdOut(errorDetails));
+ PySys_SetObject((char*)"stderr", new_stderr);
+ PyErr_Print();
+ PySys_SetObject((char*)"stderr", PySys_GetObject((char*)"__stderr__"));
+ Py_DECREF(new_stderr);
+ std::ostringstream oss; oss << "evalPy failed : " << errorDetails;
+ throw Exception(oss.str());
+ }
+ AutoPyRef res(PyEval_EvalCode(reinterpret_cast<PyCodeObject *>((PyObject *)code),context,context));
+ PyObject *ret(PyDict_GetItemString(context,funcName.c_str())); //borrowed ref
+ if(!ret)
+ throw YACS::Exception("evalPy : Error on returned func !");
+ Py_XINCREF(ret);
+ return ret;
+}
+
+PyObject *evalFuncPyWithNoParams(PyObject *func)
+{
+ if(!func)
+ throw YACS::Exception("evalFuncPyWithNoParams : input func is NULL !");
+ AutoPyRef args(PyTuple_New(0));
+ AutoPyRef ret(PyObject_CallObject(func,args));
+ if(ret.isNull())
+ throw YACS::Exception("evalFuncPyWithNoParams : ret is null !");
+ return ret.retn();
+}
+
}
}
{
namespace ENGINE
{
- YACSRUNTIMESALOME_EXPORT PyObject * newPyStdOut( std::string& out );
+ YACSRUNTIMESALOME_EXPORT PyObject *newPyStdOut( std::string& out );
+ YACSRUNTIMESALOME_EXPORT PyObject *evalPy(const std::string& funcName, const std::string& strToEval);
+ YACSRUNTIMESALOME_EXPORT PyObject *evalFuncPyWithNoParams(PyObject *func);
}
}
void PyFuncNode::init(bool start)
{
initCommonPartWithoutStateManagement(start);
+ if(_state == YACS::DISABLED)
+ {
+ exDisabledState(); // to refresh propagation of DISABLED state
+ return ;
+ }
if(start) //complete initialization
setState(YACS::READY);
else if(_state > YACS::LOADED)// WARNING FuncNode has internal vars (CEA usecase) ! Partial initialization (inside a loop). Exclusivity of funcNode.
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
-INCLUDE(UseQt4Ext)
-INCLUDE(${QT_USE_FILE})
+INCLUDE(UseQtExt)
# --- options ---
)
# header files / uic wrappings
-QT4_WRAP_UI(_uic_HEADERS ${_uic_files})
+QT_WRAP_UIC(_uic_HEADERS ${_uic_files})
# --- sources ---
# sources / moc wrappings
-QT4_WRAP_CPP(_moc_SOURCES ${_moc_HEADERS})
+QT_WRAP_MOC(_moc_SOURCES ${_moc_HEADERS})
SET(YACS_SOURCES
Yacsgui.cxx
INSTALL(TARGETS YACS EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS})
INSTALL(FILES ${YACS_HEADERS} DESTINATION ${SALOME_INSTALL_HEADERS})
-QT4_INSTALL_TS_RESOURCES("${YACS_RESOURCES}" "${SALOME_YACS_INSTALL_RES_DATA}")
+QT_INSTALL_TS_RESOURCES("${YACS_RESOURCES}" "${SALOME_YACS_INSTALL_RES_DATA}")
INSTALL(FILES ${_res_files} DESTINATION ${SALOME_YACS_INSTALL_RES_DATA})
SALOME_CONFIGURE_FILE(resources/YACSCatalog.xml.in
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
-INCLUDE(${QT_USE_FILE})
+INCLUDE(UseQtExt)
# --- options ---
# additional include directories
INCLUDE_DIRECTORIES(
${OMNIORB_INCLUDE_DIR}
- ${QT_INCLUDE_DIR}
${KERNEL_INCLUDE_DIRS}
${GUI_INCLUDE_DIRS}
${PROJECT_SOURCE_DIR}/src/bases
# --- sources ---
# sources / moc wrappings
-QT4_WRAP_CPP(_moc_SOURCES ${_moc_HEADERS})
+QT_WRAP_MOC(_moc_SOURCES ${_moc_HEADERS})
SET(SalomeWrap_SOURCES
SalomeWrapExport.hxx
#
IF(NOT WIN32)
+ SET(SHELL /bin/sh)
ADD_TEST(YacsLoaderTest python ${SALOME_TEST_DRIVER} ${TIMEOUT} ./runYacsLoaderTest.sh)
SET_TESTS_PROPERTIES(YacsLoaderTest PROPERTIES
LABELS "${COMPONENT_NAME}"
- ENVIRONMENT "LD_LIBRARY_PATH=${YACS_TEST_LIB}:$ENV{LD_LIBRARY_PATH}"
- )
+ ENVIRONMENT "LD_LIBRARY_PATH=${YACS_TEST_LIB}:$ENV{LD_LIBRARY_PATH}")
+ ADD_TEST(YacsPmmlExeTest ${SHELL} ./PmmlExeTest.sh)
+ SET_TESTS_PROPERTIES(YacsPmmlExeTest PROPERTIES LABELS "${COMPONENT_NAME}")
ENDIF()
# --- launch in background a SALOME session (servers)
ln -fs @CMAKE_SOURCE_DIR@/src/yacsloader/samples .
- ./runAppli > log1 2>&1
+ ./salome > log1 2>&1 &
# --- wait a little to let the background process define
# the CORBA naming service port and host
# --- execute the test script in SALOME session environment
chmod +x @CMAKE_CURRENT_BINARY_DIR@/YacsLoaderInSessionTest.sh
- ./runSession @CMAKE_CURRENT_BINARY_DIR@/YacsLoaderInSessionTest.sh
+ ./salome shell @CMAKE_CURRENT_BINARY_DIR@/YacsLoaderInSessionTest.sh
ret=$?
# ---------------------------------------------------------------------------
kill -9 `cat "/tmp/YACSTEST_PidEcho"`
- ./runSession killSalome.py
+ ./salome shell python killSalome.py
echo "exec status YacsLoaderInSessionTest.sh " $ret
#include <iostream>
#include <fstream>
#include <signal.h>
+#include <list>
#ifdef WIN32
#else
{"shutdown", 't', "level", 0, "Shutdown the schema: 0=no shutdown to 3=full shutdown (default 1)"},
{"reset", 'r', "level", 0, "Reset the schema before execution: 0=nothing, 1=reset error nodes to ready state (default 0)"},
{"kill-port", 'k', "port", 0, "Kill Salome application running on the specified port if the driver process is killed (with SIGINT or SIGTERM)"},
+ {"init_port", 'i', "value", OPTION_ARG_OPTIONAL, "Initialisation value of a port, specified as bloc.node.port=value."},
{ 0 }
};
#endif
int shutdown;
int reset;
int killPort;
+ std::list<std::string> init_ports;
};
typedef struct {
case 'k':
myArgs->killPort = atoi(arg);
break;
+ case 'i':
+ if (arg)
+ myArgs->init_ports.push_back(std::string(arg));
+ break;
case ARGP_KEY_ARG:
if (state->arg_num >=1) // Too many arguments.
}
#endif
+bool parse_init_port(const std::string& input, std::string& node, std::string& port, std::string& value)
+{
+ bool ok = true;
+ size_t pos_eq = input.find('=');
+ if(pos_eq == std::string::npos || pos_eq == input.size())
+ return false;
+ value = input.substr(pos_eq+1);
+ size_t pos_dot = input.rfind('.', pos_eq);
+ if(!pos_dot || pos_dot == std::string::npos || pos_dot >= pos_eq-1)
+ return false;
+ port = input.substr(pos_dot+1, pos_eq-pos_dot-1);
+ node = input.substr(0, pos_dot);
+ return true;
+}
int main (int argc, char* argv[])
{
myArgs.shutdown = 1;
myArgs.reset = 0;
myArgs.killPort = 0;
+ myArgs.init_ports.clear();
// Parse our arguments; every option seen by parse_opt will be reflected in arguments.
#ifdef WIN32
std::cerr << " dumpErrorFile=" << myArgs.dumpErrorFile << std::endl;
else
std::cerr << std::endl;
+ std::list<std::string>::const_iterator it;
+ for(it=myArgs.init_ports.begin(); it != myArgs.init_ports.end(); it++)
+ {
+ std::cerr << (*it) << std::endl;
+ }
#endif
#ifndef WIN32
std::cerr << "The imported file is probably not a YACS schema file" << std::endl;
return 1;
}
+ // Initialize the ports
+ for(it=myArgs.init_ports.begin(); it != myArgs.init_ports.end(); it++)
+ {
+ std::string node, port, value;
+ if(parse_init_port((*it), node, port, value))
+ {
+ std::cerr << "Initialization node=" << node
+ << " port=" << port
+ << " value=" << value << std::endl;
+
+ std::string init_state;
+ init_state = p->setInPortValue(node, port, value);
+ if(value.compare(init_state))
+ {
+ std::cerr << "Error on initialization:" << init_state << std::endl;
+ return 1;
+ }
+ }
+ else
+ {
+ std::cerr << "Error on parsing initialization string:" << (*it) << std::endl;
+ return 1;
+ }
+ }
+
//Get the parser logger
Logger* logger=p->getLogger("parser");
//Print errors logged if any
SALOME_CONFIGURE_FILE(PmmlExeTest.sh.in PmmlExeTest.sh)
SALOME_CONFIGURE_FILE(PmmlInSessionTest.sh.in PmmlInSessionTest.sh)
ADD_TEST(NAME PmmlExeTest COMMAND ${SHELL} PmmlExeTest.sh)
-ENDIF()
\ No newline at end of file
+ENDIF()
+
+SET(LOCAL_TEST_DIR ${SALOME_YACS_INSTALL_TEST}/yacsloader)
+INSTALL(TARGETS TestYACSPMML DESTINATION ${LOCAL_TEST_DIR})
+INSTALL(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/PmmlExeTest.sh DESTINATION ${LOCAL_TEST_DIR})
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/config_appli.xml DESTINATION ${LOCAL_TEST_DIR})
# --- launch in background a SALOME session (servers)
ln -fs @CMAKE_SOURCE_DIR@/src/yacsloader/samples .
- ./runAppli > log1 2>&1
+ ./salome > log1 2>&1 &
# --- wait a little to let the background process define
# the CORBA naming service port and host
# --- execute the test script in SALOME session environment
chmod +x @CMAKE_CURRENT_BINARY_DIR@/PmmlInSessionTest.sh
- ./runSession @CMAKE_CURRENT_BINARY_DIR@/PmmlInSessionTest.sh
+ ./salome shell @CMAKE_CURRENT_BINARY_DIR@/PmmlInSessionTest.sh
ret=$?
# ---------------------------------------------------------------------------
kill -9 `cat "/tmp/YACSTEST_PidEcho"`
- ./runSession killSalome.py
+ ./salome shell python killSalome.py
echo "exec status PmmlInSessionTest.sh " $ret
self.assertEqual(endNode_error.getPyObj(),0)
pass
+ def test4(self):
+ """ test linked to TestSaveLoadRun.test20. This is a smaller test coming from EDF autotest"""
+ xmlFileName="test4.xml"
+ p=self.r.createProc("test26")
+ n=self.r.createScriptNode("","node1")
+ n.setScript("import os")
+ p.edAddChild(n)
+ n.setState(pilot.DISABLED)
+ #
+ ex=pilot.ExecutorSwig()
+ self.assertEqual(p.getState(),pilot.READY)
+ ex.RunW(p,0)
+ self.assertEqual(p.getState(),pilot.ACTIVATED)
+ self.assertEqual(n.getState(),pilot.DISABLED) # <- test is here.
+ pass
+
def tearDown(self):
del self.r
del self.l
# --- launch in background a SALOME session (servers)
ln -fs @CMAKE_SOURCE_DIR@/src/yacsloader/samples .
- ./runAppli > log1 2>&1
+ ./salome > log1 2>&1 &
# --- wait a little to let the background process define
# the CORBA naming service port and host
# --- execute the test script in SALOME session environment
chmod +x @CMAKE_CURRENT_BINARY_DIR@/YacsLoaderInSessionTest.sh
- ./runSession @CMAKE_CURRENT_BINARY_DIR@/YacsLoaderInSessionTest.sh
+ ./salome shell @CMAKE_CURRENT_BINARY_DIR@/YacsLoaderInSessionTest.sh
ret=$?
# ---------------------------------------------------------------------------
kill -9 `cat "/tmp/YACSTEST_PidEcho"`
- ./runSession killSalome.py
+ ./salome shell python killSalome.py
echo "exec status YacsLoaderInSessionTest.sh " $ret