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

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_r387292177
 
 

 ##########
 File path: 
sdks/python/apache_beam/runners/interactive/interactive_environment.py
 ##########
 @@ -43,6 +43,55 @@
 
 _LOGGER = logging.getLogger(__name__)
 
+# By `format(customized_script=xxx)`, the given `customized_script` is
+# guaranteed to be executed within access to a jquery with datatable plugin
+# configured which is useful so that any `customized_script` is resilient to
+# browser refresh. Inside `customized_script`, use `$` as jQuery.
+_JQUERY_WITH_DATATABLE_TEMPLATE = """
+        if (typeof window.jquery341 == 'undefined') {{
 
 Review comment:
   It's an arbitrary name we give to the jQuery v3.4.1 we imported. It's like a 
namesapce. Note the magic happens in `window.jquery341 = 
jQuery.noConflict(true);`.
   The problem here is that:
   1. A frontend can connect to the kernel at any time: code executed by kernel 
in the past does not have any effect to new frontends.
   2. Multiple frontends can connect to the same kernel: each frontend has its 
own state (browser: HTML and JS), the rendered HTML+JS cannot assume the 
existence of any global variable, function definition or libraries.
   
   This ensures no matter how many jQuery gets imported at any time, the 
interactive notebook always checks and uses the single jQuery configured by 
interactive modules with Datatable plugin initialized.
   And the `function($)` signature ensures that any customized script executed 
will use `$` as the singleton instance  `window.jquery341`. This ensures that 
code reading `$` as jQuery will always work.
   The advantage of doing this isolation is:
   1. The JS imported by interactive modules to any frontend does not alter 
their existing states. Everything in the notebook still works as it was no 
matter what libraries and global vars have been used.
   2. HTML with JS rendered by interactive modules will have determined 
behavior because it always uses the same libraries.
   3. Whether/when a frontend is connected to the kernel doesn't matter now. 
The visualization HTML contains everything it needs to setup and/or execute 
scripts.
   4. Arbitrary DOM changes doesn't matter now. Even if the user screws the 
notebook's HTML, the data visualization broadcast from kernels will always be 
rendered correctly.
 
----------------------------------------------------------------
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: 397109)
    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