Github user achristianson commented on a diff in the pull request:

    https://github.com/apache/nifi-minifi-cpp/pull/183#discussion_r150893273
  
    --- Diff: extensions/tensorflow/TFApplyGraph.cpp ---
    @@ -0,0 +1,227 @@
    +/**
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +#include "TFApplyGraph.h"
    +
    +#include "tensorflow/cc/ops/standard_ops.h"
    +
    +namespace org {
    +namespace apache {
    +namespace nifi {
    +namespace minifi {
    +namespace processors {
    +
    +core::Property TFApplyGraph::InputNode(  // NOLINT
    +    "Input Node",
    +    "The node of the TensorFlow graph to feed tensor inputs to", "");
    +core::Property TFApplyGraph::OutputNode(  // NOLINT
    +    "Output Node",
    +    "The node of the TensorFlow graph to read tensor outputs from", "");
    +
    +core::Relationship TFApplyGraph::Success(  // NOLINT
    +    "success",
    +    "Successful graph application outputs");
    +core::Relationship TFApplyGraph::Retry(  // NOLINT
    +    "retry",
    +    "Inputs which fail graph application but may work if sent again");
    +core::Relationship TFApplyGraph::Failure(  // NOLINT
    +    "failure",
    +    "Failures which will not work if retried");
    +
    +void TFApplyGraph::initialize() {
    +  std::set<core::Property> properties;
    +  properties.insert(InputNode);
    +  properties.insert(OutputNode);
    +  setSupportedProperties(std::move(properties));
    +
    +  std::set<core::Relationship> relationships;
    +  relationships.insert(Success);
    +  relationships.insert(Retry);
    +  relationships.insert(Failure);
    +  setSupportedRelationships(std::move(relationships));
    +}
    +
    +void TFApplyGraph::onSchedule(core::ProcessContext *context, 
core::ProcessSessionFactory *sessionFactory) {
    +  context->getProperty(InputNode.getName(), input_node_);
    +
    +  if (input_node_.empty()) {
    +    logger_->log_error("Invalid input node");
    +  }
    +
    +  context->getProperty(OutputNode.getName(), output_node_);
    +
    +  if (output_node_.empty()) {
    +    logger_->log_error("Invalid output node");
    +  }
    +}
    +
    +void TFApplyGraph::onTrigger(const std::shared_ptr<core::ProcessContext> 
&context,
    +                             const std::shared_ptr<core::ProcessSession> 
&session) {
    +  auto flow_file = session->get();
    --- End diff --
    
    Good question. Whatever is feeding this processor could simply fork its 
output relationship to another processor to preserve the input. Another 
alternative is to add an "original" relationship to this processor, which 
follows a common design pattern from NiFi processors.
    
    In my opinion, for now, we should just allow this processor to be 
destructive with its input, and expect the user to fork off the original 
upstream of the processor if they have a need to do so.
    
    When we flesh out our user docs for the minifi-cpp processors, we can 
detail this behavior as well as common use cases, such as loading a graph from 
the filesystem with a GetFile. The "success" relationship of said GetFile can 
be sent anywhere to preserve the original graph. Likewise for tensor inputs.


---

Reply via email to