KevinGG commented on a change in pull request #11020: [BEAM-7926] Update Data
Visualization
URL: https://github.com/apache/beam/pull/11020#discussion_r387276995
##########
File path:
sdks/python/apache_beam/runners/interactive/display/pcoll_visualization.py
##########
@@ -215,20 +287,32 @@ def display_facets(self, updating_pv=None):
# Ensures that dive, overview and table render the same data because the
# materialized PCollection data might being updated continuously.
data = self._to_dataframe()
+ # String-ify the dictionaries for display because elements of type dict
+ # cannot be ordered.
+ data = data.applymap(lambda x: str(x) if isinstance(x, dict) else x)
if updating_pv:
- self._display_dive(data, updating_pv._dive_display_id)
- self._display_overview(data, updating_pv._overview_display_id)
- self._display_dataframe(data, updating_pv._df_display_id)
+ # Only updates when data is not empty. Otherwise, consider it a bad
+ # iteration and noop since there is nothing to be updated.
+ if data.empty:
+ _LOGGER.debug('Skip a visualization update due to empty data.')
+ else:
+ self._display_dataframe(data.copy(deep=True), updating_pv)
+ if self._display_facets:
+ self._display_dive(data.copy(deep=True), updating_pv)
Review comment:
Because we make different changes (such as formatting and dropping some
columns) to the dataframe before displaying it in these 3 widgets.
For example, window info needs to be formatted for facets-dive and datatable
while getting dropped in facets-overview.
If they share the same instance, the 3 widgets will be altering the same
dataframe object in arbitrary order, get arbitrary mixed output or run into all
kinds of mapping errors.
----------------------------------------------------------------
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]
With regards,
Apache Git Services