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})
-SET(${PROJECT_NAME_UC}_VERSION_DEV 0)
+SET(${PROJECT_NAME_UC}_VERSION_DEV 1)
# Find KERNEL (optional)
# ==============
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)
{
const int ForEachLoop::NOT_RUNNING_BRANCH_ID=-1;
+const char ForEachLoop::INTERCEPTOR_STR[]="_interceptor";
+
InterceptorInputPort::InterceptorInputPort(const std::string& name, Node *node, TypeCode* type):AnyInputPort(name,node,type),
DataPort(name,node,type),Port(node),
_repr(0)
}
}
+void ForEachLoop::InterceptorizeNameOfPort(std::string& portName)
+{
+ std::replace_if(portName.begin(), portName.end(), std::bind1st(std::equal_to<char>(), '.'), '_');
+ portName += INTERCEPTOR_STR;
+}
+
void ForEachLoop::buildDelegateOf(std::pair<OutPort *, OutPort *>& port, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView)
{
DynParaLoop::buildDelegateOf(port,finalTarget,pointsOfView);
// the delegated port belongs to a node child of the ForEachLoop.
// The name of the delegated port contains dots (bloc.node.outport),
// whereas the name of the out going port shouldn't do.
- std::string outputPortName = getPortName(port.first);
- std::replace_if (outputPortName.begin(), outputPortName.end(),
- std::bind1st(std::equal_to<char>(), '.'), '_');
- outputPortName += "_interceptor";
- AnySplitOutputPort *newPort=new AnySplitOutputPort(outputPortName,this,newTc);
- InterceptorInputPort *intercptor=new InterceptorInputPort(outputPortName + "_in",this,port.first->edGetType());
+ std::string outputPortName(getPortName(port.first));
+ InterceptorizeNameOfPort(outputPortName);
+ AnySplitOutputPort *newPort(new AnySplitOutputPort(outputPortName,this,newTc));
+ InterceptorInputPort *intercptor(new InterceptorInputPort(outputPortName + "_in",this,port.first->edGetType()));
intercptor->setRepr(newPort);
newTc->decrRef();
newPort->addRepr(port.first,intercptor);
void storeOutValsInSeqForOutOfScopeUse(int rank, int branchNb);
private:
int getFinishedId();
+ public:
+ static void InterceptorizeNameOfPort(std::string& portName);
+ static const char INTERCEPTOR_STR[];
};
}
}
return xmldump;
}
+std::string InputPort::getHumanRepr()
+{
+ return dump();
+}
+
void InputPort::setStringRef(std::string strRef)
{
_stringRef = strRef;
virtual void *get() const = 0;
virtual void put(const void *data) throw(ConversionException) = 0;
virtual std::string dump();
+ virtual std::string getHumanRepr();
virtual void setStringRef(std::string strRef);
virtual std::string typeName() {return "YACS__ENGINE__InputPort";}
bool canBeNull() const;
if(_cont)
_cont->decrRef();
_cont=cont;
- _cont->incrRef();
+ if(_cont)
+ _cont->incrRef();
_propertyMap=listOfPropertiesInYACSContainer();
}
throw YACS::Exception("YACSEvalVirtualYACSContainer::apply : unrecognized container !");
}
+std::string YACSEvalVirtualYACSContainer::getName() const
+{
+ checkNotNullYACSContainer();
+ return _cont->getName();
+}
+
unsigned int YACSEvalVirtualYACSContainer::getValueOfKeyUInt(const char *key) const
{
std::string v(getValueOfKey(key));
return props;
}
+void YACSEvalVirtualYACSContainer::checkNotNullYACSContainer() const
+{
+ if(!_cont)
+ throw YACS::Exception("YACSEvalVirtualYACSContainer::checkNotNullYACSContainer : internal YACS container is NULL !");
+}
+
YACSEvalResource::~YACSEvalResource()
{
}
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)
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(); }
+ YACSEVALYFX_EXPORT std::string getName() const;
void apply();
public:
YACSEvalVirtualYACSContainer();
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[];
return _pattern->getObserver();
}
+std::string YACSEvalYFX::getErrorDetailsInCaseOfFailure() const
+{
+ return _pattern->getErrorDetailsInCaseOfFailure();
+}
+
+std::string YACSEvalYFX::getStatusOfRunStr() const
+{
+ return _pattern->getStatusOfRunStr();
+}
+
std::vector<YACSEvalSeqAny *> YACSEvalYFX::getResults() const
{
return _pattern->getResults();
}
+std::vector<YACSEvalSeqAny *> YACSEvalYFX::getResultsInCaseOfFailure(std::vector<unsigned int>& passedIds) const
+{
+ return _pattern->getResultsInCaseOfFailure(passedIds);
+}
+
YACS::ENGINE::Proc *YACSEvalYFX::getUndergroundGeneratedGraph() const
{
return _pattern->getUndergroundGeneratedGraph();
YACSEVALYFX_EXPORT bool run(YACSEvalSession *session, int& nbOfBranches);
YACSEVALYFX_EXPORT void registerObserver(YACSEvalObserver *observer);
YACSEVALYFX_EXPORT YACSEvalObserver *getObserver();
+ YACSEVALYFX_EXPORT std::string getErrorDetailsInCaseOfFailure() const;
+ YACSEVALYFX_EXPORT std::string getStatusOfRunStr() const;
YACSEVALYFX_EXPORT std::vector<YACSEvalSeqAny *> getResults() const;
+ YACSEVALYFX_EXPORT std::vector<YACSEvalSeqAny *> getResultsInCaseOfFailure(std::vector<unsigned int>& passedIds) const;
//
YACSEVALYFX_EXPORT YACS::ENGINE::Proc *getUndergroundGeneratedGraph() const;
YACSEVALYFX_EXPORT void setParallelizeStatus(bool newVal);
#include "ElementaryNode.hxx"
#include "RuntimeSALOME.hxx"
#include "Dispatcher.hxx"
+#include "Executor.hxx"
#include "InputPort.hxx"
#include "LinkInfo.hxx"
#include "TypeCode.hxx"
#include <limits>
#include <numeric>
#include <sstream>
+#include <iterator>
const char YACSEvalYFXPattern::DFT_PROC_NAME[]="YFX";
+const char YACSEvalYFXPattern::ST_OK[]="ALL_OK";
+
+const char YACSEvalYFXPattern::ST_FAILED[]="SOME_SAMPLES_FAILED_AND_ALL_OF_THEM_FAILED_DETERMINISTICALLY";
+
+const char YACSEvalYFXPattern::ST_ERROR[]="SOME_SAMPLES_FAILED_BUT_IMPOSSIBLE_TO_CONCLUDE_ON_THEM";
+
+const std::size_t YACSEvalYFXPattern::MAX_LGTH_OF_INP_DUMP=10000;
+
+const char YACSEvalYFXRunOnlyPattern::FIRST_FE_SUBNODE_NAME[]="Bloc";
+
const char YACSEvalYFXRunOnlyPattern::GATHER_NODE_NAME[]="__gather__";
std::vector< YACSEvalInputPort *> YACSEvalYFXPattern::getFreeInputPorts() const
throw YACS::Exception("YACSEvalYFXPattern::GetValueInPort : not implemented yet for other than Double and Int !");
}
+YACSEvalSeqAny *YACSEvalYFXPattern::BuildValueFromEngineFrmt(YACS::ENGINE::SequenceAny *data)
+{
+ unsigned int sz(data->size());
+ std::vector<double> eltCpp(sz);
+ for(unsigned int ii=0;ii<sz;ii++)
+ {
+ YACS::ENGINE::AnyPtr elt((*data)[ii]);
+ YACS::ENGINE::Any *eltPtr((YACS::ENGINE::Any *)elt);
+ YACS::ENGINE::AtomAny *eltPtr2(dynamic_cast<YACS::ENGINE::AtomAny *>(eltPtr));
+ if(!eltPtr2)
+ {
+ std::ostringstream oss; oss << "YACSEvalYFXPattern::BuildValueFromEngineFrmt : error at pos #" << ii << " ! It is not an AtomAny !";
+ throw YACS::Exception(oss.str());
+ }
+ eltCpp[ii]=eltPtr2->getDoubleValue();
+ }
+ return new YACSEvalSeqAnyDouble(eltCpp);
+}
+
void YACSEvalYFXPattern::cleanScheme()
{
if(_ownScheme)
_generatedGraph->edAddChild(n2);
_generatedGraph->edAddCFLink(n1,n2);
//
- YACS::ENGINE::Bloc *n10(r->createBloc("Bloc"));
+ 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));
return _generatedGraph;
}
+std::string YACSEvalYFXRunOnlyPattern::getErrorDetailsInCaseOfFailure() const
+{
+ std::string st(getStatusOfRunStr());//test if a run has occurred.
+ 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::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::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 !");
+ if(nnc->getState()==YACS::DONE)
+ continue;
+ std::list< YACS::ENGINE::ElementaryNode *> fec(nnc->getRecursiveConstituents());
+ for(std::list< YACS::ENGINE::ElementaryNode *>::reverse_iterator it=fec.rbegin();it!=fec.rend();it++)
+ {
+ YACS::StatesForNode st0((*it)->getState());
+ if(st0!=YACS::DONE)
+ {
+ oss << "NODE = " << nnc->getChildName(*it) << std::endl;
+ oss << "STATUS = " << nsm[st0] << std::endl;
+ oss << "BRANCH ID = " << j << std::endl;
+ std::list<YACS::ENGINE::InputPort *> inps((*it)->getSetOfInputPort());
+ for(std::list<YACS::ENGINE::InputPort *>::const_iterator it=inps.begin();it!=inps.end();it++)
+ {
+ std::string d((*it)->getHumanRepr());
+ if(d.size()>10000)
+ d=d.substr(0,MAX_LGTH_OF_INP_DUMP);
+ oss << "INPUT \"" << (*it)->getName() << "\" = " << d << std::endl;
+ }
+ oss << "DETAILS = " << std::endl;
+ oss << (*it)->getErrorDetails();
+ }
+ }
+ }
+ return oss.str();
+}
+
+std::string YACSEvalYFXRunOnlyPattern::getStatusOfRunStr() const
+{
+ YACS::StatesForNode st(_generatedGraph->getState());
+ switch(st)
+ {
+ case YACS::READY:
+ case YACS::TOLOAD:
+ case YACS::LOADED:
+ case YACS::TOACTIVATE:
+ case YACS::ACTIVATED:
+ case YACS::SUSPENDED:
+ case YACS::PAUSE:
+ case YACS::DISABLED:
+ case YACS::DESACTIVATED:
+ {
+ std::ostringstream oss; oss << "YACSEvalYFXRunOnlyPattern::getStatusOfRunStr : Unexpected state \"" << YACS::ENGINE::Node::getStateName(st) << "\" ! Did you invoke run ?";
+ throw YACS::Exception(oss.str());
+ }
+ case YACS::LOADFAILED:
+ case YACS::EXECFAILED:
+ case YACS::ERROR:
+ case YACS::INTERNALERR:
+ return std::string(ST_ERROR);
+ case YACS::FAILED:
+ return std::string(ST_FAILED);
+ case YACS::DONE:
+ return std::string(ST_OK);
+ default:
+ {
+ std::ostringstream oss; oss << "YACSEvalYFXRunOnlyPattern::getStatusOfRunStr : unrecognized and managed state \"" << YACS::ENGINE::Node::getStateName(st) << "\" !";
+ throw YACS::Exception(oss.str());
+ }
+ }
+}
+
std::vector<YACSEvalSeqAny *> YACSEvalYFXRunOnlyPattern::getResults() const
{
if(_generatedGraph->getState()!=YACS::DONE)
return ret;
}
+/*!
+ * This method works if run succeeded (true return) and also if graph has failed. Graph failed means soft error of evaluation due to error in evaluation (example 1/0 or a normal throw from one node)
+ * If a more serious error occured (SIGSEGV of a server or internal error in YACS engine, cluster error, loose of connection...) this method will throw an exception to warn the caller that the results may be
+ */
+std::vector<YACSEvalSeqAny *> YACSEvalYFXRunOnlyPattern::getResultsInCaseOfFailure(std::vector<unsigned int>& passedIds) const
+{
+ YACS::StatesForNode st(_generatedGraph->getState());
+ if(st==YACS::DONE)
+ {
+ passedIds.clear();
+ std::vector<YACSEvalSeqAny *> ret(getResults());
+ if(!ret.empty())
+ {
+ if(!ret[0])
+ throw YACS::Exception("YACSEvalYFXRunOnlyPattern::getResultsInCaseOfFailure : internal error ! The returned vector has a null pointer at pos #0 !");
+ std::size_t sz(ret[0]->size());
+ passedIds.resize(sz);
+ for(std::size_t i=0;i<sz;i++)
+ passedIds[i]=i;
+ }
+ return ret;
+ }
+ getStatusOfRunStr();// To check that the status is recognized.
+ std::list<YACS::ENGINE::Node *> lns(_generatedGraph->edGetDirectDescendants());
+ YACS::ENGINE::ForEachLoop *fe(findTopForEach());
+ //
+ YACS::ENGINE::Executor exe;
+ std::vector<YACS::ENGINE::SequenceAny *> outputs;
+ std::vector<std::string> nameOfOutputs;
+ passedIds=fe->getPassedResults(&exe,outputs,nameOfOutputs);//<- the key invokation is here.
+ std::size_t sz(passedIds.size()),ii(0);
+ std::vector<YACSEvalSeqAny *> ret(_outputsOfInterest.size());
+ for(std::vector<YACSEvalOutputPort *>::const_iterator it=_outputsOfInterest.begin();it!=_outputsOfInterest.end();it++,ii++)
+ {
+ YACS::ENGINE::OutputPort *p((*it)->getUndergroundPtr());
+ std::string st(_runNode->getOutPortName(p));
+ std::ostringstream oss; oss << FIRST_FE_SUBNODE_NAME << '.' << _runNode->getName() << '.' << st;
+ st=oss.str();
+ YACS::ENGINE::ForEachLoop::InterceptorizeNameOfPort(st);
+ std::vector<std::string>::iterator it(std::find(nameOfOutputs.begin(),nameOfOutputs.end(),st));
+ if(it==nameOfOutputs.end())
+ {
+ std::ostringstream oss; oss << "YACSEvalYFXRunOnlyPattern::getResultsInCaseOfFailure : internal error 3 ! Unable to locate interceptor with name " << st << " ! Possibilities are : ";
+ std::copy(nameOfOutputs.begin(),nameOfOutputs.end(),std::ostream_iterator<std::string>(oss," "));
+ oss << " !";
+ throw YACS::Exception(oss.str());
+ }
+ std::size_t pos(std::distance(nameOfOutputs.begin(),it));
+ ret[ii]=BuildValueFromEngineFrmt(outputs[pos]);
+ }
+ return ret;
+}
+
void YACSEvalYFXRunOnlyPattern::emitStart() const
{
YACSEvalObserver *obs(getObserver());
}
}
+YACS::ENGINE::ForEachLoop *YACSEvalYFXRunOnlyPattern::findTopForEach() 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++)
+ {
+ fe=dynamic_cast<YACS::ENGINE::ForEachLoop *>(*it);
+ if(fe)
+ break;
+ }
+ if(!fe)
+ throw YACS::Exception("YACSEvalYFXRunOnlyPattern::findTopForEach : internal error 2 ! ForEach is not accessible !");
+ return fe;
+}
class ForEachLoop;
class ComposedNode;
class InputPyPort;
+ class SequenceAny;
}
}
virtual bool isLocked() const = 0;
virtual YACSEvalListOfResources *giveResources() = 0;
virtual YACS::ENGINE::Proc *getUndergroundGeneratedGraph() const = 0;
+ virtual std::string getErrorDetailsInCaseOfFailure() const = 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[];
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();
private:
protected:
std::vector< YACSEvalInputPort > _inputs;
std::vector< YACSEvalOutputPort > _outputs;
+public:
+ static const char ST_OK[]; // execution goes to the end without any trouble -> results can be exploited without any problem with getResults and getResultsInCaseOfFailure.
+ static const char ST_FAILED[]; // execution has reached some failed evaluation (normal errors due to incapacity of one node to evaluate) -> results can be exploited without any problem with getResultsInCaseOfFailure
+ static const char ST_ERROR[]; // execution has encountered hard errors (SIGSEGV in a server, internal error in YACS) -> results can be exploited with getResultsInCaseOfFailure but you can't make hypothesis for other ids not in passedIds.
+ static const std::size_t MAX_LGTH_OF_INP_DUMP;
};
class YACSEvalYFXRunOnlyPattern : public YACSEvalYFXPattern
bool isLocked() const;
YACSEvalListOfResources *giveResources();
YACS::ENGINE::Proc *getUndergroundGeneratedGraph() const;
+ std::string getErrorDetailsInCaseOfFailure() const;
+ std::string getStatusOfRunStr() const;
std::vector<YACSEvalSeqAny *> getResults() const;
+ std::vector<YACSEvalSeqAny *> getResultsInCaseOfFailure(std::vector<unsigned int>& passedIds) const;
void emitStart() const;
//
YACS::ENGINE::ForEachLoop *getUndergroundForEach() const { return _FEInGeneratedGraph; }
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 buildInputPorts();
void buildOutputPorts();
+ YACS::ENGINE::ForEachLoop *findTopForEach() const;
private:
YACS::ENGINE::ComposedNode *_runNode;
std::vector<YACSEvalOutputPort *> _outputsOfInterest;
}
}
+static PyObject *convertToPyToInt(const std::vector<unsigned int>& arr)
+{
+ std::size_t sz(arr.size());
+ PyObject *ret(PyList_New(sz));
+ for(std::size_t i=0;i<sz;i++)
+ PyList_SetItem(ret,i,PyInt_FromLong(arr[i]));
+ return ret;
+}
+
static void convertPyToDblArr(PyObject *pyLi, std::vector<double>& arr)
{
if(PyList_Check(pyLi))
throw YACS::Exception("convertPyToNewIntArr3 : not a list nor a tuple");
}
}
+
+static PyObject *convertVectOfSeqAny(const std::vector<YACSEvalSeqAny *>& retCpp)
+{
+ std::size_t sz(retCpp.size());
+ PyObject *ret(PyList_New(sz));
+ for(std::size_t i=0;i<sz;i++)
+ {
+ YACSEvalSeqAny *elt(retCpp[i]);
+ YACSEvalSeqAnyDouble *elt1(dynamic_cast<YACSEvalSeqAnyDouble *>(elt));
+ YACSEvalSeqAnyInt *elt2(dynamic_cast<YACSEvalSeqAnyInt *>(elt));
+ if(elt1)
+ {
+ std::vector<double> *zeArr(elt1->getInternal());
+ std::size_t sz2(zeArr->size());
+ PyObject *ret2(PyList_New(sz2));
+ for(std::size_t i2=0;i2<sz2;i2++)
+ PyList_SetItem(ret2,i2,PyFloat_FromDouble((*zeArr)[i2]));
+ PyList_SetItem(ret,i,ret2);
+ }
+ else if(elt2)
+ {
+ std::vector<int> *zeArr(elt2->getInternal());
+ std::size_t sz2(zeArr->size());
+ PyObject *ret2(PyList_New(sz2));
+ for(std::size_t i2=0;i2<sz2;i2++)
+ PyList_SetItem(ret2,i2,PyInt_FromLong((*zeArr)[i2]));
+ PyList_SetItem(ret,i,ret2);
+ }
+ else
+ throw YACS::Exception("wrap of YACSEvalYFX.getResults : unrecognized type !");
+ delete elt;
+ }
+ return ret;
+}
%}
%types(YACSEvalInputPort,YACSEvalOutputPort);
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();
};
bool isLocked() const;
YACS::ENGINE::Proc *getUndergroundGeneratedGraph() const;
YACSEvalListOfResources *giveResources();
+ std::string getErrorDetailsInCaseOfFailure() const;
+ std::string getStatusOfRunStr() const;
void setParallelizeStatus(bool newVal);
bool getParallelizeStatus() const;
//void registerObserver(YACSEvalObserver *observer);
PyObject *getResults() const
{
std::vector<YACSEvalSeqAny *> retCpp(self->getResults());
- std::size_t sz(retCpp.size());
- PyObject *ret(PyList_New(sz));
- for(std::size_t i=0;i<sz;i++)
- {
- YACSEvalSeqAny *elt(retCpp[i]);
- YACSEvalSeqAnyDouble *elt1(dynamic_cast<YACSEvalSeqAnyDouble *>(elt));
- YACSEvalSeqAnyInt *elt2(dynamic_cast<YACSEvalSeqAnyInt *>(elt));
- if(elt1)
- {
- std::vector<double> *zeArr(elt1->getInternal());
- std::size_t sz2(zeArr->size());
- PyObject *ret2(PyList_New(sz2));
- for(std::size_t i2=0;i2<sz2;i2++)
- PyList_SetItem(ret2,i2,PyFloat_FromDouble((*zeArr)[i2]));
- PyList_SetItem(ret,i,ret2);
- }
- else if(elt2)
- {
- std::vector<int> *zeArr(elt2->getInternal());
- std::size_t sz2(zeArr->size());
- PyObject *ret2(PyList_New(sz2));
- for(std::size_t i2=0;i2<sz2;i2++)
- PyList_SetItem(ret2,i2,PyInt_FromLong((*zeArr)[i2]));
- PyList_SetItem(ret,i,ret2);
- }
- else
- throw YACS::Exception("wrap of YACSEvalYFX.getResults : unrecognized type !");
- delete elt;
- }
- return ret;
+ return convertVectOfSeqAny(retCpp);
+ }
+
+ PyObject *getResultsInCaseOfFailure() const
+ {
+ std::vector<unsigned int> ret1Cpp;
+ std::vector<YACSEvalSeqAny *> ret0Cpp(self->getResultsInCaseOfFailure(ret1Cpp));
+ PyObject *retPy(PyTuple_New(2));
+ PyTuple_SetItem(retPy,0,convertVectOfSeqAny(ret0Cpp));
+ PyTuple_SetItem(retPy,1,convertToPyToInt(ret1Cpp));
+ return retPy;
}
PyObject *run(YACSEvalSession *session)
import evalyfx
session=evalyfx.YACSEvalSession()
session.launch()
+buildScheme(fname)
efx=evalyfx.YACSEvalYFX.BuildFromFile(fname)
efx.setParallelizeStatus(False)
inps=efx.getFreeInputPorts()
--- /dev/null
+# bug revealed by otgui on 8/2/16. Several lock/unlock session. test1.xml is Cogeneration.xml.
+
+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="test2.xml"
+import evalyfx
+session=evalyfx.YACSEvalSession()
+session.launch()
+buildScheme(fname)
+efx=evalyfx.YACSEvalYFX.BuildFromFile(fname)
+#efx.setParallelizeStatus(False)
+efx.getParams().setStopASAPAfterErrorStatus(False)
+inps=efx.getFreeInputPorts()
+assert(len(inps)==1)
+outps=efx.getFreeOutputPorts()
+inps[0].setSequenceOfValuesToEval([1.,2.,3.,4.,5.,6.])
+efx.lockPortsForEvaluation(inps,outps)
+rss=efx.giveResources()
+rss[0][0].setWantedMachine("localhost")
+a,b=efx.run(session)
+assert(efx.getStatusOfRunStr()=='SOME_SAMPLES_FAILED_AND_ALL_OF_THEM_FAILED_DETERMINISTICALLY')
+c,d=efx.getResultsInCaseOfFailure()
+assert(d==[0,1,2,4,5])# case 3 is not in !
+assert(len(c)==1)
+c=c[0]
+for f,g in zip(c,[0.3333333333333333,0.5,1.0,-1.0,-0.5]):
+ assert(abs(f-g)<1e-12)
+ pass
+st=efx.getErrorDetailsInCaseOfFailure()
+assert("NODE = toto.PyScript0" in st)
+assert("float division by zero" in st)
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 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 -*-
+
+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)
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.
return ret;
}
+std::string InputPyPort::getHumanRepr()
+{
+ if(!_data)
+ return dump();
+ PyObject *ret(PyObject_Str(_data));
+ if(!ret)
+ return dump();
+ std::string retCpp;
+ char *val(PyString_AsString(ret));
+ if(val)
+ retCpp=val;
+ Py_XDECREF(ret);
+ return retCpp;
+}
+
bool InputPyPort::isEmpty()
{
return _data == Py_None;
virtual PyObj * getPyObj() const;
virtual std::string getAsString();
void *get() const throw(Exception);
+ virtual std::string getHumanRepr();
virtual bool isEmpty();
virtual void exSaveInit();
virtual void exRestoreInit();
#
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
{
if ( xmlParseDocument(saxContext) == -1 )
{
+ if(!currentProc)
+ throw Exception("Basic error during parsing.");
YACS::ENGINE::Logger* logger = currentProc->getLogger("parser");
logger->fatal( saxContext->lastError.message, file, saxContext->input->line );
}
}
catch(Exception& e)
{
+ if(!currentProc)
+ throw e;
YACS::ENGINE::Logger* logger = currentProc->getLogger("parser");
logger->fatal(e.what(), file, saxContext->input->line);
saxContext = 0;
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})
\ No newline at end of file
# --- 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