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/30 20:20:56 UTC
[beam] branch master updated: [BEAM-7923] Fix datatable on notebook
reloading
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 0f9b59e [BEAM-7923] Fix datatable on notebook reloading
new 122d60f Merge pull request #11262 from KevinGG/BEAM-7923
0f9b59e is described below
commit 0f9b59e14678e525c46f68491c4d04715616ee6b
Author: KevinGG <ka...@gmail.com>
AuthorDate: Mon Mar 30 11:27:24 2020 -0700
[BEAM-7923] Fix datatable on notebook reloading
1. The problem: when a user reloads the browser window of a jupyter
notebook page, the javascripts of all output areas are executed
in an arbitrary order. A datatable's state is gone on the reloading,
thus causing all the javascripts to reinitialize a datatable.
When the Javascripts race with each other, a datatable can be
reinitialized multiple times indeterminably, resulting in multiple
duplicated datatable wrappers being added to the DOM. The datatable
is then rendered with multiple search and pagination web elements.
2. The solution is to disable the javascripts from being executed on
reloading. There is no use of restoring a datatable's state because
the whole window is gone on reloading, thus nothing depends on the
datatable any more. And from the perspective of visualization, the
DOM with datatable web elements already presents, so no need for
datatable javascripts either.
3. Changed the dataframe visualization javascripts to check if a
datatable wrapper exists before invoking an initialization. If there
is no datatable object but there is a wrapper, it means this is a
browser reloading and do nothing.
---
.../apache_beam/runners/interactive/display/pcoll_visualization.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/sdks/python/apache_beam/runners/interactive/display/pcoll_visualization.py b/sdks/python/apache_beam/runners/interactive/display/pcoll_visualization.py
index 873873c..d44a9f3 100644
--- a/sdks/python/apache_beam/runners/interactive/display/pcoll_visualization.py
+++ b/sdks/python/apache_beam/runners/interactive/display/pcoll_visualization.py
@@ -117,10 +117,12 @@ _DATAFRAME_SCRIPT_TEMPLATE = """
var dt;
if ($.fn.dataTable.isDataTable("#{table_id}")) {{
dt = $("#{table_id}").dataTable();
- }} else {{
+ }} else if ($("#{table_id}_wrapper").length == 0) {{
dt = $("#{table_id}").dataTable({{
""" + _DATATABLE_INITIALIZATION_CONFIG + """
}});
+ }} else {{
+ return;
}}
dt.api()
.clear()