Salome HOME
Bug correction EDF12462 (3/3)
authorAnthony Geay <anthony.geay@edf.fr>
Fri, 4 Mar 2016 08:56:33 +0000 (09:56 +0100)
committerAnthony Geay <anthony.geay@edf.fr>
Fri, 4 Mar 2016 08:56:33 +0000 (09:56 +0100)
src/engine/InputPort.cxx
src/engine/InputPort.hxx
src/evalyfx/YACSEvalYFX.cxx
src/evalyfx/YACSEvalYFX.hxx
src/evalyfx/YACSEvalYFXPattern.cxx
src/evalyfx/YACSEvalYFXPattern.hxx
src/evalyfx_swig/evalyfx.i
src/evalyfx_swig/test2.py
src/runtime/PythonPorts.cxx
src/runtime/PythonPorts.hxx

index d2b13e31d65c48cad39be071b5507e6fe783d1aa..569e5aacd63561938216e09ad1f0423456650b4e 100644 (file)
@@ -161,6 +161,11 @@ std::string InputPort::dump()
   return xmldump;
 }
 
+std::string InputPort::getHumanRepr()
+{
+  return dump();
+}
+
 void InputPort::setStringRef(std::string strRef)
 {
   _stringRef = strRef;
index 80c565f2236f9ce5bf39af1f1d33071dead3cea7..37c642dc93327dcbd9add4a3824ba182de27e9f5 100644 (file)
@@ -76,6 +76,7 @@ namespace YACS
       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;
index 9e7ef2f3ffac51ceb336a8184b068f83df307be3..dc94ec8fdffaea2e28d3b25581d3fd0234955f66 100644 (file)
@@ -137,6 +137,11 @@ YACSEvalObserver *YACSEvalYFX::getObserver()
   return _pattern->getObserver();
 }
 
+std::string YACSEvalYFX::getErrorDetailsInCaseOfFailure() const
+{
+  return _pattern->getErrorDetailsInCaseOfFailure();
+}
+
 std::string YACSEvalYFX::getStatusOfRunStr() const
 {
   return _pattern->getStatusOfRunStr();
index 7f723c4bcf7897b6fdf2a7cab88825daa4fbc9f2..a881e15d11e4d4e883f9c0adaefa900cb8c8d976 100644 (file)
@@ -58,6 +58,7 @@ public:
   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;
index 7afb739d05cb70ed440fefd3d742e2bef8f200c5..6a787645c69fa8ecd93c3964006faa03b3e229ef 100644 (file)
@@ -55,6 +55,8 @@ const char YACSEvalYFXPattern::ST_FAILED[]="SOME_SAMPLES_FAILED_AND_ALL_OF_THEM_
 
 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__";
@@ -483,6 +485,49 @@ YACS::ENGINE::Proc *YACSEvalYFXRunOnlyPattern::getUndergroundGeneratedGraph() co
   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());
@@ -566,15 +611,7 @@ std::vector<YACSEvalSeqAny *> YACSEvalYFXRunOnlyPattern::getResultsInCaseOfFailu
     }
   getStatusOfRunStr();// To check that the status is recognized.
   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::getResultsInCaseOfFailure : internal error 2 ! ForEach is not accessible !");
+  YACS::ENGINE::ForEachLoop *fe(findTopForEach());
   //
   YACS::ENGINE::Executor exe;
   std::vector<YACS::ENGINE::SequenceAny *> outputs;
@@ -691,3 +728,17 @@ void YACSEvalYFXRunOnlyPattern::buildOutputPorts()
     }
 }
 
+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;
+}
index 6db957d0479179a44f9756787f2deaa6bbf167c6..4a9654bd552541431ce8aad01d1b82bfaa835610 100644 (file)
@@ -75,6 +75,7 @@ public:
   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;
@@ -107,6 +108,7 @@ 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
@@ -123,6 +125,7 @@ public:
   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;
@@ -136,6 +139,7 @@ public:
 private:
   void buildInputPorts();
   void buildOutputPorts();
+  YACS::ENGINE::ForEachLoop *findTopForEach() const;
 private:
   YACS::ENGINE::ComposedNode *_runNode;
   std::vector<YACSEvalOutputPort *> _outputsOfInterest;
index 21286547071e888c20a7e5a3d21aab129e3c945e..b67dbb4a16d5f0414da9c3e75af854e744795885 100644 (file)
@@ -394,6 +394,7 @@ public:
   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;
index 706b1707d832863f814d76e3d8201abf88543988..b47d37caa826b58e92808c178b55a77ba20bda28 100644 (file)
@@ -46,4 +46,6 @@ 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)
index 4d25d1f09b534c27e40c2f8fe1ca664ef024024c..040a1d1cfa6963558ef3ae8f41b4226f629a4b88 100644 (file)
@@ -190,6 +190,21 @@ std::string InputPyPort::getAsString()
   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;
index 6fd09092538426cd4caae973bd5d3e66f16626f7..1c338b5d4bbdd61b899c967282fcb86b623a9209 100644 (file)
@@ -85,6 +85,7 @@ namespace YACS
       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();