kw2542 commented on a change in pull request #14945:
URL: https://github.com/apache/beam/pull/14945#discussion_r647660031



##########
File path: 
runners/samza/src/main/java/org/apache/beam/runners/samza/renderer/PipelineJsonRenderer.java
##########
@@ -0,0 +1,196 @@
+/*
+ * 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.
+ */
+package org.apache.beam.runners.samza.renderer;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.ServiceLoader;
+import org.apache.beam.model.pipeline.v1.RunnerApi;
+import org.apache.beam.runners.samza.SamzaIOInfo;
+import org.apache.beam.sdk.Pipeline;
+import org.apache.beam.sdk.annotations.Experimental;
+import org.apache.beam.sdk.runners.TransformHierarchy;
+import org.apache.beam.sdk.values.PValue;
+import 
org.apache.beam.vendor.guava.v26_0_jre.com.google.common.collect.Iterators;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A JSON renderer for BEAM {@link Pipeline} DAG. This can help us with 
visualization of the Beam
+ * DAG.
+ */
+@Experimental
+public class PipelineJsonRenderer implements Pipeline.PipelineVisitor {
+  private static final Logger LOG = 
LoggerFactory.getLogger(PipelineJsonRenderer.class);
+  private static final String OUTERMOST_NODE = "OuterMostNode";
+
+  public static String toJsonString(Pipeline pipeline) {
+    final PipelineJsonRenderer visitor = new PipelineJsonRenderer();
+    visitor.begin();
+    pipeline.traverseTopologically(visitor);
+    visitor.end();
+    return visitor.jsonBuilder.toString();
+  }
+
+  public static String toJsonString(RunnerApi.Pipeline pipeline) {
+    return null;

Review comment:
       why don't we support portable pipeline?

##########
File path: runners/samza/src/test/resources/ExpectedDag.json
##########
@@ -0,0 +1,103 @@
+{
+  "RootNode": [
+    { "fullName":"OuterMostNode",
+      "shortName":"OuterMostNode",
+      "id":"OuterMostNode",
+      "ChildNode":[
+        { "fullName":"Create.TimestampedValues",
+          "shortName":"Create.TimestampedValues",
+          "id":"Create.TimestampedValues",
+          "enclosingNode":"OuterMostNode",
+          "ChildNode":[
+            { "fullName":"Create.TimestampedValues/Create.Values",
+              "shortName":"Create.Values",
+              "id":"Create.TimestampedValues/Create.Values",
+              "enclosingNode":"Create.TimestampedValues",

Review comment:
       do we really need `enclosingNode` since the info can already be inferred 
from `ChildNode` 

##########
File path: runners/samza/src/test/resources/ExpectedDag.json
##########
@@ -0,0 +1,103 @@
+{
+  "RootNode": [
+    { "fullName":"OuterMostNode",
+      "shortName":"OuterMostNode",
+      "id":"OuterMostNode",
+      "ChildNode":[
+        { "fullName":"Create.TimestampedValues",
+          "shortName":"Create.TimestampedValues",
+          "id":"Create.TimestampedValues",
+          "enclosingNode":"OuterMostNode",
+          "ChildNode":[
+            { "fullName":"Create.TimestampedValues/Create.Values",
+              "shortName":"Create.Values",
+              "id":"Create.TimestampedValues/Create.Values",
+              "enclosingNode":"Create.TimestampedValues",
+              "ChildNode":[
+                { 
"fullName":"Create.TimestampedValues/Create.Values/Read(CreateSource)",
+                  "shortName":"Read(CreateSource)",
+                  
"id":"Create.TimestampedValues/Create.Values/Read(CreateSource)",

Review comment:
       judging from the test, it looks to me that the `id` is always the same 
as `fullName`, is this expected? do we need both?

##########
File path: runners/samza/src/test/resources/ExpectedDag.json
##########
@@ -0,0 +1,103 @@
+{
+  "RootNode": [
+    { "fullName":"OuterMostNode",
+      "shortName":"OuterMostNode",
+      "id":"OuterMostNode",
+      "ChildNode":[
+        { "fullName":"Create.TimestampedValues",
+          "shortName":"Create.TimestampedValues",
+          "id":"Create.TimestampedValues",
+          "enclosingNode":"OuterMostNode",
+          "ChildNode":[
+            { "fullName":"Create.TimestampedValues/Create.Values",
+              "shortName":"Create.Values",
+              "id":"Create.TimestampedValues/Create.Values",
+              "enclosingNode":"Create.TimestampedValues",
+              "ChildNode":[
+                { 
"fullName":"Create.TimestampedValues/Create.Values/Read(CreateSource)",
+                  "shortName":"Read(CreateSource)",

Review comment:
       do we really need short name since it seems to be just the last part of 
full name?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to