You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by GitBox <gi...@apache.org> on 2020/03/17 19:32:42 UTC

[GitHub] [beam] pabloem commented on a change in pull request #11147: [BEAM-7923] Support dict and iterable PCollections in show

pabloem commented on a change in pull request #11147: [BEAM-7923] Support dict and iterable PCollections in show
URL: https://github.com/apache/beam/pull/11147#discussion_r393920308
 
 

 ##########
 File path: sdks/python/apache_beam/runners/interactive/interactive_beam.py
 ##########
 @@ -276,6 +284,21 @@ def show(*pcolls, **configs):
       # PCollection `square` and PCollection `cube`, then visualizes them.
       show(square, cube)
   """
+  flatten_pcolls = []
+  for pcoll_container in pcolls:
+    if isinstance(pcoll_container, dict):
+      flatten_pcolls.extend(pcoll_container.values())
+    elif isinstance(pcoll_container, beam.pvalue.PCollection):
+      flatten_pcolls.append(pcoll_container)
+    else:
+      try:
+        flatten_pcolls.extend(iter(pcoll_container))
+      except TypeError:
+        _LOGGER.warning(
+            'The given pcoll %s is not a dict, an iterable or a PCollection.',
+            pcoll_container)
+        return
 
 Review comment:
   It may be good to throw a ValueError or the TypeError? WDYT?

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services