[ 
https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=397108&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-397108
 ]

ASF GitHub Bot logged work on BEAM-7926:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 03/Mar/20 22:50
            Start Date: 03/Mar/20 22:50
    Worklog Time Spent: 10m 
      Work Description: KevinGG commented on pull request #11020: [BEAM-7926] 
Update Data Visualization
URL: https://github.com/apache/beam/pull/11020#discussion_r387320751
 
 

 ##########
 File path: 
sdks/python/apache_beam/runners/interactive/display/pcoll_visualization.py
 ##########
 @@ -291,3 +402,81 @@ def _to_dataframe(self):
 
   def _is_one_dimension_type(self, val):
     return type(val) in _one_dimension_types
+
+
+def format_window_info_in_dataframe(data):
+  if 'event_time' in data.columns:
+    data['event_time'] = data['event_time'].apply(event_time_formatter)
+  if 'windows' in data.columns:
+    data['windows'] = data['windows'].apply(windows_formatter)
+  if 'pane_info' in data.columns:
+    data['pane_info'] = data['pane_info'].apply(pane_info_formatter)
+
+
+def event_time_formatter(event_time_us):
+  options = ie.current_env().options
+  to_tz = options.display_timezone
+  try:
+    return (
+        datetime.datetime.utcfromtimestamp(event_time_us / 1000000).replace(
+            tzinfo=tz.tzutc()).astimezone(to_tz).strftime(
+                options.display_timestamp_format))
+  except ValueError:
+    if event_time_us < 0:
+      return 'Min Timestamp'
+    return 'Max Timestamp'
+
+
+def windows_formatter(windows):
+  result = []
+  for w in windows:
+    if isinstance(w, GlobalWindow):
+      result.append(str(w))
+    elif isinstance(w, IntervalWindow):
+      # First get the duration in terms of hours, minutes, seconds, and
+      # micros.
+      duration = w.end.micros - w.start.micros
+      duration_secs = duration // 1000000
+      hours, remainder = divmod(duration_secs, 3600)
+      minutes, seconds = divmod(remainder, 60)
+      micros = (duration - duration_secs * 1000000) % 1000000
+
+      # Construct the duration string. Try and write the string in such a
 
 Review comment:
   This is trying to format a duration potentially with precision at micros, 
not exactly a `datetime`.  It's more like pretty print a `timedelta`. So the 
`strftime` function is not applicable.
 
----------------------------------------------------------------
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:
us...@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 397108)
    Time Spent: 52h  (was: 51h 50m)

> Show PCollection with Interactive Beam in a data-centric user flow
> ------------------------------------------------------------------
>
>                 Key: BEAM-7926
>                 URL: https://issues.apache.org/jira/browse/BEAM-7926
>             Project: Beam
>          Issue Type: New Feature
>          Components: runner-py-interactive
>            Reporter: Ning Kang
>            Assignee: Ning Kang
>            Priority: Major
>          Time Spent: 52h
>  Remaining Estimate: 0h
>
> Support auto plotting / charting of materialized data of a given PCollection 
> with Interactive Beam.
> Say an Interactive Beam pipeline defined as
>  
> {code:java}
> p = beam.Pipeline(InteractiveRunner())
> pcoll = p | 'Transform' >> transform()
> pcoll2 = ...
> pcoll3 = ...{code}
> The use can call a single function and get auto-magical charting of the data.
> e.g.,
> {code:java}
> show(pcoll, pcoll2)
> {code}
> Throughout the process, a pipeline fragment is built to include only 
> transforms necessary to produce the desired pcolls (pcoll and pcoll2) and 
> execute that fragment.
> This makes the Interactive Beam user flow data-centric.
>  
> Detailed 
> [design|https://docs.google.com/document/d/1DYWrT6GL_qDCXhRMoxpjinlVAfHeVilK5Mtf8gO6zxQ/edit#heading=h.v6k2o3roarzz].



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to