You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by al...@apache.org on 2020/03/18 21:52:05 UTC

[beam] branch master updated: [BEAM-7923] Change Transform Label Prefix Syntax

This is an automated email from the ASF dual-hosted git repository.

altay pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/beam.git


The following commit(s) were added to refs/heads/master by this push:
     new 12cd4b6  [BEAM-7923] Change Transform Label Prefix Syntax
     new 8c69322  Merge pull request #11161 from KevinGG/refactor
12cd4b6 is described below

commit 12cd4b61cf4cbb83e4c54b79423cff508270b1d7
Author: KevinGG <ka...@gmail.com>
AuthorDate: Wed Mar 18 11:23:28 2020 -0700

    [BEAM-7923] Change Transform Label Prefix Syntax
    
    1. Based on user studies, changed the transform label prefix from `Cell
    {}:` to `[{}]:` when a pipeline is constructed in an IPython
    environment (in IPython or in an IPython backed notebook).
    2. The change mostly affects the pipeline graph rendered and should not
    cause backward compatibility issues.
---
 .../interactive/display/pipeline_graph_test.py     | 22 +++++++++++-----------
 sdks/python/apache_beam/utils/interactive_utils.py |  2 +-
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/sdks/python/apache_beam/runners/interactive/display/pipeline_graph_test.py b/sdks/python/apache_beam/runners/interactive/display/pipeline_graph_test.py
index d4e9169..01d85bd 100644
--- a/sdks/python/apache_beam/runners/interactive/display/pipeline_graph_test.py
+++ b/sdks/python/apache_beam/runners/interactive/display/pipeline_graph_test.py
@@ -55,7 +55,7 @@ class PipelineGraphTest(unittest.TestCase):
     p = beam.Pipeline(ir.InteractiveRunner())
     # We are examining if literal `"` and trailing literal `\` are decorated
     # correctly.
-    pcoll = p | '"Cell 1": "Create\\"' >> beam.Create(range(1000))
+    pcoll = p | '"[1]": "Create\\"' >> beam.Create(range(1000))
     ib.watch(locals())
 
     self.assertEqual(
@@ -64,9 +64,9 @@ class PipelineGraphTest(unittest.TestCase):
             'node [color=blue, fontcolor=blue, shape=box];\n'
             # The py string literal from `\\\\\\"` is `\\\"` in dot and will be
             # rendered as `\"` because they are enclosed by `"`.
-            '"\\"Cell 1\\": \\"Create\\\\\\"";\n'
+            '"\\"[1]\\": \\"Create\\\\\\"";\n'
             'pcoll [shape=circle];\n'
-            '"\\"Cell 1\\": \\"Create\\\\\\"" -> pcoll;\n'
+            '"\\"[1]\\": \\"Create\\\\\\"" -> pcoll;\n'
             '}\n'),
         pipeline_graph.PipelineGraph(p).get_dot())
 
@@ -119,17 +119,17 @@ class PipelineGraphTest(unittest.TestCase):
     self.assertEqual((
         'digraph G {\n'
         'node [color=blue, fontcolor=blue, shape=box];\n'
-        '"Cell 2: Init";\n'
+        '"[2]: Init";\n'
         'init_pcoll [shape=circle];\n'
-        '"Cell 3: Square";\n'
+        '"[3]: Square";\n'
         'squares [shape=circle];\n'
-        '"Cell 4: Cube";\n'
+        '"[4]: Cube";\n'
         'cubes [shape=circle];\n'
-        '"Cell 2: Init" -> init_pcoll;\n'
-        'init_pcoll -> "Cell 3: Square";\n'
-        'init_pcoll -> "Cell 4: Cube";\n'
-        '"Cell 3: Square" -> squares;\n'
-        '"Cell 4: Cube" -> cubes;\n'
+        '"[2]: Init" -> init_pcoll;\n'
+        'init_pcoll -> "[3]: Square";\n'
+        'init_pcoll -> "[4]: Cube";\n'
+        '"[3]: Square" -> squares;\n'
+        '"[4]: Cube" -> cubes;\n'
         '}\n'),
                      pipeline_graph.PipelineGraph(p).get_dot())
 
diff --git a/sdks/python/apache_beam/utils/interactive_utils.py b/sdks/python/apache_beam/utils/interactive_utils.py
index 9820db9..a1afb20 100644
--- a/sdks/python/apache_beam/utils/interactive_utils.py
+++ b/sdks/python/apache_beam/utils/interactive_utils.py
@@ -87,7 +87,7 @@ def alter_label_if_ipython(transform, pvalueish):
         # We only alter for transforms to be applied to user-defined pipelines
         # at pipeline construction time.
         and pipeline in ie.current_env().tracked_user_pipelines):
-      transform.label = 'Cell {}: {}'.format(prompt, transform.label)
+      transform.label = '[{}]: {}'.format(prompt, transform.label)
 
 
 def _extract_pipeline_of_pvalueish(pvalueish):