Ignore:
Timestamp:
06/04/21 11:55:52 (3 years ago)
Author:
yushan
Message:

Big commit on graph functionality. Enable the workflow graph when going through field dependency graph

Location:
XIOS/dev/dev_ym/XIOS_COUPLING/src/node
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/field.cpp

    r2130 r2144  
    2222#include "file_reader_source_filter.hpp" 
    2323#include "tracer.hpp" 
     24#include "graph_package.hpp" 
    2425 
    2526namespace xios 
     
    585586     
    586587    const bool detectMissingValues = (!detect_missing_value.isEmpty() && !default_value.isEmpty() && detect_missing_value == true); 
    587     const double defaultValue  = detectMissingValues ? default_value : (!default_value.isEmpty() ? default_value : 0.0); 
    588  
     588    const double defaultValue = detectMissingValues ? default_value : (!default_value.isEmpty() ? default_value : 0.0); 
     589    bool buildGraph_ = !build_workflow_graph.isEmpty() && build_workflow_graph == true ; 
     590    info(100)<<"=== Workflow Graph === field id="<<this->getId()<<" build_workflow_graph="<<buildGraph_<<std::endl; 
    589591    if (!inputFilter) inputFilter = std::shared_ptr<CPassThroughFilter>(new CPassThroughFilter(gc));  
    590592      
     
    592594    { 
    593595      CField* fieldRef = getDirectFieldReference(); 
     596      info(100)<<"=== Workflow Graph === fieldRef id="<<fieldRef->getId()<<std::endl; 
     597 
     598      //------ build_workflow_graph start 
     599      if(buildGraph_) 
     600      { 
     601        (*fieldRef).build_workflow_graph.set(build_workflow_graph);  
     602      }     
     603      else 
     604      { 
     605        this->build_workflow_graph.set(fieldRef->build_workflow_graph); 
     606        buildGraph_ = !build_workflow_graph.isEmpty() && build_workflow_graph == true ; 
     607        info(100)<<"=== Workflow Graph === field id="<<this->getId()<<" updated build_workflow_graph="<<buildGraph_<<std::endl; 
     608      } 
     609 
     610       
     611      if(buildGraph_) this->build_workflow_graph.set(build_workflow_graph); 
     612      //------ build_workflow_graph end 
     613 
    594614      bool ret=fieldRef->buildWorkflowGraph(gc);  
    595615      if (!ret) return false ; // workflow graph cannot be built at this stage 
     616       
     617      this->build_workflow_graph.set(fieldRef->build_workflow_graph); 
     618      buildGraph_ = !build_workflow_graph.isEmpty() && build_workflow_graph == true ; 
    596619    } 
    597620 
     
    624647      { 
    625648        grid->solveElementsRefInheritance() ; 
    626         std::pair<std::shared_ptr<CFilter>, std::shared_ptr<CFilter> > filters = grid->buildTransformationGraph(gc, false,  gridSrc, detectMissingValues, defaultValue, newGrid) ; 
     649        std::pair<std::shared_ptr<CFilter>, std::shared_ptr<CFilter> > filters = grid->buildTransformationGraph(gc, false,  gridSrc, detectMissingValues, defaultValue, newGrid, buildGraph_, this) ; 
    627650        lastFilter->connectOutput(filters.first, 0); 
    628651        lastFilter = filters.second; 
     
    636659      // connect the input Filter to the reference 
    637660      getDirectFieldReference()->getInstantDataFilter()->connectOutput(inputFilter,0); 
     661      if(buildGraph_)  
     662      { 
     663        info(100)<<"=== Workflow Graph === field "<<this->getId()<<" calls a transformation filter 2 ============== "<<getDirectFieldReference()->getInstantDataFilter()<<" _ "<<inputFilter<<std::endl; 
     664        inputFilter->graphEnabled=true; 
     665        inputFilter->graphPackage = new CGraphPackage; 
     666        inputFilter->graphPackage->inFields.push_back(this); 
     667        inputFilter->label_field_id = getDirectFieldReference()->getId();  
     668      } 
    638669    } 
    639670    else  
     
    647678         if (fileIn_->isClientSide()) fileIn_->readFieldAttributesMetaData(this); 
    648679         CGrid* newGrid ; 
    649          std::pair<std::shared_ptr<CFilter>, std::shared_ptr<CFilter> > filters = grid_->buildTransformationGraph(gc, true, nullptr, detectMissingValues, defaultValue, newGrid) ; 
     680         std::pair<std::shared_ptr<CFilter>, std::shared_ptr<CFilter> > filters = grid_->buildTransformationGraph(gc, true, nullptr, detectMissingValues, defaultValue, newGrid, buildGraph_, this) ; 
    650681         grid_ = newGrid ; 
    651682         grid_ref=grid_->getId() ; // for server  
     
    668699        grid_->solveElementsRefInheritance() ; 
    669700        CGrid* newGrid ; 
    670         std::pair<std::shared_ptr<CFilter>, std::shared_ptr<CFilter> > filters = grid_->buildTransformationGraph(gc, true, nullptr, detectMissingValues, defaultValue, newGrid) ; 
     701        std::pair<std::shared_ptr<CFilter>, std::shared_ptr<CFilter> > filters = grid_->buildTransformationGraph(gc, true, nullptr, detectMissingValues, defaultValue, newGrid, buildGraph_, this) ; 
    671702        newGrid->duplicateAttributes(grid_) ; // for grid attributes (mask) 
    672703        grid_ = newGrid ; 
     
    701732    // insert temporal filter before sending to files 
    702733    getTemporalDataFilter(gc, fileOut_->output_freq)->connectOutput(clientToServerStoreFilter_, 0); 
     734    const bool buildGraph_ = !build_workflow_graph.isEmpty() && build_workflow_graph == true ; 
     735    if(buildGraph_)  
     736    { 
     737      info(100)<<"=== Workflow Graph === field "<<this->getId()<<" calls a connectToFileServer  ============== "<<getTemporalDataFilter(gc, fileOut_->output_freq)<<" _ "<<clientToServerStoreFilter_<<std::endl; 
     738      clientToServerStoreFilter_->graphPackage = new CGraphPackage; 
     739      clientToServerStoreFilter_->graphEnabled = true; 
     740      clientToServerStoreFilter_->graphPackage->inFields.push_back(this); 
     741    } 
    703742  }  
    704743 
     
    708747    clientToServerStoreFilter_ = std::shared_ptr<CClientToServerStoreFilter>(new CClientToServerStoreFilter(gc, this, client)); 
    709748    instantDataFilter->connectOutput(clientToServerStoreFilter_, 0); 
     749    const bool buildGraph_ = !build_workflow_graph.isEmpty() && build_workflow_graph == true ; 
     750    if(buildGraph_)  
     751    { 
     752      info(100)<<"=== Workflow Graph === field "<<this->getId()<<" calls a connectToCouplerOut  ============== "<<instantDataFilter<<" _ "<<clientToServerStoreFilter_<<std::endl; 
     753      clientToServerStoreFilter_->graphPackage = new CGraphPackage; 
     754      clientToServerStoreFilter_->graphEnabled = true; 
     755      clientToServerStoreFilter_->graphPackage->inFields.push_back(this); 
     756    } 
    710757  }  
    711758 
     
    722769    modelToClientSourceFilter_ = std::shared_ptr<CModelToClientSourceFilter>(new CModelToClientSourceFilter(gc, grid_, detectMissingValues, defaultValue)); 
    723770    modelToClientSourceFilter_ -> connectOutput(inputFilter,0) ; 
     771    const bool buildGraph_ = !build_workflow_graph.isEmpty() && build_workflow_graph == true ; 
     772    if(buildGraph_ )  
     773    { 
     774      info(100)<<"=== Workflow Graph === field "<<this->getId()<<" calls a connectToModelInput  ============== "<<modelToClientSourceFilter_<<" _ "<<inputFilter<<" ***** "<<std::endl; 
     775      modelToClientSourceFilter_->graphPackage = new CGraphPackage; 
     776      modelToClientSourceFilter_->graphEnabled = true; 
     777      modelToClientSourceFilter_->graphPackage->inFields.push_back(this); 
     778    } 
    724779  }  
    725780  
     
    731786    serverFromClientSourceFilter_ = std::shared_ptr<CServerFromClientSourceFilter>(new CServerFromClientSourceFilter(gc,  grid_)); 
    732787    serverFromClientSourceFilter_ -> connectOutput(inputFilter,0) ; 
     788    const bool buildGraph_ = !build_workflow_graph.isEmpty() && build_workflow_graph == true ; 
     789    if(buildGraph_) 
     790    { 
     791      info(100)<<"=== Workflow Graph === field "<<this->getId()<<" calls a connectToClientInput  ============== "<<serverFromClientSourceFilter_ << " _ "<<inputFilter<<" ***** "<<std::endl; 
     792      serverFromClientSourceFilter_->graphPackage = new CGraphPackage; 
     793      serverFromClientSourceFilter_->graphEnabled = true; 
     794      serverFromClientSourceFilter_->graphPackage->inFields.push_back(this); 
     795    } 
    733796  }  
    734797 
     
    742805    clientFromServerSourceFilter_ = std::shared_ptr<CClientFromServerSourceFilter>(new CClientFromServerSourceFilter(gc,this)) ; 
    743806    clientFromServerSourceFilter_ -> connectOutput(inputFilter,0) ; 
     807    const bool buildGraph_ = !build_workflow_graph.isEmpty() && build_workflow_graph == true ; 
     808    if(buildGraph_) 
     809    { 
     810      info(100)<<"=== Workflow Graph === field "<<this->getId()<<" calls a connectToServerInput  ============== "<<clientFromServerSourceFilter_ << " _ "<<inputFilter<<std::endl; 
     811      clientFromServerSourceFilter_->graphPackage = new CGraphPackage; 
     812      clientFromServerSourceFilter_->graphEnabled = true; 
     813      clientFromServerSourceFilter_->graphPackage->inFields.push_back(this); 
     814    } 
    744815  }  
    745816 
     
    755826    clientFromClientSourceFilter_ = std::shared_ptr<CClientFromClientSourceFilter>(new CClientFromClientSourceFilter(gc, this)) ; 
    756827    clientFromClientSourceFilter_ -> connectOutput(inputFilter,0) ; 
    757     
     828    const bool buildGraph_ = !build_workflow_graph.isEmpty() && build_workflow_graph == true ; 
     829    if(buildGraph_) 
     830    { 
     831      info(100)<<"=== Workflow Graph === field "<<this->getId()<<" calls a connectToCouplerIn  ============== "<<clientFromClientSourceFilter_ << " _ "<<inputFilter<<std::endl; 
     832      clientFromClientSourceFilter_->graphPackage = new CGraphPackage; 
     833      clientFromClientSourceFilter_->graphEnabled = true; 
     834      clientFromClientSourceFilter_->graphPackage->inFields.push_back(this); 
     835    } 
    758836  }  
    759837 
     
    765843    fileWriterStoreFilter_ = std::shared_ptr<CFileWriterStoreFilter>(new CFileWriterStoreFilter(gc, this)); 
    766844    instantDataFilter->connectOutput(fileWriterStoreFilter_, 0); 
     845    const bool buildGraph_ = !build_workflow_graph.isEmpty() && build_workflow_graph == true ; 
     846    if(buildGraph_) 
     847    { 
     848      info(100)<<"=== Workflow Graph === field "<<this->getId()<<" calls a connectToFileWriter  ============== "<<instantDataFilter << " _ "<<fileWriterStoreFilter_<<std::endl; 
     849      fileWriterStoreFilter_->graphPackage = new CGraphPackage; 
     850      fileWriterStoreFilter_->graphEnabled = true; 
     851      fileWriterStoreFilter_->graphPackage->inFields.push_back(this); 
     852    } 
    767853  }  
    768854 
     
    774860    fileReaderSourceFilter_ = std::shared_ptr<CFileReaderSourceFilter>(new CFileReaderSourceFilter(gc, this)); 
    775861    fileReaderSourceFilter_->connectOutput(inputFilter, 0); 
     862    const bool buildGraph_ = !build_workflow_graph.isEmpty() && build_workflow_graph == true ; 
     863    if(buildGraph_) 
     864    { 
     865      info(100)<<"=== Workflow Graph === field "<<this->getId()<<" calls a connectToFileReader  ============== "<<fileReaderSourceFilter_ << " _ "<<inputFilter<<std::endl; 
     866      fileReaderSourceFilter_->graphPackage = new CGraphPackage; 
     867      fileReaderSourceFilter_->graphEnabled = true; 
     868      fileReaderSourceFilter_->graphPackage->inFields.push_back(this); 
     869    } 
    776870  } 
    777871 
     
    784878    clientToModelStoreFilter_ = std::shared_ptr<CClientToModelStoreFilter>(new CClientToModelStoreFilter(gc, this)); 
    785879    instantDataFilter->connectOutput(clientToModelStoreFilter_, 0); 
     880    const bool buildGraph_ = !build_workflow_graph.isEmpty() && build_workflow_graph == true ; 
     881    if(buildGraph_) 
     882    { 
     883      info(100)<<"=== Workflow Graph === field "<<this->getId()<<" calls a connectToModelOutput  ============== "<<instantDataFilter << " _ "<<clientToModelStoreFilter_<<std::endl; 
     884      clientToModelStoreFilter_->graphPackage = new CGraphPackage; 
     885      clientToModelStoreFilter_->graphEnabled = true; 
     886      clientToModelStoreFilter_->graphPackage->inFields.push_back(this); 
     887    } 
    786888  } 
    787889 
     
    792894    serverToClientStoreFilter_ = std::shared_ptr<CServerToClientStoreFilter>(new CServerToClientStoreFilter(gc, this, client)); 
    793895    instantDataFilter->connectOutput(serverToClientStoreFilter_, 0); 
     896    const bool buildGraph_ = !build_workflow_graph.isEmpty() && build_workflow_graph == true ; 
     897    if(buildGraph_) 
     898    { 
     899      info(100)<<"=== Workflow Graph === field "<<this->getId()<<" calls a connectToServerToClient  ============== "<<instantDataFilter << " _ "<<serverToClientStoreFilter_<<std::endl; 
     900      serverToClientStoreFilter_->graphPackage = new CGraphPackage; 
     901      serverToClientStoreFilter_->graphEnabled = true; 
     902      serverToClientStoreFilter_->graphPackage->inFields.push_back(this); 
     903    } 
    794904  } 
    795905 
     
    9251035 
    9261036      instantDataFilter->connectOutput(temporalFilter, 0); 
     1037      const bool buildGraph_ = !build_workflow_graph.isEmpty() && build_workflow_graph == true ; 
     1038      if(buildGraph_)  
     1039      { 
     1040        info(100)<<"=== Workflow Graph === field "<<this->getId()<<" calls a getTemporalDataFilter  ============== "<<instantDataFilter << " _ "<<temporalFilter<<std::endl; 
     1041        temporalFilter->graphPackage = new CGraphPackage; 
     1042        temporalFilter->graphEnabled = true; 
     1043        temporalFilter->graphPackage->inFields.push_back(this); 
     1044      } 
    9271045 
    9281046      it = temporalDataFilters.insert(std::make_pair(outFreq, temporalFilter)).first; 
     
    9721090 
    9731091      inputFilter->connectOutput(selfTemporalDataFilter, 0); 
     1092      const bool buildGraph_ = !build_workflow_graph.isEmpty() && build_workflow_graph == true ; 
     1093      if(buildGraph_) 
     1094      { 
     1095        info(100)<<"=== Workflow Graph === field "<<this->getId()<<" calls a getSelfTemporalDataFilter  ============== "<<inputFilter << " _ "<<selfTemporalDataFilter<<std::endl; 
     1096        selfTemporalDataFilter->graphPackage = new CGraphPackage; 
     1097        selfTemporalDataFilter->graphEnabled = true; 
     1098        selfTemporalDataFilter->graphPackage->inFields.push_back(this); 
     1099      } 
    9741100      return selfTemporalDataFilter ; 
    9751101    } 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/grid.cpp

    r2128 r2144  
    16401640 
    16411641  std::pair<std::shared_ptr<CFilter>, std::shared_ptr<CFilter> >  
    1642   CGrid::buildTransformationGraph(CGarbageCollector& gc, bool isSource, CGrid* gridSrc, double detectMissingValues, double defaultValue, CGrid*& newGrid) 
    1643   TRY 
    1644   { 
     1642  CGrid::buildTransformationGraph(CGarbageCollector& gc, bool isSource, CGrid* gridSrc, double detectMissingValues, double defaultValue, CGrid*& newGrid, bool graphEnabled, CField* field) 
     1643  TRY 
     1644  { 
     1645    static bool transformationGoing = false; 
    16451646    registerAlgorithmTransformation() ; // needed to enable self-registration of the transformations 
    16461647                                        // big mystery why it doesn't work witout that... 
     
    19361937        shared_ptr<CTransformFilter> transformFilter = shared_ptr<CTransformFilter>(gridAlgorithm->createTransformFilter(gc, detectMissingValues, defaultValue)) ; 
    19371938        outputFilter->connectOutput(transformFilter,0) ; 
     1939        if(graphEnabled) 
     1940        { 
     1941          transformFilter->graphEnabled=true; 
     1942          transformFilter->graphPackage = new CGraphPackage; 
     1943          transformFilter->graphPackage->inFields.push_back(field); 
     1944          transformFilter->graphPackage->show = !transformationGoing; 
     1945        } 
     1946         
    19381947        vector<string> auxFieldId = algo->getAuxFieldId() ; // better to do that at transformation not algo ?? 
    19391948        int i=1;  
     
    19501959      if (hasRemainTransform) 
    19511960      { 
     1961        transformationGoing = true; 
    19521962        gridSrc=newGrid ; 
    1953         pair<shared_ptr<CFilter>, shared_ptr<CFilter> > filters = this->buildTransformationGraph(gc, isSource, gridSrc, detectMissingValues, defaultValue, newGrid) ; 
     1963        CField *field_bis = field; 
     1964        pair<shared_ptr<CFilter>, shared_ptr<CFilter> > filters = this->buildTransformationGraph(gc, isSource, gridSrc, detectMissingValues, defaultValue, newGrid, graphEnabled, field_bis) ; 
    19541965        outputFilter->connectOutput(filters.first,0) ; 
    19551966        outputFilter=filters.second ; 
    19561967      } 
     1968      transformationGoing = false; 
    19571969    } 
    19581970      
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/grid.hpp

    r2127 r2144  
    216216      public: 
    217217         pair<shared_ptr<CFilter>, shared_ptr<CFilter> > buildTransformationGraph(CGarbageCollector& gc, bool isSource, CGrid* gridSrc, double detectMissingValues, 
    218                                                                                   double defaultValue, CGrid*& newGrid) ; 
     218                                                                                  double defaultValue, CGrid*& newGrid, bool graphEnabled=false, CField* field=0) ; 
    219219      private: 
    220220        CGridAlgorithm* gridAlgorithm_ = nullptr ; 
Note: See TracChangeset for help on using the changeset viewer.