[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=337613&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-337613 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 01/Nov/19 23:18 Start Date: 01/Nov/19 23:18 Worklog Time Spent: 10m Work Description: pabloem commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741 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: 337613) Time Spent: 19h 40m (was: 19.5h) > Visualize PCollection with Interactive Beam > --- > > 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: 19h 40m > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=337614&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-337614 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 01/Nov/19 23:19 Start Date: 01/Nov/19 23:19 Worklog Time Spent: 10m Work Description: pabloem commented on issue #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#issuecomment-548981473 Squashed and merged after Ahmet LGTMd, and myself as well. 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: 337614) Time Spent: 19h 50m (was: 19h 40m) > Visualize PCollection with Interactive Beam > --- > > 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: 19h 50m > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=324584&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-324584 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 07/Oct/19 20:13 Start Date: 07/Oct/19 20:13 Worklog Time Spent: 10m Work Description: KevinGG commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741 1. Added pcoll_visualization module to visualize materialized PCollection data. 2. A visualization mainly consists of 3 parts: facets-dive, facets-overview and data-table. 3. The visualization is always async. It has 2 modes: one-shot and dynamical plotting. 4. One-shot visualization renders the visualization as HTML statically. 5. Dynamical plotting polls materialized data, initializes a visualization and then updates the visualization continuously. 6. It's the pipeline state, i.e., whether the PCollection materialization is being updated that decides if the visualization is dynamical plotting or one-shot. It's not the boundedness of PCollection that decides the visualization mode. However, when engineering for Interactive Beam, it's alright to always use the dynamical plotting mode as long as the InteractiveRunner(s) manages jobs and tracks the pipeline(job) results correctly. Failing to terminate a visualization job might cause resource leak. 7. The materialized PCollection data goes through the following process flow: cache -> element list -> normalization -> dataframe -> HTMLs/scripts. 8. A visualization is always self-contained. Meaning it controls when the visualization starts and ends by itself. Once visualized, the visualization is anchored within the notebook cell's output area. Code in other cells can affect the visualization in the cell but will not change the existing visualization's position in the notebook. Multiple visualize(pcoll) calls will render multiple independent distinct visualization instances/jobs. Each visualization runs in its own thread outside of the notebook main thread. 8. Unittest added focusing on the above visualization logic other than the visualization UI (those should belong to Facets, pandas and jQuery, we'll trust them work as intended). Integration tests can be added later. 9. Each visualization job regularly queries interactive environment for running pipeline(job) results implicitly to determine the default visualization end condition. It's based on the limitation that within current interactive environment, at a time, at most one job is in non-terminated state for an end user defined pipeline instance (in whatever state). The end user could also use the handle returned by visualize() to stop() the visualization job manually. Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily: - [x] [**Choose reviewer(s)**](https://beam.apache.org/contribute/#make-your-change) and mention them in a comment (`R: @username`). - [x] Format the pull request title like `[BEAM-XXX] Fixes bug in ApproximateQuantiles`, where you replace `BEAM-XXX` with the appropriate JIRA issue, if applicable. This will automatically link the pull request to the issue. - [x] If this contribution is large, please file an Apache [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf). Post-Commit Tests Status (on master branch) Lang | SDK | Apex | Dataflow | Flink | Gearpump | Samza | Spark --- | --- | --- | --- | --- | --- | --- | --- Go | [![Build Status](https://builds.apache.org/job/beam_PostCommit_Go/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Go/lastCompletedBuild/) | --- | --- | [![Build Status](https://builds.apache.org/job/beam_PostCommit_Go_VR_Flink/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Go_VR_Flink/lastCompletedBuild/) | --- | --- | [![Build Status](https://builds.apache.org/job/beam_PostCommit_Go_VR_Spark/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Go_VR_Spark/lastCompletedBuild/) Java | [![Build Status](https://builds.apache.org/job/beam_PostCommit_Java/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Java/lastCompletedBuild/) | [![Build Status](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Apex/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Apex/lastCompletedBuild/) | [![Build Status](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_D
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=324587&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-324587 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 07/Oct/19 20:31 Start Date: 07/Oct/19 20:31 Worklog Time Spent: 10m Work Description: KevinGG commented on issue #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#issuecomment-539191219 R:rohdesamuel PTAL. Will fix the precommit checks once they are done add aaltay@ later. 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: 324587) Time Spent: 20m (was: 10m) > Visualize PCollection with Interactive Beam > --- > > 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: 20m > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=324589&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-324589 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 07/Oct/19 20:31 Start Date: 07/Oct/19 20:31 Worklog Time Spent: 10m Work Description: KevinGG commented on issue #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#issuecomment-539191219 R:@rohdesamuel PTAL. Will fix the precommit checks once they are done add aaltay@ later. 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: 324589) Time Spent: 0.5h (was: 20m) > Visualize PCollection with Interactive Beam > --- > > 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: 0.5h > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=326043&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-326043 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 10/Oct/19 00:21 Start Date: 10/Oct/19 00:21 Worklog Time Spent: 10m Work Description: KevinGG commented on issue #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#issuecomment-540263254 R: @aaltay R: @rohdesamuel PTAL, thanks! 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: 326043) Time Spent: 40m (was: 0.5h) > Visualize PCollection with Interactive Beam > --- > > 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: 40m > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=326081&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-326081 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 10/Oct/19 02:48 Start Date: 10/Oct/19 02:48 Worklog Time Spent: 10m Work Description: aaltay commented on issue #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#issuecomment-540310351 I will wait for @rohdesamuel to make the first review pass. Could you also check the failing tests please? 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: 326081) Time Spent: 50m (was: 40m) > Visualize PCollection with Interactive Beam > --- > > 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: 50m > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=326492&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-326492 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 10/Oct/19 18:29 Start Date: 10/Oct/19 18:29 Worklog Time Spent: 10m Work Description: KevinGG commented on issue #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#issuecomment-540713909 > I will wait for @rohdesamuel to make the first review pass. Could you also check the failing tests please? Sure! I'll fix the import errors from Python2 tests. 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: 326492) Time Spent: 1h (was: 50m) > Visualize PCollection with Interactive Beam > --- > > 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: 1h > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=326889&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-326889 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 11/Oct/19 13:11 Start Date: 11/Oct/19 13:11 Worklog Time Spent: 10m Work Description: leonardoam commented on pull request #9771: [BEAM-7926] Update dependencies in Java Katas URL: https://github.com/apache/beam/pull/9771 Update several Java Katas dependencies. Specially, upgrade Gradle from 4.8 to 5.0 and fix deprecated declaration. ``` Updates: Gradle: 4.8 -> 5.0 (and fix deprecated build-in task overwritten declaration) org.apache.beam:beam-sdks-java-core: 2.13.0 -> 2.16.0 org.apache.beam:beam-runners-direct-java: 2.13.0 -> 2.16.0 com.google.guava:guava: 27.1-jre -> 28.1-jre joda-time:joda-time: 2.10.3 -> 2.10.4 org.slf4j:slf4j-api: 1.7.26 -> 1.7.28 org.apache.logging.log4j:log4j-slf4j-impl: 2.11.2 -> 2.12.1 org.assertj:assertj-core: 3.12.2 -> 3.13.2 org.hamcrest:hamcrest-core: 1.3 -> 2.1 org.hamcrest:hamcrest-library: 1.3 -> 2.1 ``` R: @henryken @reuvenlax Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily: - [X] [**Choose reviewer(s)**](https://beam.apache.org/contribute/#make-your-change) and mention them in a comment (`R: @username`). - [X] Format the pull request title like `[BEAM-XXX] Fixes bug in ApproximateQuantiles`, where you replace `BEAM-XXX` with the appropriate JIRA issue, if applicable. This will automatically link the pull request to the issue. - [X] If this contribution is large, please file an Apache [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf). Post-Commit Tests Status (on master branch) Lang | SDK | Apex | Dataflow | Flink | Gearpump | Samza | Spark --- | --- | --- | --- | --- | --- | --- | --- Go | [![Build Status](https://builds.apache.org/job/beam_PostCommit_Go/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Go/lastCompletedBuild/) | --- | --- | [![Build Status](https://builds.apache.org/job/beam_PostCommit_Go_VR_Flink/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Go_VR_Flink/lastCompletedBuild/) | --- | --- | [![Build Status](https://builds.apache.org/job/beam_PostCommit_Go_VR_Spark/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Go_VR_Spark/lastCompletedBuild/) Java | [![Build Status](https://builds.apache.org/job/beam_PostCommit_Java/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Java/lastCompletedBuild/) | [![Build Status](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Apex/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Apex/lastCompletedBuild/) | [![Build Status](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Dataflow/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Dataflow/lastCompletedBuild/) | [![Build Status](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Flink/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Flink/lastCompletedBuild/)[![Build Status](https://builds.apache.org/job/beam_PostCommit_Java_PVR_Flink_Batch/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Java_PVR_Flink_Batch/lastCompletedBuild/)[![Build Status](https://builds.apache.org/job/beam_PostCommit_Java_PVR_Flink_Streaming/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Java_PVR_Flink_Streaming/lastCompletedBuild/) | [![Build Status](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Gearpump/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Gearpump/lastCompletedBuild/) | [![Build Status](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Samza/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Samza/lastCompletedBuild/) | [![Build Status](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Spark/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Spark/lastCompletedBuild/)[![Build Status](https://builds.apache.org/job/beam_PostCommit_Java_PVR_Spark_Batch/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Java_PVR_Spark_Ba
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=327154&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-327154 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 11/Oct/19 23:59 Start Date: 11/Oct/19 23:59 Worklog Time Spent: 10m Work Description: KevinGG commented on issue #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#issuecomment-541259707 Hi @pabloem , thanks for volunteering to review this PR! I've fixed most of the test related issues. There is a Python fatal stack overflow error that I couldn't really make sense of. It seems that the error exists before my change but past Jenkins tests skipped it due to some execution ordering reason? I've asked the question to the dev mail list: https://mail.google.com/mail/u/0?ui=2&ik=64050edf4e&view=lg&permmsgid=msg-f%3A1647143158414277283&ser=1 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: 327154) Time Spent: 1h 20m (was: 1h 10m) > Visualize PCollection with Interactive Beam > --- > > 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: 1h 20m > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=327155&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-327155 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 12/Oct/19 00:01 Start Date: 12/Oct/19 00:01 Worklog Time Spent: 10m Work Description: KevinGG commented on issue #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#issuecomment-541259707 Hi @pabloem , thanks for volunteering to review this PR! I've fixed most of the test related issues. There is a Python fatal stack overflow error that I couldn't really make sense of. It seems that the error exists before my change but past Jenkins tests skipped it due to some execution ordering reason? I've asked the question to the dev mail list: https://mail.google.com/mail/u/0?ui=2&ik=c25ee601a8&view=lg&permmsgid=msg-a%3Ar421316325553969817 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: 327155) Time Spent: 1.5h (was: 1h 20m) > Visualize PCollection with Interactive Beam > --- > > 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: 1.5h > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=328245&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-328245 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 15/Oct/19 01:06 Start Date: 15/Oct/19 01:06 Worklog Time Spent: 10m Work Description: aaltay commented on issue #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#issuecomment-541991427 Any updates @rohdesamuel @KevinGG ? 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: 328245) Time Spent: 1h 40m (was: 1.5h) > Visualize PCollection with Interactive Beam > --- > > 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: 1h 40m > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=329333&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-329333 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 16/Oct/19 18:45 Start Date: 16/Oct/19 18:45 Worklog Time Spent: 10m Work Description: KevinGG commented on issue #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#issuecomment-542839019 > Any updates @rohdesamuel @KevinGG ? Just trying to get unblocked by tinkering the setup.py. Thanks Valentyn for helping me investigating the issue. We filed a bug: BEAM-8397 There is something weird going on in the code base that some times lead tox suite or nose test into stack overflow. And a workaround by lowering upper-bound of ipython in the setup seems to help. Once the pre-commit passes, I'll notify Sam to do a first iteration and ping you after. Thanks! 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: 329333) Time Spent: 1h 50m (was: 1h 40m) > Visualize PCollection with Interactive Beam > --- > > 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: 1h 50m > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=329365&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-329365 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 16/Oct/19 20:25 Start Date: 16/Oct/19 20:25 Worklog Time Spent: 10m Work Description: KevinGG commented on issue #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#issuecomment-542876876 retest this please. 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: 329365) Time Spent: 2h (was: 1h 50m) > Visualize PCollection with Interactive Beam > --- > > 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: 2h > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=329462&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-329462 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 16/Oct/19 22:32 Start Date: 16/Oct/19 22:32 Worklog Time Spent: 10m Work Description: KevinGG commented on issue #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#issuecomment-542918457 retest this please. 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: 329462) Time Spent: 2h 10m (was: 2h) > Visualize PCollection with Interactive Beam > --- > > 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: 2h 10m > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=330025&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-330025 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 17/Oct/19 17:34 Start Date: 17/Oct/19 17:34 Worklog Time Spent: 10m Work Description: KevinGG commented on issue #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#issuecomment-543282061 retest this please. 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: 330025) Time Spent: 2h 20m (was: 2h 10m) > Visualize PCollection with Interactive Beam > --- > > 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: 2h 20m > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=330029&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-330029 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 17/Oct/19 17:45 Start Date: 17/Oct/19 17:45 Worklog Time Spent: 10m Work Description: pabloem commented on issue #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#issuecomment-543286382 FYI you don't need to retest the whole thing. You just need to rerun the specific tests that are failing (e.g. Run Portable_Python PreCommit / Run Python PreCommit / Run PythonLint PreCommit / ) 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: 330029) Time Spent: 2.5h (was: 2h 20m) > Visualize PCollection with Interactive Beam > --- > > 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: 2.5h > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=330105&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-330105 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 17/Oct/19 20:00 Start Date: 17/Oct/19 20:00 Worklog Time Spent: 10m Work Description: KevinGG commented on issue #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#issuecomment-543337758 > FYI you don't need to retest the whole thing. You just need to rerun the specific tests that are failing (e.g. Run Portable_Python PreCommit / Run Python PreCommit / Run PythonLint PreCommit / ) Got it. Thanks! Now the tests have passed, we can start reviewing it. 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: 330105) Time Spent: 2h 40m (was: 2.5h) > Visualize PCollection with Interactive Beam > --- > > 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: 2h 40m > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=330176&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-330176 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 17/Oct/19 22:43 Start Date: 17/Oct/19 22:43 Worklog Time Spent: 10m Work Description: aaltay commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r336258249 ## File path: sdks/python/setup.py ## @@ -107,13 +107,17 @@ def get_version(): 'crcmod>=1.7,<2.0', # Dill doesn't guarantee comatibility between releases within minor version. 'dill>=0.3.0,<0.3.1', +'facets-overview>=1.0.0,<2', Review comment: This change is significantly expanding the required Beam dependencies. These dependencies are by default not used by existing users and also would not be needed in execution environments. I suggest making another extras_require similar to gcp and group all interactive dependency requirements under that group. 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: 330176) Time Spent: 2h 50m (was: 2h 40m) > Visualize PCollection with Interactive Beam > --- > > 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: 2h 50m > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=330638&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-330638 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 18/Oct/19 16:48 Start Date: 18/Oct/19 16:48 Worklog Time Spent: 10m Work Description: rohdesamuel commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r336581554 ## File path: sdks/python/apache_beam/runners/interactive/interactive_environment.py ## @@ -105,3 +113,33 @@ def set_cache_manager(self, cache_manager): def cache_manager(self): """Gets the cache manager held by current Interactive Environment.""" return self._cache_manager + + def set_pipeline_result(self, pipeline, result): Review comment: Why do we need this method? It looks like it's only being used in tests. 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: 330638) Time Spent: 3h (was: 2h 50m) > Visualize PCollection with Interactive Beam > --- > > 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: 3h > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=330639&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-330639 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 18/Oct/19 16:50 Start Date: 18/Oct/19 16:50 Worklog Time Spent: 10m Work Description: rohdesamuel commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r336582418 ## File path: sdks/python/apache_beam/runners/interactive/display/pcoll_visualization_test.py ## @@ -0,0 +1,133 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +#http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +"""Tests for apache_beam.runners.interactive.display.pcoll_visualization.""" +from __future__ import absolute_import + +import sys +import time +import unittest + +import timeloop + +import apache_beam as beam +from apache_beam.runners import runner +from apache_beam.runners.interactive import interactive_environment as ie +from apache_beam.runners.interactive.display import pcoll_visualization as pv + +# Work around nose tests using Python2 without unittest.mock module. +try: + from unittest.mock import patch +except ImportError: + from mock import patch + + +class PCollVisualizationTest(unittest.TestCase): + + def setUp(self): +self._p = beam.Pipeline() +# pylint: disable=range-builtin-not-iterating +self._pcoll = self._p | 'Create' >> beam.Create(range(1000)) + + @unittest.skipIf(sys.version_info < (3, 5, 3), + 'PCollVisualization is not supported on Python 2.') + def test_raise_error_for_non_pcoll_input(self): +class Foo(object): + pass + +with self.assertRaises(ValueError) as ctx: + pv.PCollVisualization(Foo()) + self.assertTrue('pcoll should be apache_beam.pvalue.PCollection' in + ctx.exception) + + @unittest.skipIf(sys.version_info < (3, 5, 3), Review comment: Is there a way to do this check only once? Maybe in the module's "if __name__ == "main""? 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: 330639) Time Spent: 3h 10m (was: 3h) > Visualize PCollection with Interactive Beam > --- > > 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: 3h 10m > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=330642&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-330642 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 18/Oct/19 16:52 Start Date: 18/Oct/19 16:52 Worklog Time Spent: 10m Work Description: rohdesamuel commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r336583208 ## File path: sdks/python/apache_beam/runners/interactive/display/pcoll_visualization.py ## @@ -0,0 +1,258 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +#http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +"""Module visualizes PCollection data. + +For internal use only; no backwards-compatibility guarantees. +Only works with Python 3.5+. +""" +from __future__ import absolute_import + +import base64 +import logging +from datetime import timedelta + +from facets_overview.generic_feature_statistics_generator import GenericFeatureStatisticsGenerator +from IPython.core.display import HTML +from IPython.core.display import Javascript +from IPython.core.display import display +from IPython.core.display import display_javascript +from IPython.core.display import update_display +from pandas.io.json import json_normalize +from timeloop import Timeloop + +from apache_beam import pvalue +from apache_beam.runners.interactive import interactive_environment as ie +from apache_beam.runners.interactive import pipeline_instrument as instr + +# jsons doesn't support < Python 3.5. Work around with json for legacy tests. +try: + import jsons + _pv_jsons_load = jsons.load + _pv_jsons_dump = jsons.dump +except ImportError: + import json + _pv_jsons_load = json.load + _pv_jsons_dump = json.dump + +# 1-d types that need additional normalization to be compatible with DataFrame. +_one_dimension_types = (int, float, str, bool, list, tuple) + +_DIVE_SCRIPT_TEMPLATE = """ +document.querySelector("#{display_id}").data = {jsonstr};""" +_DIVE_HTML_TEMPLATE = """ +https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/1.3.3/webcomponents-lite.js";> +https://raw.githubusercontent.com/PAIR-code/facets/1.0.0/facets-dist/facets-jupyter.html";> + + + document.querySelector("#{display_id}").data = {jsonstr}; +""" +_OVERVIEW_SCRIPT_TEMPLATE = """ + document.querySelector("#{display_id}").protoInput = "{protostr}"; + """ +_OVERVIEW_HTML_TEMPLATE = """ +https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/1.3.3/webcomponents-lite.js";> +https://raw.githubusercontent.com/PAIR-code/facets/1.0.0/facets-dist/facets-jupyter.html";> + + + document.querySelector("#{display_id}").protoInput = "{protostr}"; +""" +_DATAFRAME_PAGINATION_TEMPLATE = """ +https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js";> +https://cdn.datatables.net/1.10.16/js/jquery.dataTables.js";> +https://cdn.datatables.net/1.10.16/css/jquery.dataTables.css";> +{dataframe_html} + + $("#{table_id}").DataTable(); +""" + + +def visualize(pcoll, dynamical_plotting_interval=None): + """Visualizes the data of a given PCollection. Optionally enables dynamical + plotting with interval in seconds if the PCollection is being produced by a + running pipeline or the pipeline is streaming indefinitely. The function + always returns immediately and is asynchronous when dynamical plotting is on. + + If dynamical plotting enabled, the visualization is updated continuously until + the pipeline producing the PCollection is in an end state. The visualization + would be anchored to the notebook cell output area. The function + asynchronously returns a handle to the visualization job immediately. The user + could manually do:: + +# In one notebook cell, enable dynamical plotting every 1 second: +handle = visualize(pcoll, dynamical_plotting_interval=1) Review comment: Please change "dynamical" to
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=330645&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-330645 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 18/Oct/19 16:54 Start Date: 18/Oct/19 16:54 Worklog Time Spent: 10m Work Description: rohdesamuel commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r336583985 ## File path: sdks/python/apache_beam/runners/interactive/display/pcoll_visualization.py ## @@ -0,0 +1,258 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +#http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +"""Module visualizes PCollection data. + +For internal use only; no backwards-compatibility guarantees. +Only works with Python 3.5+. +""" +from __future__ import absolute_import + +import base64 +import logging +from datetime import timedelta + +from facets_overview.generic_feature_statistics_generator import GenericFeatureStatisticsGenerator +from IPython.core.display import HTML +from IPython.core.display import Javascript +from IPython.core.display import display +from IPython.core.display import display_javascript +from IPython.core.display import update_display +from pandas.io.json import json_normalize +from timeloop import Timeloop + +from apache_beam import pvalue +from apache_beam.runners.interactive import interactive_environment as ie +from apache_beam.runners.interactive import pipeline_instrument as instr + +# jsons doesn't support < Python 3.5. Work around with json for legacy tests. +try: + import jsons + _pv_jsons_load = jsons.load + _pv_jsons_dump = jsons.dump +except ImportError: + import json + _pv_jsons_load = json.load + _pv_jsons_dump = json.dump + +# 1-d types that need additional normalization to be compatible with DataFrame. +_one_dimension_types = (int, float, str, bool, list, tuple) + +_DIVE_SCRIPT_TEMPLATE = """ +document.querySelector("#{display_id}").data = {jsonstr};""" +_DIVE_HTML_TEMPLATE = """ +https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/1.3.3/webcomponents-lite.js";> +https://raw.githubusercontent.com/PAIR-code/facets/1.0.0/facets-dist/facets-jupyter.html";> + + + document.querySelector("#{display_id}").data = {jsonstr}; +""" +_OVERVIEW_SCRIPT_TEMPLATE = """ + document.querySelector("#{display_id}").protoInput = "{protostr}"; + """ +_OVERVIEW_HTML_TEMPLATE = """ +https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/1.3.3/webcomponents-lite.js";> +https://raw.githubusercontent.com/PAIR-code/facets/1.0.0/facets-dist/facets-jupyter.html";> + + + document.querySelector("#{display_id}").protoInput = "{protostr}"; +""" +_DATAFRAME_PAGINATION_TEMPLATE = """ +https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js";> +https://cdn.datatables.net/1.10.16/js/jquery.dataTables.js";> +https://cdn.datatables.net/1.10.16/css/jquery.dataTables.css";> +{dataframe_html} + + $("#{table_id}").DataTable(); +""" + + +def visualize(pcoll, dynamical_plotting_interval=None): + """Visualizes the data of a given PCollection. Optionally enables dynamical + plotting with interval in seconds if the PCollection is being produced by a + running pipeline or the pipeline is streaming indefinitely. The function + always returns immediately and is asynchronous when dynamical plotting is on. + + If dynamical plotting enabled, the visualization is updated continuously until + the pipeline producing the PCollection is in an end state. The visualization + would be anchored to the notebook cell output area. The function + asynchronously returns a handle to the visualization job immediately. The user + could manually do:: + +# In one notebook cell, enable dynamical plotting every 1 second: +handle = visualize(pcoll, dynamical_plotting_interval=1) +# Visualization anchored to the cell's output
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=330646&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-330646 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 18/Oct/19 16:57 Start Date: 18/Oct/19 16:57 Worklog Time Spent: 10m Work Description: rohdesamuel commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r336585148 ## File path: sdks/python/apache_beam/runners/interactive/display/pcoll_visualization.py ## @@ -0,0 +1,258 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +#http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +"""Module visualizes PCollection data. + +For internal use only; no backwards-compatibility guarantees. +Only works with Python 3.5+. +""" +from __future__ import absolute_import + +import base64 +import logging +from datetime import timedelta + +from facets_overview.generic_feature_statistics_generator import GenericFeatureStatisticsGenerator +from IPython.core.display import HTML +from IPython.core.display import Javascript +from IPython.core.display import display +from IPython.core.display import display_javascript +from IPython.core.display import update_display +from pandas.io.json import json_normalize +from timeloop import Timeloop + +from apache_beam import pvalue +from apache_beam.runners.interactive import interactive_environment as ie +from apache_beam.runners.interactive import pipeline_instrument as instr + +# jsons doesn't support < Python 3.5. Work around with json for legacy tests. +try: + import jsons + _pv_jsons_load = jsons.load + _pv_jsons_dump = jsons.dump +except ImportError: + import json + _pv_jsons_load = json.load + _pv_jsons_dump = json.dump + +# 1-d types that need additional normalization to be compatible with DataFrame. +_one_dimension_types = (int, float, str, bool, list, tuple) + +_DIVE_SCRIPT_TEMPLATE = """ +document.querySelector("#{display_id}").data = {jsonstr};""" +_DIVE_HTML_TEMPLATE = """ +https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/1.3.3/webcomponents-lite.js";> +https://raw.githubusercontent.com/PAIR-code/facets/1.0.0/facets-dist/facets-jupyter.html";> + + + document.querySelector("#{display_id}").data = {jsonstr}; +""" +_OVERVIEW_SCRIPT_TEMPLATE = """ + document.querySelector("#{display_id}").protoInput = "{protostr}"; + """ +_OVERVIEW_HTML_TEMPLATE = """ +https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/1.3.3/webcomponents-lite.js";> +https://raw.githubusercontent.com/PAIR-code/facets/1.0.0/facets-dist/facets-jupyter.html";> + + + document.querySelector("#{display_id}").protoInput = "{protostr}"; +""" +_DATAFRAME_PAGINATION_TEMPLATE = """ +https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js";> +https://cdn.datatables.net/1.10.16/js/jquery.dataTables.js";> +https://cdn.datatables.net/1.10.16/css/jquery.dataTables.css";> +{dataframe_html} + + $("#{table_id}").DataTable(); +""" + + +def visualize(pcoll, dynamical_plotting_interval=None): + """Visualizes the data of a given PCollection. Optionally enables dynamical + plotting with interval in seconds if the PCollection is being produced by a + running pipeline or the pipeline is streaming indefinitely. The function + always returns immediately and is asynchronous when dynamical plotting is on. + + If dynamical plotting enabled, the visualization is updated continuously until + the pipeline producing the PCollection is in an end state. The visualization + would be anchored to the notebook cell output area. The function + asynchronously returns a handle to the visualization job immediately. The user + could manually do:: + +# In one notebook cell, enable dynamical plotting every 1 second: +handle = visualize(pcoll, dynamical_plotting_interval=1) +# Visualization anchored to the cell's output
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=330647&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-330647 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 18/Oct/19 16:59 Start Date: 18/Oct/19 16:59 Worklog Time Spent: 10m Work Description: rohdesamuel commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r336586086 ## File path: sdks/python/apache_beam/runners/interactive/display/pcoll_visualization.py ## @@ -0,0 +1,258 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +#http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +"""Module visualizes PCollection data. + +For internal use only; no backwards-compatibility guarantees. +Only works with Python 3.5+. +""" +from __future__ import absolute_import + +import base64 +import logging +from datetime import timedelta + +from facets_overview.generic_feature_statistics_generator import GenericFeatureStatisticsGenerator +from IPython.core.display import HTML +from IPython.core.display import Javascript +from IPython.core.display import display +from IPython.core.display import display_javascript +from IPython.core.display import update_display +from pandas.io.json import json_normalize +from timeloop import Timeloop + +from apache_beam import pvalue +from apache_beam.runners.interactive import interactive_environment as ie +from apache_beam.runners.interactive import pipeline_instrument as instr + +# jsons doesn't support < Python 3.5. Work around with json for legacy tests. +try: + import jsons + _pv_jsons_load = jsons.load + _pv_jsons_dump = jsons.dump +except ImportError: + import json + _pv_jsons_load = json.load + _pv_jsons_dump = json.dump + +# 1-d types that need additional normalization to be compatible with DataFrame. +_one_dimension_types = (int, float, str, bool, list, tuple) + +_DIVE_SCRIPT_TEMPLATE = """ +document.querySelector("#{display_id}").data = {jsonstr};""" +_DIVE_HTML_TEMPLATE = """ +https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/1.3.3/webcomponents-lite.js";> +https://raw.githubusercontent.com/PAIR-code/facets/1.0.0/facets-dist/facets-jupyter.html";> + + + document.querySelector("#{display_id}").data = {jsonstr}; +""" +_OVERVIEW_SCRIPT_TEMPLATE = """ + document.querySelector("#{display_id}").protoInput = "{protostr}"; + """ +_OVERVIEW_HTML_TEMPLATE = """ +https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/1.3.3/webcomponents-lite.js";> +https://raw.githubusercontent.com/PAIR-code/facets/1.0.0/facets-dist/facets-jupyter.html";> + + + document.querySelector("#{display_id}").protoInput = "{protostr}"; +""" +_DATAFRAME_PAGINATION_TEMPLATE = """ +https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js";> +https://cdn.datatables.net/1.10.16/js/jquery.dataTables.js";> +https://cdn.datatables.net/1.10.16/css/jquery.dataTables.css";> +{dataframe_html} + + $("#{table_id}").DataTable(); +""" + + +def visualize(pcoll, dynamical_plotting_interval=None): + """Visualizes the data of a given PCollection. Optionally enables dynamical + plotting with interval in seconds if the PCollection is being produced by a + running pipeline or the pipeline is streaming indefinitely. The function + always returns immediately and is asynchronous when dynamical plotting is on. + + If dynamical plotting enabled, the visualization is updated continuously until + the pipeline producing the PCollection is in an end state. The visualization + would be anchored to the notebook cell output area. The function + asynchronously returns a handle to the visualization job immediately. The user + could manually do:: + +# In one notebook cell, enable dynamical plotting every 1 second: +handle = visualize(pcoll, dynamical_plotting_interval=1) +# Visualization anchored to the cell's output
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=330648&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-330648 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 18/Oct/19 17:01 Start Date: 18/Oct/19 17:01 Worklog Time Spent: 10m Work Description: rohdesamuel commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r336586553 ## File path: sdks/python/apache_beam/runners/interactive/display/pcoll_visualization.py ## @@ -0,0 +1,258 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +#http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +"""Module visualizes PCollection data. + +For internal use only; no backwards-compatibility guarantees. +Only works with Python 3.5+. +""" +from __future__ import absolute_import + +import base64 +import logging +from datetime import timedelta + +from facets_overview.generic_feature_statistics_generator import GenericFeatureStatisticsGenerator +from IPython.core.display import HTML +from IPython.core.display import Javascript +from IPython.core.display import display +from IPython.core.display import display_javascript +from IPython.core.display import update_display +from pandas.io.json import json_normalize +from timeloop import Timeloop + +from apache_beam import pvalue +from apache_beam.runners.interactive import interactive_environment as ie +from apache_beam.runners.interactive import pipeline_instrument as instr + +# jsons doesn't support < Python 3.5. Work around with json for legacy tests. +try: + import jsons + _pv_jsons_load = jsons.load + _pv_jsons_dump = jsons.dump +except ImportError: + import json + _pv_jsons_load = json.load + _pv_jsons_dump = json.dump + +# 1-d types that need additional normalization to be compatible with DataFrame. +_one_dimension_types = (int, float, str, bool, list, tuple) + +_DIVE_SCRIPT_TEMPLATE = """ +document.querySelector("#{display_id}").data = {jsonstr};""" +_DIVE_HTML_TEMPLATE = """ +https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/1.3.3/webcomponents-lite.js";> +https://raw.githubusercontent.com/PAIR-code/facets/1.0.0/facets-dist/facets-jupyter.html";> + + + document.querySelector("#{display_id}").data = {jsonstr}; +""" +_OVERVIEW_SCRIPT_TEMPLATE = """ + document.querySelector("#{display_id}").protoInput = "{protostr}"; + """ +_OVERVIEW_HTML_TEMPLATE = """ +https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/1.3.3/webcomponents-lite.js";> +https://raw.githubusercontent.com/PAIR-code/facets/1.0.0/facets-dist/facets-jupyter.html";> + + + document.querySelector("#{display_id}").protoInput = "{protostr}"; +""" +_DATAFRAME_PAGINATION_TEMPLATE = """ +https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js";> +https://cdn.datatables.net/1.10.16/js/jquery.dataTables.js";> +https://cdn.datatables.net/1.10.16/css/jquery.dataTables.css";> +{dataframe_html} + + $("#{table_id}").DataTable(); +""" + + +def visualize(pcoll, dynamical_plotting_interval=None): Review comment: How does one stop visualizing a PCollection? 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: 330648) Time Spent: 4h (was: 3h 50m) > Visualize PCollection with Interactive Beam > --- > > 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 >
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=330649&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-330649 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 18/Oct/19 17:02 Start Date: 18/Oct/19 17:02 Worklog Time Spent: 10m Work Description: rohdesamuel commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r336582418 ## File path: sdks/python/apache_beam/runners/interactive/display/pcoll_visualization_test.py ## @@ -0,0 +1,133 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +#http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +"""Tests for apache_beam.runners.interactive.display.pcoll_visualization.""" +from __future__ import absolute_import + +import sys +import time +import unittest + +import timeloop + +import apache_beam as beam +from apache_beam.runners import runner +from apache_beam.runners.interactive import interactive_environment as ie +from apache_beam.runners.interactive.display import pcoll_visualization as pv + +# Work around nose tests using Python2 without unittest.mock module. +try: + from unittest.mock import patch +except ImportError: + from mock import patch + + +class PCollVisualizationTest(unittest.TestCase): + + def setUp(self): +self._p = beam.Pipeline() +# pylint: disable=range-builtin-not-iterating +self._pcoll = self._p | 'Create' >> beam.Create(range(1000)) + + @unittest.skipIf(sys.version_info < (3, 5, 3), + 'PCollVisualization is not supported on Python 2.') + def test_raise_error_for_non_pcoll_input(self): +class Foo(object): + pass + +with self.assertRaises(ValueError) as ctx: + pv.PCollVisualization(Foo()) + self.assertTrue('pcoll should be apache_beam.pvalue.PCollection' in + ctx.exception) + + @unittest.skipIf(sys.version_info < (3, 5, 3), Review comment: Is there a way to do this check only once? Maybe in the module's "if \_\_name\_\_ == "main""? 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: 330649) Time Spent: 4h 10m (was: 4h) > Visualize PCollection with Interactive Beam > --- > > 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: 4h 10m > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=330653&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-330653 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 18/Oct/19 17:04 Start Date: 18/Oct/19 17:04 Worklog Time Spent: 10m Work Description: rohdesamuel commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r336587840 ## File path: sdks/python/apache_beam/runners/interactive/display/pcoll_visualization_test.py ## @@ -0,0 +1,133 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +#http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +"""Tests for apache_beam.runners.interactive.display.pcoll_visualization.""" +from __future__ import absolute_import + +import sys +import time +import unittest + +import timeloop + +import apache_beam as beam +from apache_beam.runners import runner +from apache_beam.runners.interactive import interactive_environment as ie +from apache_beam.runners.interactive.display import pcoll_visualization as pv + +# Work around nose tests using Python2 without unittest.mock module. +try: + from unittest.mock import patch +except ImportError: + from mock import patch + + +class PCollVisualizationTest(unittest.TestCase): + + def setUp(self): +self._p = beam.Pipeline() +# pylint: disable=range-builtin-not-iterating +self._pcoll = self._p | 'Create' >> beam.Create(range(1000)) + + @unittest.skipIf(sys.version_info < (3, 5, 3), + 'PCollVisualization is not supported on Python 2.') + def test_raise_error_for_non_pcoll_input(self): +class Foo(object): + pass + +with self.assertRaises(ValueError) as ctx: + pv.PCollVisualization(Foo()) + self.assertTrue('pcoll should be apache_beam.pvalue.PCollection' in + ctx.exception) + + @unittest.skipIf(sys.version_info < (3, 5, 3), + 'PCollVisualization is not supported on Python 2.') + def test_pcoll_visualization_generate_unique_display_id(self): +pv_1 = pv.PCollVisualization(self._pcoll) +pv_2 = pv.PCollVisualization(self._pcoll) +self.assertNotEqual(pv_1._dive_display_id, pv_2._dive_display_id) +self.assertNotEqual(pv_1._overview_display_id, pv_2._overview_display_id) +self.assertNotEqual(pv_1._df_display_id, pv_2._df_display_id) + + @unittest.skipIf(sys.version_info < (3, 5, 3), + 'PCollVisualization is not supported on Python 2.') + @patch('apache_beam.runners.interactive.display.pcoll_visualization' + '.PCollVisualization._to_element_list', lambda x: [1, 2, 3]) + def test_one_shot_visualization_not_return_handle(self): +self.assertIsNone(pv.visualize(self._pcoll)) + + def _mock_to_element_list(self): +yield [1, 2, 3] +yield [1, 2, 3, 4] + + @unittest.skipIf(sys.version_info < (3, 5, 3), + 'PCollVisualization is not supported on Python 2.') + @patch('apache_beam.runners.interactive.display.pcoll_visualization' + '.PCollVisualization._to_element_list', _mock_to_element_list) + def test_dynamical_plotting_return_handle(self): +h = pv.visualize(self._pcoll, dynamical_plotting_interval=1) +self.assertIsInstance(h, timeloop.Timeloop) +h.stop() + + @unittest.skipIf(sys.version_info < (3, 5, 3), + 'PCollVisualization is not supported on Python 2.') + @patch('apache_beam.runners.interactive.display.pcoll_visualization' + '.PCollVisualization._to_element_list', _mock_to_element_list) + @patch('apache_beam.runners.interactive.display.pcoll_visualization' + '.PCollVisualization.display_facets') + def test_dynamical_plotting_update_same_display(self, + mocked_display_facets): +# Starts async dynamical plotting. +h = pv.visualize(self._pcoll, dynamical_plotting_interval=0.001) +# Blocking so the above async task can execute a few iterations. +time.sleep(0.1) Review comment: Please don't use time.sleep() in unit tests. Not only does it slow down the testing, but it also generally leads to flaky tests
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=330658&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-330658 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 18/Oct/19 17:13 Start Date: 18/Oct/19 17:13 Worklog Time Spent: 10m Work Description: KevinGG commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r336591010 ## File path: sdks/python/setup.py ## @@ -107,13 +107,17 @@ def get_version(): 'crcmod>=1.7,<2.0', # Dill doesn't guarantee comatibility between releases within minor version. 'dill>=0.3.0,<0.3.1', +'facets-overview>=1.0.0,<2', Review comment: Thanks for the suggestions! Yes, I feel the same way but didn't know what to do about it. Will make the change. 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: 330658) Time Spent: 4.5h (was: 4h 20m) > Visualize PCollection with Interactive Beam > --- > > 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: 4.5h > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=330660&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-330660 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 18/Oct/19 17:15 Start Date: 18/Oct/19 17:15 Worklog Time Spent: 10m Work Description: KevinGG commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r336592169 ## File path: sdks/python/apache_beam/runners/interactive/interactive_environment.py ## @@ -105,3 +113,33 @@ def set_cache_manager(self, cache_manager): def cache_manager(self): """Gets the cache manager held by current Interactive Environment.""" return self._cache_manager + + def set_pipeline_result(self, pipeline, result): Review comment: It's not used yet. It should be invoked by the InteractiveRunner once we have all the building blocks ready. What we are planning to do is to only allow one job for one user pipeline running at the same time within a runner instance. So if the user re-executes p.run() for an async running job. The runner should cancel the running job using current tracked pipeline_result and starts a new one, then track the new pipeline_result. 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: 330660) Time Spent: 4h 40m (was: 4.5h) > Visualize PCollection with Interactive Beam > --- > > 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: 4h 40m > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=330661&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-330661 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 18/Oct/19 17:17 Start Date: 18/Oct/19 17:17 Worklog Time Spent: 10m Work Description: KevinGG commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r336592842 ## File path: sdks/python/apache_beam/runners/interactive/display/pcoll_visualization_test.py ## @@ -0,0 +1,133 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +#http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +"""Tests for apache_beam.runners.interactive.display.pcoll_visualization.""" +from __future__ import absolute_import + +import sys +import time +import unittest + +import timeloop + +import apache_beam as beam +from apache_beam.runners import runner +from apache_beam.runners.interactive import interactive_environment as ie +from apache_beam.runners.interactive.display import pcoll_visualization as pv + +# Work around nose tests using Python2 without unittest.mock module. +try: + from unittest.mock import patch +except ImportError: + from mock import patch + + +class PCollVisualizationTest(unittest.TestCase): + + def setUp(self): +self._p = beam.Pipeline() +# pylint: disable=range-builtin-not-iterating +self._pcoll = self._p | 'Create' >> beam.Create(range(1000)) + + @unittest.skipIf(sys.version_info < (3, 5, 3), + 'PCollVisualization is not supported on Python 2.') + def test_raise_error_for_non_pcoll_input(self): +class Foo(object): + pass + +with self.assertRaises(ValueError) as ctx: + pv.PCollVisualization(Foo()) + self.assertTrue('pcoll should be apache_beam.pvalue.PCollection' in + ctx.exception) + + @unittest.skipIf(sys.version_info < (3, 5, 3), Review comment: Yes, you can do it by putting skipIf at the class level. It's just one of the tests is depending on (3,6,3) (where assert_called is introduced in unittest). So not all tests are depending on the same version. Decorating at function level gives more flexibility. 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: 330661) Time Spent: 4h 50m (was: 4h 40m) > Visualize PCollection with Interactive Beam > --- > > 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: 4h 50m > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=330662&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-330662 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 18/Oct/19 17:18 Start Date: 18/Oct/19 17:18 Worklog Time Spent: 10m Work Description: KevinGG commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r336593108 ## File path: sdks/python/apache_beam/runners/interactive/display/pcoll_visualization.py ## @@ -0,0 +1,258 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +#http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +"""Module visualizes PCollection data. + +For internal use only; no backwards-compatibility guarantees. +Only works with Python 3.5+. +""" +from __future__ import absolute_import + +import base64 +import logging +from datetime import timedelta + +from facets_overview.generic_feature_statistics_generator import GenericFeatureStatisticsGenerator +from IPython.core.display import HTML +from IPython.core.display import Javascript +from IPython.core.display import display +from IPython.core.display import display_javascript +from IPython.core.display import update_display +from pandas.io.json import json_normalize +from timeloop import Timeloop + +from apache_beam import pvalue +from apache_beam.runners.interactive import interactive_environment as ie +from apache_beam.runners.interactive import pipeline_instrument as instr + +# jsons doesn't support < Python 3.5. Work around with json for legacy tests. +try: + import jsons + _pv_jsons_load = jsons.load + _pv_jsons_dump = jsons.dump +except ImportError: + import json + _pv_jsons_load = json.load + _pv_jsons_dump = json.dump + +# 1-d types that need additional normalization to be compatible with DataFrame. +_one_dimension_types = (int, float, str, bool, list, tuple) + +_DIVE_SCRIPT_TEMPLATE = """ +document.querySelector("#{display_id}").data = {jsonstr};""" +_DIVE_HTML_TEMPLATE = """ +https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/1.3.3/webcomponents-lite.js";> +https://raw.githubusercontent.com/PAIR-code/facets/1.0.0/facets-dist/facets-jupyter.html";> + + + document.querySelector("#{display_id}").data = {jsonstr}; +""" +_OVERVIEW_SCRIPT_TEMPLATE = """ + document.querySelector("#{display_id}").protoInput = "{protostr}"; + """ +_OVERVIEW_HTML_TEMPLATE = """ +https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/1.3.3/webcomponents-lite.js";> +https://raw.githubusercontent.com/PAIR-code/facets/1.0.0/facets-dist/facets-jupyter.html";> + + + document.querySelector("#{display_id}").protoInput = "{protostr}"; +""" +_DATAFRAME_PAGINATION_TEMPLATE = """ +https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js";> +https://cdn.datatables.net/1.10.16/js/jquery.dataTables.js";> +https://cdn.datatables.net/1.10.16/css/jquery.dataTables.css";> +{dataframe_html} + + $("#{table_id}").DataTable(); +""" + + +def visualize(pcoll, dynamical_plotting_interval=None): + """Visualizes the data of a given PCollection. Optionally enables dynamical + plotting with interval in seconds if the PCollection is being produced by a + running pipeline or the pipeline is streaming indefinitely. The function + always returns immediately and is asynchronous when dynamical plotting is on. + + If dynamical plotting enabled, the visualization is updated continuously until + the pipeline producing the PCollection is in an end state. The visualization + would be anchored to the notebook cell output area. The function + asynchronously returns a handle to the visualization job immediately. The user + could manually do:: + +# In one notebook cell, enable dynamical plotting every 1 second: +handle = visualize(pcoll, dynamical_plotting_interval=1) Review comment: Thanks, I'll go for it and change
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=330663&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-330663 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 18/Oct/19 17:18 Start Date: 18/Oct/19 17:18 Worklog Time Spent: 10m Work Description: KevinGG commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r336593305 ## File path: sdks/python/apache_beam/runners/interactive/display/pcoll_visualization.py ## @@ -0,0 +1,258 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +#http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +"""Module visualizes PCollection data. + +For internal use only; no backwards-compatibility guarantees. +Only works with Python 3.5+. +""" +from __future__ import absolute_import + +import base64 +import logging +from datetime import timedelta + +from facets_overview.generic_feature_statistics_generator import GenericFeatureStatisticsGenerator +from IPython.core.display import HTML +from IPython.core.display import Javascript +from IPython.core.display import display +from IPython.core.display import display_javascript +from IPython.core.display import update_display +from pandas.io.json import json_normalize +from timeloop import Timeloop + +from apache_beam import pvalue +from apache_beam.runners.interactive import interactive_environment as ie +from apache_beam.runners.interactive import pipeline_instrument as instr + +# jsons doesn't support < Python 3.5. Work around with json for legacy tests. +try: + import jsons + _pv_jsons_load = jsons.load + _pv_jsons_dump = jsons.dump +except ImportError: + import json + _pv_jsons_load = json.load + _pv_jsons_dump = json.dump + +# 1-d types that need additional normalization to be compatible with DataFrame. +_one_dimension_types = (int, float, str, bool, list, tuple) + +_DIVE_SCRIPT_TEMPLATE = """ +document.querySelector("#{display_id}").data = {jsonstr};""" +_DIVE_HTML_TEMPLATE = """ +https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/1.3.3/webcomponents-lite.js";> +https://raw.githubusercontent.com/PAIR-code/facets/1.0.0/facets-dist/facets-jupyter.html";> + + + document.querySelector("#{display_id}").data = {jsonstr}; +""" +_OVERVIEW_SCRIPT_TEMPLATE = """ + document.querySelector("#{display_id}").protoInput = "{protostr}"; + """ +_OVERVIEW_HTML_TEMPLATE = """ +https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/1.3.3/webcomponents-lite.js";> +https://raw.githubusercontent.com/PAIR-code/facets/1.0.0/facets-dist/facets-jupyter.html";> + + + document.querySelector("#{display_id}").protoInput = "{protostr}"; +""" +_DATAFRAME_PAGINATION_TEMPLATE = """ +https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js";> +https://cdn.datatables.net/1.10.16/js/jquery.dataTables.js";> +https://cdn.datatables.net/1.10.16/css/jquery.dataTables.css";> +{dataframe_html} + + $("#{table_id}").DataTable(); +""" + + +def visualize(pcoll, dynamical_plotting_interval=None): + """Visualizes the data of a given PCollection. Optionally enables dynamical + plotting with interval in seconds if the PCollection is being produced by a + running pipeline or the pipeline is streaming indefinitely. The function + always returns immediately and is asynchronous when dynamical plotting is on. + + If dynamical plotting enabled, the visualization is updated continuously until + the pipeline producing the PCollection is in an end state. The visualization + would be anchored to the notebook cell output area. The function + asynchronously returns a handle to the visualization job immediately. The user + could manually do:: + +# In one notebook cell, enable dynamical plotting every 1 second: +handle = visualize(pcoll, dynamical_plotting_interval=1) +# Visualization anchored to the cell's output area
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=330665&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-330665 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 18/Oct/19 17:21 Start Date: 18/Oct/19 17:21 Worklog Time Spent: 10m Work Description: KevinGG commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r336594249 ## File path: sdks/python/apache_beam/runners/interactive/display/pcoll_visualization.py ## @@ -0,0 +1,258 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +#http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +"""Module visualizes PCollection data. + +For internal use only; no backwards-compatibility guarantees. +Only works with Python 3.5+. +""" +from __future__ import absolute_import + +import base64 +import logging +from datetime import timedelta + +from facets_overview.generic_feature_statistics_generator import GenericFeatureStatisticsGenerator +from IPython.core.display import HTML +from IPython.core.display import Javascript +from IPython.core.display import display +from IPython.core.display import display_javascript +from IPython.core.display import update_display +from pandas.io.json import json_normalize +from timeloop import Timeloop + +from apache_beam import pvalue +from apache_beam.runners.interactive import interactive_environment as ie +from apache_beam.runners.interactive import pipeline_instrument as instr + +# jsons doesn't support < Python 3.5. Work around with json for legacy tests. +try: + import jsons + _pv_jsons_load = jsons.load + _pv_jsons_dump = jsons.dump +except ImportError: + import json + _pv_jsons_load = json.load + _pv_jsons_dump = json.dump + +# 1-d types that need additional normalization to be compatible with DataFrame. +_one_dimension_types = (int, float, str, bool, list, tuple) + +_DIVE_SCRIPT_TEMPLATE = """ +document.querySelector("#{display_id}").data = {jsonstr};""" +_DIVE_HTML_TEMPLATE = """ +https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/1.3.3/webcomponents-lite.js";> +https://raw.githubusercontent.com/PAIR-code/facets/1.0.0/facets-dist/facets-jupyter.html";> + + + document.querySelector("#{display_id}").data = {jsonstr}; +""" +_OVERVIEW_SCRIPT_TEMPLATE = """ + document.querySelector("#{display_id}").protoInput = "{protostr}"; + """ +_OVERVIEW_HTML_TEMPLATE = """ +https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/1.3.3/webcomponents-lite.js";> +https://raw.githubusercontent.com/PAIR-code/facets/1.0.0/facets-dist/facets-jupyter.html";> + + + document.querySelector("#{display_id}").protoInput = "{protostr}"; +""" +_DATAFRAME_PAGINATION_TEMPLATE = """ +https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js";> +https://cdn.datatables.net/1.10.16/js/jquery.dataTables.js";> +https://cdn.datatables.net/1.10.16/css/jquery.dataTables.css";> +{dataframe_html} + + $("#{table_id}").DataTable(); +""" + + +def visualize(pcoll, dynamical_plotting_interval=None): + """Visualizes the data of a given PCollection. Optionally enables dynamical + plotting with interval in seconds if the PCollection is being produced by a + running pipeline or the pipeline is streaming indefinitely. The function + always returns immediately and is asynchronous when dynamical plotting is on. + + If dynamical plotting enabled, the visualization is updated continuously until + the pipeline producing the PCollection is in an end state. The visualization + would be anchored to the notebook cell output area. The function + asynchronously returns a handle to the visualization job immediately. The user + could manually do:: + +# In one notebook cell, enable dynamical plotting every 1 second: +handle = visualize(pcoll, dynamical_plotting_interval=1) +# Visualization anchored to the cell's output area
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=330670&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-330670 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 18/Oct/19 17:25 Start Date: 18/Oct/19 17:25 Worklog Time Spent: 10m Work Description: KevinGG commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r336592169 ## File path: sdks/python/apache_beam/runners/interactive/interactive_environment.py ## @@ -105,3 +113,33 @@ def set_cache_manager(self, cache_manager): def cache_manager(self): """Gets the cache manager held by current Interactive Environment.""" return self._cache_manager + + def set_pipeline_result(self, pipeline, result): Review comment: It's not used yet. It should be invoked by the InteractiveRunner once we have all the building blocks ready. What we are planning to do is to only allow one job for one user pipeline running at the same time within a runner instance. So if the user re-executes p.run() for an async running job. The runner should cancel the running job using current tracked pipeline_result and start a new one, then track the new pipeline_result. 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: 330670) Time Spent: 5h 40m (was: 5.5h) > Visualize PCollection with Interactive Beam > --- > > 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: 5h 40m > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=330668&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-330668 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 18/Oct/19 17:23 Start Date: 18/Oct/19 17:23 Worklog Time Spent: 10m Work Description: KevinGG commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r336595299 ## File path: sdks/python/apache_beam/runners/interactive/display/pcoll_visualization.py ## @@ -0,0 +1,258 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +#http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +"""Module visualizes PCollection data. + +For internal use only; no backwards-compatibility guarantees. +Only works with Python 3.5+. +""" +from __future__ import absolute_import + +import base64 +import logging +from datetime import timedelta + +from facets_overview.generic_feature_statistics_generator import GenericFeatureStatisticsGenerator +from IPython.core.display import HTML +from IPython.core.display import Javascript +from IPython.core.display import display +from IPython.core.display import display_javascript +from IPython.core.display import update_display +from pandas.io.json import json_normalize +from timeloop import Timeloop + +from apache_beam import pvalue +from apache_beam.runners.interactive import interactive_environment as ie +from apache_beam.runners.interactive import pipeline_instrument as instr + +# jsons doesn't support < Python 3.5. Work around with json for legacy tests. +try: + import jsons + _pv_jsons_load = jsons.load + _pv_jsons_dump = jsons.dump +except ImportError: + import json + _pv_jsons_load = json.load + _pv_jsons_dump = json.dump + +# 1-d types that need additional normalization to be compatible with DataFrame. +_one_dimension_types = (int, float, str, bool, list, tuple) + +_DIVE_SCRIPT_TEMPLATE = """ +document.querySelector("#{display_id}").data = {jsonstr};""" +_DIVE_HTML_TEMPLATE = """ +https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/1.3.3/webcomponents-lite.js";> +https://raw.githubusercontent.com/PAIR-code/facets/1.0.0/facets-dist/facets-jupyter.html";> + + + document.querySelector("#{display_id}").data = {jsonstr}; +""" +_OVERVIEW_SCRIPT_TEMPLATE = """ + document.querySelector("#{display_id}").protoInput = "{protostr}"; + """ +_OVERVIEW_HTML_TEMPLATE = """ +https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/1.3.3/webcomponents-lite.js";> +https://raw.githubusercontent.com/PAIR-code/facets/1.0.0/facets-dist/facets-jupyter.html";> + + + document.querySelector("#{display_id}").protoInput = "{protostr}"; +""" +_DATAFRAME_PAGINATION_TEMPLATE = """ +https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js";> +https://cdn.datatables.net/1.10.16/js/jquery.dataTables.js";> +https://cdn.datatables.net/1.10.16/css/jquery.dataTables.css";> +{dataframe_html} + + $("#{table_id}").DataTable(); +""" + + +def visualize(pcoll, dynamical_plotting_interval=None): Review comment: It automatically checks the running job's pipeline result and stop itself when the job is in an terminated state. The end user could also assign the returned handle from visualize() to a variable, say `handle = visualize(pcoll)` and call `handle.stop()` to explicitly manually stop the visualization from anywhere in the notebook. 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: 330668) Time Spent: 5.5h (was: 5h 20m) > Visualize PCollection with Interactive Beam > ---
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=330700&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-330700 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 18/Oct/19 18:26 Start Date: 18/Oct/19 18:26 Worklog Time Spent: 10m Work Description: KevinGG commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r336621115 ## File path: sdks/python/apache_beam/runners/interactive/display/pcoll_visualization_test.py ## @@ -0,0 +1,133 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +#http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +"""Tests for apache_beam.runners.interactive.display.pcoll_visualization.""" +from __future__ import absolute_import + +import sys +import time +import unittest + +import timeloop + +import apache_beam as beam +from apache_beam.runners import runner +from apache_beam.runners.interactive import interactive_environment as ie +from apache_beam.runners.interactive.display import pcoll_visualization as pv + +# Work around nose tests using Python2 without unittest.mock module. +try: + from unittest.mock import patch +except ImportError: + from mock import patch + + +class PCollVisualizationTest(unittest.TestCase): + + def setUp(self): +self._p = beam.Pipeline() +# pylint: disable=range-builtin-not-iterating +self._pcoll = self._p | 'Create' >> beam.Create(range(1000)) + + @unittest.skipIf(sys.version_info < (3, 5, 3), + 'PCollVisualization is not supported on Python 2.') + def test_raise_error_for_non_pcoll_input(self): +class Foo(object): + pass + +with self.assertRaises(ValueError) as ctx: + pv.PCollVisualization(Foo()) + self.assertTrue('pcoll should be apache_beam.pvalue.PCollection' in + ctx.exception) + + @unittest.skipIf(sys.version_info < (3, 5, 3), + 'PCollVisualization is not supported on Python 2.') + def test_pcoll_visualization_generate_unique_display_id(self): +pv_1 = pv.PCollVisualization(self._pcoll) +pv_2 = pv.PCollVisualization(self._pcoll) +self.assertNotEqual(pv_1._dive_display_id, pv_2._dive_display_id) +self.assertNotEqual(pv_1._overview_display_id, pv_2._overview_display_id) +self.assertNotEqual(pv_1._df_display_id, pv_2._df_display_id) + + @unittest.skipIf(sys.version_info < (3, 5, 3), + 'PCollVisualization is not supported on Python 2.') + @patch('apache_beam.runners.interactive.display.pcoll_visualization' + '.PCollVisualization._to_element_list', lambda x: [1, 2, 3]) + def test_one_shot_visualization_not_return_handle(self): +self.assertIsNone(pv.visualize(self._pcoll)) + + def _mock_to_element_list(self): +yield [1, 2, 3] +yield [1, 2, 3, 4] + + @unittest.skipIf(sys.version_info < (3, 5, 3), + 'PCollVisualization is not supported on Python 2.') + @patch('apache_beam.runners.interactive.display.pcoll_visualization' + '.PCollVisualization._to_element_list', _mock_to_element_list) + def test_dynamical_plotting_return_handle(self): +h = pv.visualize(self._pcoll, dynamical_plotting_interval=1) +self.assertIsInstance(h, timeloop.Timeloop) +h.stop() + + @unittest.skipIf(sys.version_info < (3, 5, 3), + 'PCollVisualization is not supported on Python 2.') + @patch('apache_beam.runners.interactive.display.pcoll_visualization' + '.PCollVisualization._to_element_list', _mock_to_element_list) + @patch('apache_beam.runners.interactive.display.pcoll_visualization' + '.PCollVisualization.display_facets') + def test_dynamical_plotting_update_same_display(self, + mocked_display_facets): +# Starts async dynamical plotting. +h = pv.visualize(self._pcoll, dynamical_plotting_interval=0.001) +# Blocking so the above async task can execute a few iterations. +time.sleep(0.1) Review comment: Using while loop querying for an ending condition to block then. Also added a timeout to ensure the while loop to never exceed 0.1
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=330824&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-330824 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 18/Oct/19 23:55 Start Date: 18/Oct/19 23:55 Worklog Time Spent: 10m Work Description: aaltay commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r336710191 ## File path: sdks/python/setup.py ## @@ -219,11 +227,15 @@ def run(self): install_requires=REQUIRED_PACKAGES, python_requires=python_requires, test_suite='nose.collector', -tests_require=REQUIRED_TEST_PACKAGES, +tests_require=[ +REQUIRED_TEST_PACKAGES, +INTERACTIVE_BEAM, +], extras_require={ 'docs': ['Sphinx>=1.5.2,<2.0'], 'test': REQUIRED_TEST_PACKAGES, 'gcp': GCP_REQUIREMENTS, +'ib': INTERACTIVE_BEAM, Review comment: how about `interactive` instead of `ib`. This leads to a more readable `pip install apache_beam[interactive]` instead of `pip install apache_beam[ib]` 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: 330824) Time Spent: 6h (was: 5h 50m) > Visualize PCollection with Interactive Beam > --- > > 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: 6h > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=330826&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-330826 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 18/Oct/19 23:56 Start Date: 18/Oct/19 23:56 Worklog Time Spent: 10m Work Description: aaltay commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r336710275 ## File path: sdks/python/setup.py ## @@ -219,11 +227,15 @@ def run(self): install_requires=REQUIRED_PACKAGES, python_requires=python_requires, test_suite='nose.collector', -tests_require=REQUIRED_TEST_PACKAGES, +tests_require=[ +REQUIRED_TEST_PACKAGES, +INTERACTIVE_BEAM, Review comment: Why tests would require interactive beam packages? 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: 330826) Time Spent: 6h 10m (was: 6h) > Visualize PCollection with Interactive Beam > --- > > 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: 6h 10m > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=330829&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-330829 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 19/Oct/19 00:10 Start Date: 19/Oct/19 00:10 Worklog Time Spent: 10m Work Description: KevinGG commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r336711762 ## File path: sdks/python/setup.py ## @@ -219,11 +227,15 @@ def run(self): install_requires=REQUIRED_PACKAGES, python_requires=python_requires, test_suite='nose.collector', -tests_require=REQUIRED_TEST_PACKAGES, +tests_require=[ +REQUIRED_TEST_PACKAGES, +INTERACTIVE_BEAM, +], extras_require={ 'docs': ['Sphinx>=1.5.2,<2.0'], 'test': REQUIRED_TEST_PACKAGES, 'gcp': GCP_REQUIREMENTS, +'ib': INTERACTIVE_BEAM, Review comment: Agreed! 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: 330829) Time Spent: 6.5h (was: 6h 20m) > Visualize PCollection with Interactive Beam > --- > > 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: 6.5h > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=330828&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-330828 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 19/Oct/19 00:10 Start Date: 19/Oct/19 00:10 Worklog Time Spent: 10m Work Description: KevinGG commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r336711748 ## File path: sdks/python/setup.py ## @@ -219,11 +227,15 @@ def run(self): install_requires=REQUIRED_PACKAGES, python_requires=python_requires, test_suite='nose.collector', -tests_require=REQUIRED_TEST_PACKAGES, +tests_require=[ +REQUIRED_TEST_PACKAGES, +INTERACTIVE_BEAM, Review comment: Because there are unit tests around interactive beam packages. When those packages are under REQUIRED_PACKAGES, they are always installed and available during tests. Once we move them into an extras_require, they are not installed nor available during tests anymore. For example, *-gcp tests will install [gcp,test] to pick up the extras_package GCP_REQUIREMENTS. Since we don't have/need *-interactive test suites, we can make the group to always be installed as required test packages for tests. 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: 330828) Time Spent: 6h 20m (was: 6h 10m) > Visualize PCollection with Interactive Beam > --- > > 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: 6h 20m > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=330832&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-330832 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 19/Oct/19 00:16 Start Date: 19/Oct/19 00:16 Worklog Time Spent: 10m Work Description: KevinGG commented on issue #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#issuecomment-544019379 isort and pylint are crazy and contradicting about where you should put `import apache_beam as beam`. And the order suggested changes over time. 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: 330832) Time Spent: 6h 40m (was: 6.5h) > Visualize PCollection with Interactive Beam > --- > > 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: 6h 40m > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=331529&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-331529 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 21/Oct/19 17:32 Start Date: 21/Oct/19 17:32 Worklog Time Spent: 10m Work Description: KevinGG commented on issue #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#issuecomment-544622565 Run Python PreCommit 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: 331529) Time Spent: 6h 50m (was: 6h 40m) > Visualize PCollection with Interactive Beam > --- > > 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: 6h 50m > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=331543&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-331543 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 21/Oct/19 18:01 Start Date: 21/Oct/19 18:01 Worklog Time Spent: 10m Work Description: rohdesamuel commented on issue #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#issuecomment-544634753 lgtm 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: 331543) Time Spent: 7h (was: 6h 50m) > Visualize PCollection with Interactive Beam > --- > > 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: 7h > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=331634&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-331634 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 21/Oct/19 20:31 Start Date: 21/Oct/19 20:31 Worklog Time Spent: 10m Work Description: davidyan74 commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r337223191 ## File path: sdks/python/apache_beam/runners/interactive/display/pcoll_visualization_test.py ## @@ -0,0 +1,152 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +#http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +"""Tests for apache_beam.runners.interactive.display.pcoll_visualization.""" +from __future__ import absolute_import + +import sys +import time +import unittest + +import apache_beam as beam # pylint: disable=ungrouped-imports +import timeloop +from apache_beam.runners import runner +from apache_beam.runners.interactive import interactive_environment as ie +from apache_beam.runners.interactive.display import pcoll_visualization as pv + +# Work around nose tests using Python2 without unittest.mock module. +try: + from unittest.mock import patch +except ImportError: + from mock import patch + + +class PCollVisualizationTest(unittest.TestCase): + + def setUp(self): +self._p = beam.Pipeline() +# pylint: disable=range-builtin-not-iterating +self._pcoll = self._p | 'Create' >> beam.Create(range(1000)) + + @unittest.skipIf(sys.version_info < (3, 5, 3), + 'PCollVisualization is not supported on Python 2.') + def test_raise_error_for_non_pcoll_input(self): +class Foo(object): + pass + +with self.assertRaises(AssertionError) as ctx: + pv.PCollVisualization(Foo()) + self.assertTrue('pcoll should be apache_beam.pvalue.PCollection' in + ctx.exception) + + @unittest.skipIf(sys.version_info < (3, 5, 3), + 'PCollVisualization is not supported on Python 2.') + def test_pcoll_visualization_generate_unique_display_id(self): +pv_1 = pv.PCollVisualization(self._pcoll) +pv_2 = pv.PCollVisualization(self._pcoll) +self.assertNotEqual(pv_1._dive_display_id, pv_2._dive_display_id) +self.assertNotEqual(pv_1._overview_display_id, pv_2._overview_display_id) +self.assertNotEqual(pv_1._df_display_id, pv_2._df_display_id) + + @unittest.skipIf(sys.version_info < (3, 5, 3), + 'PCollVisualization is not supported on Python 2.') + @patch('apache_beam.runners.interactive.display.pcoll_visualization' + '.PCollVisualization._to_element_list', lambda x: [1, 2, 3]) + def test_one_shot_visualization_not_return_handle(self): +self.assertIsNone(pv.visualize(self._pcoll)) + + def _mock_to_element_list(self): +yield [1, 2, 3] +yield [1, 2, 3, 4] +yield [1, 2, 3, 4, 5] +yield [1, 2, 3, 4, 5, 6] +yield [1, 2, 3, 4, 5, 6, 7] +yield [1, 2, 3, 4, 5, 6, 7, 8] + + @unittest.skipIf(sys.version_info < (3, 5, 3), + 'PCollVisualization is not supported on Python 2.') + @patch('apache_beam.runners.interactive.display.pcoll_visualization' + '.PCollVisualization._to_element_list', _mock_to_element_list) + def test_dynamic_plotting_return_handle(self): +h = pv.visualize(self._pcoll, dynamic_plotting_interval=1) +self.assertIsInstance(h, timeloop.Timeloop) +h.stop() + + @unittest.skipIf(sys.version_info < (3, 5, 3), + 'PCollVisualization is not supported on Python 2.') + @patch('apache_beam.runners.interactive.display.pcoll_visualization' + '.PCollVisualization._to_element_list', _mock_to_element_list) + @patch('apache_beam.runners.interactive.display.pcoll_visualization' + '.PCollVisualization.display_facets') + def test_dynamic_plotting_update_same_display(self, +mocked_display_facets): +fake_pipeline_result = runner.PipelineResult(runner.PipelineState.RUNNING) +ie.current_env().set_pipeline_result(self._p, fake_pipeline_result) +# Starts async dynamic plotting that
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=331633&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-331633 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 21/Oct/19 20:31 Start Date: 21/Oct/19 20:31 Worklog Time Spent: 10m Work Description: davidyan74 commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r337223563 ## File path: sdks/python/apache_beam/runners/interactive/display/pcoll_visualization.py ## @@ -0,0 +1,258 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +#http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +"""Module visualizes PCollection data. + +For internal use only; no backwards-compatibility guarantees. +Only works with Python 3.5+. +""" +from __future__ import absolute_import + +import base64 +import logging +from datetime import timedelta + +from pandas.io.json import json_normalize + +from apache_beam import pvalue +from apache_beam.runners.interactive import interactive_environment as ie +from apache_beam.runners.interactive import pipeline_instrument as instr +from facets_overview.generic_feature_statistics_generator import GenericFeatureStatisticsGenerator +from IPython.core.display import HTML +from IPython.core.display import Javascript +from IPython.core.display import display +from IPython.core.display import display_javascript +from IPython.core.display import update_display +from timeloop import Timeloop + +# jsons doesn't support < Python 3.5. Work around with json for legacy tests. Review comment: Why do we need this workaround if we only support Python 3.5+? 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: 331633) Time Spent: 7h 10m (was: 7h) > Visualize PCollection with Interactive Beam > --- > > 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: 7h 10m > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=331640&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-331640 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 21/Oct/19 20:46 Start Date: 21/Oct/19 20:46 Worklog Time Spent: 10m Work Description: KevinGG commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r337231031 ## File path: sdks/python/apache_beam/runners/interactive/display/pcoll_visualization_test.py ## @@ -0,0 +1,152 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +#http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +"""Tests for apache_beam.runners.interactive.display.pcoll_visualization.""" +from __future__ import absolute_import + +import sys +import time +import unittest + +import apache_beam as beam # pylint: disable=ungrouped-imports +import timeloop +from apache_beam.runners import runner +from apache_beam.runners.interactive import interactive_environment as ie +from apache_beam.runners.interactive.display import pcoll_visualization as pv + +# Work around nose tests using Python2 without unittest.mock module. +try: + from unittest.mock import patch +except ImportError: + from mock import patch + + +class PCollVisualizationTest(unittest.TestCase): + + def setUp(self): +self._p = beam.Pipeline() +# pylint: disable=range-builtin-not-iterating +self._pcoll = self._p | 'Create' >> beam.Create(range(1000)) + + @unittest.skipIf(sys.version_info < (3, 5, 3), + 'PCollVisualization is not supported on Python 2.') + def test_raise_error_for_non_pcoll_input(self): +class Foo(object): + pass + +with self.assertRaises(AssertionError) as ctx: + pv.PCollVisualization(Foo()) + self.assertTrue('pcoll should be apache_beam.pvalue.PCollection' in + ctx.exception) + + @unittest.skipIf(sys.version_info < (3, 5, 3), + 'PCollVisualization is not supported on Python 2.') + def test_pcoll_visualization_generate_unique_display_id(self): +pv_1 = pv.PCollVisualization(self._pcoll) +pv_2 = pv.PCollVisualization(self._pcoll) +self.assertNotEqual(pv_1._dive_display_id, pv_2._dive_display_id) +self.assertNotEqual(pv_1._overview_display_id, pv_2._overview_display_id) +self.assertNotEqual(pv_1._df_display_id, pv_2._df_display_id) + + @unittest.skipIf(sys.version_info < (3, 5, 3), + 'PCollVisualization is not supported on Python 2.') + @patch('apache_beam.runners.interactive.display.pcoll_visualization' + '.PCollVisualization._to_element_list', lambda x: [1, 2, 3]) + def test_one_shot_visualization_not_return_handle(self): +self.assertIsNone(pv.visualize(self._pcoll)) + + def _mock_to_element_list(self): +yield [1, 2, 3] +yield [1, 2, 3, 4] +yield [1, 2, 3, 4, 5] +yield [1, 2, 3, 4, 5, 6] +yield [1, 2, 3, 4, 5, 6, 7] +yield [1, 2, 3, 4, 5, 6, 7, 8] + + @unittest.skipIf(sys.version_info < (3, 5, 3), + 'PCollVisualization is not supported on Python 2.') + @patch('apache_beam.runners.interactive.display.pcoll_visualization' + '.PCollVisualization._to_element_list', _mock_to_element_list) + def test_dynamic_plotting_return_handle(self): +h = pv.visualize(self._pcoll, dynamic_plotting_interval=1) +self.assertIsInstance(h, timeloop.Timeloop) +h.stop() + + @unittest.skipIf(sys.version_info < (3, 5, 3), + 'PCollVisualization is not supported on Python 2.') + @patch('apache_beam.runners.interactive.display.pcoll_visualization' + '.PCollVisualization._to_element_list', _mock_to_element_list) + @patch('apache_beam.runners.interactive.display.pcoll_visualization' + '.PCollVisualization.display_facets') + def test_dynamic_plotting_update_same_display(self, +mocked_display_facets): +fake_pipeline_result = runner.PipelineResult(runner.PipelineState.RUNNING) +ie.current_env().set_pipeline_result(self._p, fake_pipeline_result) +# Starts async dynamic plotting that nev
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=331642&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-331642 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 21/Oct/19 20:48 Start Date: 21/Oct/19 20:48 Worklog Time Spent: 10m Work Description: KevinGG commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r337232020 ## File path: sdks/python/apache_beam/runners/interactive/display/pcoll_visualization.py ## @@ -0,0 +1,258 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +#http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +"""Module visualizes PCollection data. + +For internal use only; no backwards-compatibility guarantees. +Only works with Python 3.5+. +""" +from __future__ import absolute_import + +import base64 +import logging +from datetime import timedelta + +from pandas.io.json import json_normalize + +from apache_beam import pvalue +from apache_beam.runners.interactive import interactive_environment as ie +from apache_beam.runners.interactive import pipeline_instrument as instr +from facets_overview.generic_feature_statistics_generator import GenericFeatureStatisticsGenerator +from IPython.core.display import HTML +from IPython.core.display import Javascript +from IPython.core.display import display +from IPython.core.display import display_javascript +from IPython.core.display import update_display +from timeloop import Timeloop + +# jsons doesn't support < Python 3.5. Work around with json for legacy tests. Review comment: All the Gradle tasks still supports py2. So you still have docs, lint and tasks running in py2 virtual env. We'll have to pass those pre-commit checks. 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: 331642) Time Spent: 7h 40m (was: 7.5h) > Visualize PCollection with Interactive Beam > --- > > 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: 7h 40m > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=331733&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-331733 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 22/Oct/19 00:14 Start Date: 22/Oct/19 00:14 Worklog Time Spent: 10m Work Description: davidyan74 commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r337293449 ## File path: sdks/python/apache_beam/runners/interactive/display/pcoll_visualization.py ## @@ -0,0 +1,258 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +#http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +"""Module visualizes PCollection data. + +For internal use only; no backwards-compatibility guarantees. +Only works with Python 3.5+. +""" +from __future__ import absolute_import + +import base64 +import logging +from datetime import timedelta + +from pandas.io.json import json_normalize + +from apache_beam import pvalue +from apache_beam.runners.interactive import interactive_environment as ie +from apache_beam.runners.interactive import pipeline_instrument as instr +from facets_overview.generic_feature_statistics_generator import GenericFeatureStatisticsGenerator +from IPython.core.display import HTML +from IPython.core.display import Javascript +from IPython.core.display import display +from IPython.core.display import display_javascript +from IPython.core.display import update_display +from timeloop import Timeloop + +# jsons doesn't support < Python 3.5. Work around with json for legacy tests. Review comment: Can we just print a warning and exit, or exclude this from running in py2? We probably don't want this to create an impression that this will work with py2. 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: 331733) Time Spent: 7h 50m (was: 7h 40m) > Visualize PCollection with Interactive Beam > --- > > 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: 7h 50m > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=331738&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-331738 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 22/Oct/19 00:51 Start Date: 22/Oct/19 00:51 Worklog Time Spent: 10m Work Description: KevinGG commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r33733 ## File path: sdks/python/apache_beam/runners/interactive/display/pcoll_visualization.py ## @@ -0,0 +1,258 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +#http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +"""Module visualizes PCollection data. + +For internal use only; no backwards-compatibility guarantees. +Only works with Python 3.5+. +""" +from __future__ import absolute_import + +import base64 +import logging +from datetime import timedelta + +from pandas.io.json import json_normalize + +from apache_beam import pvalue +from apache_beam.runners.interactive import interactive_environment as ie +from apache_beam.runners.interactive import pipeline_instrument as instr +from facets_overview.generic_feature_statistics_generator import GenericFeatureStatisticsGenerator +from IPython.core.display import HTML +from IPython.core.display import Javascript +from IPython.core.display import display +from IPython.core.display import display_javascript +from IPython.core.display import update_display +from timeloop import Timeloop + +# jsons doesn't support < Python 3.5. Work around with json for legacy tests. Review comment: This will still work Py2 though. And a sys.exit() would probably break some gradle tasks waiting for 0 exit code. I've put a TODO item here. It's a general ticket for Interactive Beam to mark for cleanup once py2 is deprecated completely from Beam. 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: 331738) Time Spent: 8h (was: 7h 50m) > Visualize PCollection with Interactive Beam > --- > > 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: 8h > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=331739&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-331739 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 22/Oct/19 00:55 Start Date: 22/Oct/19 00:55 Worklog Time Spent: 10m Work Description: davidyan74 commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r337300560 ## File path: sdks/python/apache_beam/runners/interactive/display/pcoll_visualization.py ## @@ -0,0 +1,258 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +#http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +"""Module visualizes PCollection data. + +For internal use only; no backwards-compatibility guarantees. +Only works with Python 3.5+. +""" +from __future__ import absolute_import + +import base64 +import logging +from datetime import timedelta + +from pandas.io.json import json_normalize + +from apache_beam import pvalue +from apache_beam.runners.interactive import interactive_environment as ie +from apache_beam.runners.interactive import pipeline_instrument as instr +from facets_overview.generic_feature_statistics_generator import GenericFeatureStatisticsGenerator +from IPython.core.display import HTML +from IPython.core.display import Javascript +from IPython.core.display import display +from IPython.core.display import display_javascript +from IPython.core.display import update_display +from timeloop import Timeloop + +# jsons doesn't support < Python 3.5. Work around with json for legacy tests. Review comment: Can we at least print a warning that says "interactive is not supported in py2", like we do for python 3 with beam <= 2.15? 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: 331739) Time Spent: 8h 10m (was: 8h) > Visualize PCollection with Interactive Beam > --- > > 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: 8h 10m > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=332134&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-332134 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 22/Oct/19 18:21 Start Date: 22/Oct/19 18:21 Worklog Time Spent: 10m Work Description: KevinGG commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r337676820 ## File path: sdks/python/apache_beam/runners/interactive/display/pcoll_visualization.py ## @@ -0,0 +1,258 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +#http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +"""Module visualizes PCollection data. + +For internal use only; no backwards-compatibility guarantees. +Only works with Python 3.5+. +""" +from __future__ import absolute_import + +import base64 +import logging +from datetime import timedelta + +from pandas.io.json import json_normalize + +from apache_beam import pvalue +from apache_beam.runners.interactive import interactive_environment as ie +from apache_beam.runners.interactive import pipeline_instrument as instr +from facets_overview.generic_feature_statistics_generator import GenericFeatureStatisticsGenerator +from IPython.core.display import HTML +from IPython.core.display import Javascript +from IPython.core.display import display +from IPython.core.display import display_javascript +from IPython.core.display import update_display +from timeloop import Timeloop + +# jsons doesn't support < Python 3.5. Work around with json for legacy tests. Review comment: I've added such warning message in the interactive_environment module to check for Python version and print out warnings. 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: 332134) Time Spent: 8h 20m (was: 8h 10m) > Visualize PCollection with Interactive Beam > --- > > 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: 8h 20m > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=332190&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-332190 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 22/Oct/19 20:34 Start Date: 22/Oct/19 20:34 Worklog Time Spent: 10m Work Description: KevinGG commented on issue #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#issuecomment-545142275 Run Python PreCommit 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: 332190) Time Spent: 8.5h (was: 8h 20m) > Visualize PCollection with Interactive Beam > --- > > 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: 8.5h > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=332238&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-332238 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 22/Oct/19 21:31 Start Date: 22/Oct/19 21:31 Worklog Time Spent: 10m Work Description: pabloem commented on issue #9771: [BEAM-7926] Update dependencies in Java Katas URL: https://github.com/apache/beam/pull/9771#issuecomment-545164821 Hi @leonardoam ! Thanks for the PR. Have to tested that this combination of dependencies works? 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: 332238) Time Spent: 8h 40m (was: 8.5h) > Visualize PCollection with Interactive Beam > --- > > 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: 8h 40m > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=332271&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-332271 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 22/Oct/19 22:52 Start Date: 22/Oct/19 22:52 Worklog Time Spent: 10m Work Description: KevinGG commented on issue #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#issuecomment-545189390 R: @aaltay The tests have passed and Sam has completed his review. Do you have any other comments for this PR? 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: 332271) Time Spent: 8h 50m (was: 8h 40m) > Visualize PCollection with Interactive Beam > --- > > 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: 8h 50m > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=332699&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-332699 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 23/Oct/19 17:30 Start Date: 23/Oct/19 17:30 Worklog Time Spent: 10m Work Description: leonardoam commented on issue #9771: [BEAM-7926] Update dependencies in Java Katas URL: https://github.com/apache/beam/pull/9771#issuecomment-545552768 HI @pabloem, I've ran tests and nothing broke. I also took a look at release notes for major changes and nothing seems to be a reason to break. If you suspect of anything please let me know. 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: 332699) Time Spent: 9h (was: 8h 50m) > Visualize PCollection with Interactive Beam > --- > > 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: 9h > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=332711&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-332711 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 23/Oct/19 17:46 Start Date: 23/Oct/19 17:46 Worklog Time Spent: 10m Work Description: aaltay commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r338181206 ## File path: sdks/python/apache_beam/runners/interactive/display/pcoll_visualization.py ## @@ -0,0 +1,279 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +#http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +"""Module visualizes PCollection data. + +For internal use only; no backwards-compatibility guarantees. +Only works with Python 3.5+. +""" +from __future__ import absolute_import + +import base64 +import logging +from datetime import timedelta + +from pandas.io.json import json_normalize + +from apache_beam import pvalue +from apache_beam.runners.interactive import interactive_environment as ie +from apache_beam.runners.interactive import pipeline_instrument as instr + +# jsons doesn't support < Python 3.5. Work around with json for legacy tests. +# TODO(BEAM-8288): clean up once Py2 is deprecated from Beam. +try: + import jsons + _pv_jsons_load = jsons.load + _pv_jsons_dump = jsons.dump +except ImportError: + import json + _pv_jsons_load = json.load + _pv_jsons_dump = json.dump + +try: + from facets_overview.generic_feature_statistics_generator import GenericFeatureStatisticsGenerator + _facets_gfsg_ready = True +except ImportError: + _facets_gfsg_ready = False Review comment: Is there a reason for _facets_gfsg_ready, _ipython_ready, _tl_ready to be separately ready? Does this module work with some of them installed and some not? I think this import section could be reduced to try: ... import all except ImportError ... warning, missing dependencies and ask user to install [interactive] 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: 332711) Time Spent: 9h 20m (was: 9h 10m) > Visualize PCollection with Interactive Beam > --- > > 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: 9h 20m > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=332719&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-332719 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 23/Oct/19 17:46 Start Date: 23/Oct/19 17:46 Worklog Time Spent: 10m Work Description: aaltay commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r338187897 ## File path: sdks/python/apache_beam/runners/interactive/interactive_environment_test.py ## @@ -88,6 +91,72 @@ def test_watch_class_instance(self): self.assertVariableWatched('_var_in_class_instance', self._var_in_class_instance) + def test_fail_to_set_pipeline_result_key_not_pipeline(self): +class NotPipeline(object): + pass + +with self.assertRaises(AssertionError) as ctx: + ie.current_env().set_pipeline_result(NotPipeline(), + runner.PipelineResult( + runner.PipelineState.RUNNING)) + self.assertTrue('pipeline must be an instance of apache_beam.Pipeline ' + 'or its subclass' in ctx.exception) + + def test_fail_to_set_pipeline_result_value_not_pipeline_result(self): +class NotResult(object): + pass + +with self.assertRaises(AssertionError) as ctx: + ie.current_env().set_pipeline_result(self._p, NotResult()) + self.assertTrue('result must be an instance of ' + 'apache_beam.runners.runner.PipelineResult or its ' + 'subclass' in ctx.exception) + + def test_set_pipeline_result_successfully(self): +class PipelineSubClass(beam.Pipeline): + pass + +class PipelineResultSubClass(runner.PipelineResult): + pass + +pipeline = PipelineSubClass() +pipeline_result = PipelineResultSubClass(runner.PipelineState.RUNNING) +ie.current_env().set_pipeline_result(pipeline, pipeline_result) +self.assertIs(ie.current_env().pipeline_result(pipeline), pipeline_result) + + def test_determine_terminal_state(self): +for state in (runner.PipelineState.DONE, + runner.PipelineState.FAILED, + runner.PipelineState.CANCELLED, + runner.PipelineState.UPDATED, + runner.PipelineState.DRAINED): + ie.current_env().set_pipeline_result(self._p, runner.PipelineResult( Review comment: PipelineState has an is_terminal method defined on the class that can be used here. 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: 332719) Time Spent: 10h 20m (was: 10h 10m) > Visualize PCollection with Interactive Beam > --- > > 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: 10h 20m > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=332712&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-332712 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 23/Oct/19 17:46 Start Date: 23/Oct/19 17:46 Worklog Time Spent: 10m Work Description: aaltay commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r338186737 ## File path: sdks/python/apache_beam/runners/interactive/display/pcoll_visualization_test.py ## @@ -0,0 +1,152 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +#http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +"""Tests for apache_beam.runners.interactive.display.pcoll_visualization.""" +from __future__ import absolute_import + +import sys +import time +import unittest + +import apache_beam as beam # pylint: disable=ungrouped-imports +import timeloop +from apache_beam.runners import runner +from apache_beam.runners.interactive import interactive_environment as ie +from apache_beam.runners.interactive.display import pcoll_visualization as pv + +# Work around nose tests using Python2 without unittest.mock module. +try: + from unittest.mock import patch +except ImportError: + from mock import patch + + +class PCollVisualizationTest(unittest.TestCase): + + def setUp(self): +self._p = beam.Pipeline() +# pylint: disable=range-builtin-not-iterating +self._pcoll = self._p | 'Create' >> beam.Create(range(1000)) + + @unittest.skipIf(sys.version_info < (3, 5, 3), + 'PCollVisualization is not supported on Python 2.') + def test_raise_error_for_non_pcoll_input(self): +class Foo(object): + pass + +with self.assertRaises(AssertionError) as ctx: + pv.PCollVisualization(Foo()) + self.assertTrue('pcoll should be apache_beam.pvalue.PCollection' in + ctx.exception) + + @unittest.skipIf(sys.version_info < (3, 5, 3), + 'PCollVisualization is not supported on Python 2.') + def test_pcoll_visualization_generate_unique_display_id(self): +pv_1 = pv.PCollVisualization(self._pcoll) +pv_2 = pv.PCollVisualization(self._pcoll) +self.assertNotEqual(pv_1._dive_display_id, pv_2._dive_display_id) +self.assertNotEqual(pv_1._overview_display_id, pv_2._overview_display_id) +self.assertNotEqual(pv_1._df_display_id, pv_2._df_display_id) + + @unittest.skipIf(sys.version_info < (3, 5, 3), + 'PCollVisualization is not supported on Python 2.') + @patch('apache_beam.runners.interactive.display.pcoll_visualization' + '.PCollVisualization._to_element_list', lambda x: [1, 2, 3]) + def test_one_shot_visualization_not_return_handle(self): +self.assertIsNone(pv.visualize(self._pcoll)) + + def _mock_to_element_list(self): +yield [1, 2, 3] +yield [1, 2, 3, 4] +yield [1, 2, 3, 4, 5] +yield [1, 2, 3, 4, 5, 6] +yield [1, 2, 3, 4, 5, 6, 7] +yield [1, 2, 3, 4, 5, 6, 7, 8] + + @unittest.skipIf(sys.version_info < (3, 5, 3), + 'PCollVisualization is not supported on Python 2.') + @patch('apache_beam.runners.interactive.display.pcoll_visualization' + '.PCollVisualization._to_element_list', _mock_to_element_list) + def test_dynamic_plotting_return_handle(self): +h = pv.visualize(self._pcoll, dynamic_plotting_interval=1) +self.assertIsInstance(h, timeloop.Timeloop) +h.stop() + + @unittest.skipIf(sys.version_info < (3, 5, 3), + 'PCollVisualization is not supported on Python 2.') + @patch('apache_beam.runners.interactive.display.pcoll_visualization' + '.PCollVisualization._to_element_list', _mock_to_element_list) + @patch('apache_beam.runners.interactive.display.pcoll_visualization' + '.PCollVisualization.display_facets') + def test_dynamic_plotting_update_same_display(self, +mocked_display_facets): +fake_pipeline_result = runner.PipelineResult(runner.PipelineState.RUNNING) +ie.current_env().set_pipeline_result(self._p, fake_pipeline_result) +# Starts async dynamic plotting that neve
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=332720&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-332720 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 23/Oct/19 17:46 Start Date: 23/Oct/19 17:46 Worklog Time Spent: 10m Work Description: aaltay commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r338185073 ## File path: sdks/python/apache_beam/runners/interactive/display/pcoll_visualization_test.py ## @@ -0,0 +1,152 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +#http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +"""Tests for apache_beam.runners.interactive.display.pcoll_visualization.""" +from __future__ import absolute_import + +import sys +import time +import unittest + +import apache_beam as beam # pylint: disable=ungrouped-imports +import timeloop +from apache_beam.runners import runner +from apache_beam.runners.interactive import interactive_environment as ie +from apache_beam.runners.interactive.display import pcoll_visualization as pv + +# Work around nose tests using Python2 without unittest.mock module. +try: + from unittest.mock import patch +except ImportError: + from mock import patch + + +class PCollVisualizationTest(unittest.TestCase): + + def setUp(self): +self._p = beam.Pipeline() +# pylint: disable=range-builtin-not-iterating +self._pcoll = self._p | 'Create' >> beam.Create(range(1000)) + + @unittest.skipIf(sys.version_info < (3, 5, 3), + 'PCollVisualization is not supported on Python 2.') Review comment: This is more like not supported < 3.5.3. 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: 332720) Time Spent: 10.5h (was: 10h 20m) > Visualize PCollection with Interactive Beam > --- > > 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: 10.5h > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=332722&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-332722 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 23/Oct/19 17:46 Start Date: 23/Oct/19 17:46 Worklog Time Spent: 10m Work Description: aaltay commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r338180259 ## File path: sdks/python/apache_beam/runners/interactive/display/pcoll_visualization.py ## @@ -0,0 +1,279 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +#http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +"""Module visualizes PCollection data. + +For internal use only; no backwards-compatibility guarantees. +Only works with Python 3.5+. +""" +from __future__ import absolute_import + +import base64 +import logging +from datetime import timedelta + +from pandas.io.json import json_normalize + +from apache_beam import pvalue +from apache_beam.runners.interactive import interactive_environment as ie +from apache_beam.runners.interactive import pipeline_instrument as instr + +# jsons doesn't support < Python 3.5. Work around with json for legacy tests. +# TODO(BEAM-8288): clean up once Py2 is deprecated from Beam. +try: + import jsons + _pv_jsons_load = jsons.load + _pv_jsons_dump = jsons.dump +except ImportError: + import json + _pv_jsons_load = json.load Review comment: If `json` works, why is `jsons` needed? 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: 332722) Time Spent: 10h 40m (was: 10.5h) > Visualize PCollection with Interactive Beam > --- > > 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: 10h 40m > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=332717&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-332717 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 23/Oct/19 17:46 Start Date: 23/Oct/19 17:46 Worklog Time Spent: 10m Work Description: aaltay commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r338182480 ## File path: sdks/python/apache_beam/runners/interactive/display/pcoll_visualization.py ## @@ -0,0 +1,279 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +#http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +"""Module visualizes PCollection data. + +For internal use only; no backwards-compatibility guarantees. +Only works with Python 3.5+. +""" +from __future__ import absolute_import + +import base64 +import logging +from datetime import timedelta + +from pandas.io.json import json_normalize + +from apache_beam import pvalue +from apache_beam.runners.interactive import interactive_environment as ie +from apache_beam.runners.interactive import pipeline_instrument as instr + +# jsons doesn't support < Python 3.5. Work around with json for legacy tests. +# TODO(BEAM-8288): clean up once Py2 is deprecated from Beam. +try: + import jsons + _pv_jsons_load = jsons.load + _pv_jsons_dump = jsons.dump +except ImportError: + import json + _pv_jsons_load = json.load + _pv_jsons_dump = json.dump + +try: + from facets_overview.generic_feature_statistics_generator import GenericFeatureStatisticsGenerator + _facets_gfsg_ready = True +except ImportError: + _facets_gfsg_ready = False + +try: + from IPython.core.display import HTML + from IPython.core.display import Javascript + from IPython.core.display import display + from IPython.core.display import display_javascript + from IPython.core.display import update_display + _ipython_ready = True +except ImportError: + _ipython_ready = False + +try: + from timeloop import Timeloop + _tl_ready = True +except ImportError: + _tl_ready = False + +# 1-d types that need additional normalization to be compatible with DataFrame. +_one_dimension_types = (int, float, str, bool, list, tuple) + +_DIVE_SCRIPT_TEMPLATE = """ +document.querySelector("#{display_id}").data = {jsonstr};""" +_DIVE_HTML_TEMPLATE = """ +https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/1.3.3/webcomponents-lite.js";> +https://raw.githubusercontent.com/PAIR-code/facets/1.0.0/facets-dist/facets-jupyter.html";> + + + document.querySelector("#{display_id}").data = {jsonstr}; +""" +_OVERVIEW_SCRIPT_TEMPLATE = """ + document.querySelector("#{display_id}").protoInput = "{protostr}"; + """ +_OVERVIEW_HTML_TEMPLATE = """ +https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/1.3.3/webcomponents-lite.js";> +https://raw.githubusercontent.com/PAIR-code/facets/1.0.0/facets-dist/facets-jupyter.html";> + + + document.querySelector("#{display_id}").protoInput = "{protostr}"; +""" +_DATAFRAME_PAGINATION_TEMPLATE = """ +https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js";> +https://cdn.datatables.net/1.10.16/js/jquery.dataTables.js";> +https://cdn.datatables.net/1.10.16/css/jquery.dataTables.css";> +{dataframe_html} + + $("#{table_id}").DataTable(); +""" + + +def visualize(pcoll, dynamic_plotting_interval=None): + """Visualizes the data of a given PCollection. Optionally enables dynamic + plotting with interval in seconds if the PCollection is being produced by a + running pipeline or the pipeline is streaming indefinitely. The function + always returns immediately and is asynchronous when dynamic plotting is on. + + If dynamic plotting enabled, the visualization is updated continuously until + the pipeline producing the PCollection is in an end state. The visualization + would be anchored to the notebook cell output area. The
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=332716&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-332716 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 23/Oct/19 17:46 Start Date: 23/Oct/19 17:46 Worklog Time Spent: 10m Work Description: aaltay commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r338183866 ## File path: sdks/python/apache_beam/runners/interactive/display/pcoll_visualization.py ## @@ -0,0 +1,279 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +#http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +"""Module visualizes PCollection data. + +For internal use only; no backwards-compatibility guarantees. +Only works with Python 3.5+. +""" +from __future__ import absolute_import + +import base64 +import logging +from datetime import timedelta + +from pandas.io.json import json_normalize + +from apache_beam import pvalue +from apache_beam.runners.interactive import interactive_environment as ie +from apache_beam.runners.interactive import pipeline_instrument as instr + +# jsons doesn't support < Python 3.5. Work around with json for legacy tests. +# TODO(BEAM-8288): clean up once Py2 is deprecated from Beam. +try: + import jsons + _pv_jsons_load = jsons.load + _pv_jsons_dump = jsons.dump +except ImportError: + import json + _pv_jsons_load = json.load + _pv_jsons_dump = json.dump + +try: + from facets_overview.generic_feature_statistics_generator import GenericFeatureStatisticsGenerator + _facets_gfsg_ready = True +except ImportError: + _facets_gfsg_ready = False + +try: + from IPython.core.display import HTML + from IPython.core.display import Javascript + from IPython.core.display import display + from IPython.core.display import display_javascript + from IPython.core.display import update_display + _ipython_ready = True +except ImportError: + _ipython_ready = False + +try: + from timeloop import Timeloop + _tl_ready = True +except ImportError: + _tl_ready = False + +# 1-d types that need additional normalization to be compatible with DataFrame. +_one_dimension_types = (int, float, str, bool, list, tuple) + +_DIVE_SCRIPT_TEMPLATE = """ +document.querySelector("#{display_id}").data = {jsonstr};""" +_DIVE_HTML_TEMPLATE = """ +https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/1.3.3/webcomponents-lite.js";> +https://raw.githubusercontent.com/PAIR-code/facets/1.0.0/facets-dist/facets-jupyter.html";> + + + document.querySelector("#{display_id}").data = {jsonstr}; +""" +_OVERVIEW_SCRIPT_TEMPLATE = """ + document.querySelector("#{display_id}").protoInput = "{protostr}"; + """ +_OVERVIEW_HTML_TEMPLATE = """ +https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/1.3.3/webcomponents-lite.js";> +https://raw.githubusercontent.com/PAIR-code/facets/1.0.0/facets-dist/facets-jupyter.html";> + + + document.querySelector("#{display_id}").protoInput = "{protostr}"; +""" +_DATAFRAME_PAGINATION_TEMPLATE = """ +https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js";> +https://cdn.datatables.net/1.10.16/js/jquery.dataTables.js";> +https://cdn.datatables.net/1.10.16/css/jquery.dataTables.css";> +{dataframe_html} + + $("#{table_id}").DataTable(); +""" + + +def visualize(pcoll, dynamic_plotting_interval=None): + """Visualizes the data of a given PCollection. Optionally enables dynamic + plotting with interval in seconds if the PCollection is being produced by a + running pipeline or the pipeline is streaming indefinitely. The function + always returns immediately and is asynchronous when dynamic plotting is on. + + If dynamic plotting enabled, the visualization is updated continuously until + the pipeline producing the PCollection is in an end state. The visualization + would be anchored to the notebook cell output area. The
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=332713&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-332713 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 23/Oct/19 17:46 Start Date: 23/Oct/19 17:46 Worklog Time Spent: 10m Work Description: aaltay commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r338181749 ## File path: sdks/python/apache_beam/runners/interactive/display/pcoll_visualization.py ## @@ -0,0 +1,279 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +#http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +"""Module visualizes PCollection data. + +For internal use only; no backwards-compatibility guarantees. +Only works with Python 3.5+. +""" +from __future__ import absolute_import + +import base64 +import logging +from datetime import timedelta + +from pandas.io.json import json_normalize + +from apache_beam import pvalue +from apache_beam.runners.interactive import interactive_environment as ie +from apache_beam.runners.interactive import pipeline_instrument as instr + +# jsons doesn't support < Python 3.5. Work around with json for legacy tests. +# TODO(BEAM-8288): clean up once Py2 is deprecated from Beam. +try: + import jsons + _pv_jsons_load = jsons.load + _pv_jsons_dump = jsons.dump +except ImportError: + import json + _pv_jsons_load = json.load + _pv_jsons_dump = json.dump + +try: + from facets_overview.generic_feature_statistics_generator import GenericFeatureStatisticsGenerator + _facets_gfsg_ready = True +except ImportError: + _facets_gfsg_ready = False + +try: + from IPython.core.display import HTML + from IPython.core.display import Javascript + from IPython.core.display import display + from IPython.core.display import display_javascript + from IPython.core.display import update_display + _ipython_ready = True +except ImportError: + _ipython_ready = False + +try: + from timeloop import Timeloop + _tl_ready = True +except ImportError: + _tl_ready = False + +# 1-d types that need additional normalization to be compatible with DataFrame. +_one_dimension_types = (int, float, str, bool, list, tuple) + +_DIVE_SCRIPT_TEMPLATE = """ +document.querySelector("#{display_id}").data = {jsonstr};""" +_DIVE_HTML_TEMPLATE = """ +https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/1.3.3/webcomponents-lite.js";> Review comment: I am not sure how to verify that this template is correct. How can we test this? 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: 332713) Time Spent: 9h 40m (was: 9.5h) > Visualize PCollection with Interactive Beam > --- > > 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: 9h 40m > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=332718&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-332718 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 23/Oct/19 17:46 Start Date: 23/Oct/19 17:46 Worklog Time Spent: 10m Work Description: aaltay commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r338185724 ## File path: sdks/python/apache_beam/runners/interactive/display/pcoll_visualization_test.py ## @@ -0,0 +1,152 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +#http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +"""Tests for apache_beam.runners.interactive.display.pcoll_visualization.""" +from __future__ import absolute_import + +import sys +import time +import unittest + +import apache_beam as beam # pylint: disable=ungrouped-imports +import timeloop +from apache_beam.runners import runner +from apache_beam.runners.interactive import interactive_environment as ie +from apache_beam.runners.interactive.display import pcoll_visualization as pv + +# Work around nose tests using Python2 without unittest.mock module. +try: + from unittest.mock import patch +except ImportError: + from mock import patch + + +class PCollVisualizationTest(unittest.TestCase): + + def setUp(self): +self._p = beam.Pipeline() +# pylint: disable=range-builtin-not-iterating +self._pcoll = self._p | 'Create' >> beam.Create(range(1000)) + + @unittest.skipIf(sys.version_info < (3, 5, 3), + 'PCollVisualization is not supported on Python 2.') + def test_raise_error_for_non_pcoll_input(self): +class Foo(object): + pass + +with self.assertRaises(AssertionError) as ctx: + pv.PCollVisualization(Foo()) + self.assertTrue('pcoll should be apache_beam.pvalue.PCollection' in + ctx.exception) + + @unittest.skipIf(sys.version_info < (3, 5, 3), + 'PCollVisualization is not supported on Python 2.') + def test_pcoll_visualization_generate_unique_display_id(self): +pv_1 = pv.PCollVisualization(self._pcoll) +pv_2 = pv.PCollVisualization(self._pcoll) +self.assertNotEqual(pv_1._dive_display_id, pv_2._dive_display_id) +self.assertNotEqual(pv_1._overview_display_id, pv_2._overview_display_id) +self.assertNotEqual(pv_1._df_display_id, pv_2._df_display_id) + + @unittest.skipIf(sys.version_info < (3, 5, 3), + 'PCollVisualization is not supported on Python 2.') + @patch('apache_beam.runners.interactive.display.pcoll_visualization' + '.PCollVisualization._to_element_list', lambda x: [1, 2, 3]) + def test_one_shot_visualization_not_return_handle(self): +self.assertIsNone(pv.visualize(self._pcoll)) + + def _mock_to_element_list(self): +yield [1, 2, 3] +yield [1, 2, 3, 4] +yield [1, 2, 3, 4, 5] +yield [1, 2, 3, 4, 5, 6] +yield [1, 2, 3, 4, 5, 6, 7] +yield [1, 2, 3, 4, 5, 6, 7, 8] + + @unittest.skipIf(sys.version_info < (3, 5, 3), + 'PCollVisualization is not supported on Python 2.') + @patch('apache_beam.runners.interactive.display.pcoll_visualization' + '.PCollVisualization._to_element_list', _mock_to_element_list) + def test_dynamic_plotting_return_handle(self): +h = pv.visualize(self._pcoll, dynamic_plotting_interval=1) +self.assertIsInstance(h, timeloop.Timeloop) +h.stop() + + @unittest.skipIf(sys.version_info < (3, 5, 3), + 'PCollVisualization is not supported on Python 2.') + @patch('apache_beam.runners.interactive.display.pcoll_visualization' + '.PCollVisualization._to_element_list', _mock_to_element_list) + @patch('apache_beam.runners.interactive.display.pcoll_visualization' + '.PCollVisualization.display_facets') + def test_dynamic_plotting_update_same_display(self, +mocked_display_facets): +fake_pipeline_result = runner.PipelineResult(runner.PipelineState.RUNNING) +ie.current_env().set_pipeline_result(self._p, fake_pipeline_result) +# Starts async dynamic plotting that neve
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=332715&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-332715 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 23/Oct/19 17:46 Start Date: 23/Oct/19 17:46 Worklog Time Spent: 10m Work Description: aaltay commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r338183130 ## File path: sdks/python/apache_beam/runners/interactive/display/pcoll_visualization.py ## @@ -0,0 +1,279 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +#http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +"""Module visualizes PCollection data. + +For internal use only; no backwards-compatibility guarantees. +Only works with Python 3.5+. +""" +from __future__ import absolute_import + +import base64 +import logging +from datetime import timedelta + +from pandas.io.json import json_normalize + +from apache_beam import pvalue +from apache_beam.runners.interactive import interactive_environment as ie +from apache_beam.runners.interactive import pipeline_instrument as instr + +# jsons doesn't support < Python 3.5. Work around with json for legacy tests. +# TODO(BEAM-8288): clean up once Py2 is deprecated from Beam. +try: + import jsons + _pv_jsons_load = jsons.load + _pv_jsons_dump = jsons.dump +except ImportError: + import json + _pv_jsons_load = json.load + _pv_jsons_dump = json.dump + +try: + from facets_overview.generic_feature_statistics_generator import GenericFeatureStatisticsGenerator + _facets_gfsg_ready = True +except ImportError: + _facets_gfsg_ready = False + +try: + from IPython.core.display import HTML + from IPython.core.display import Javascript + from IPython.core.display import display + from IPython.core.display import display_javascript + from IPython.core.display import update_display + _ipython_ready = True +except ImportError: + _ipython_ready = False + +try: + from timeloop import Timeloop + _tl_ready = True +except ImportError: + _tl_ready = False + +# 1-d types that need additional normalization to be compatible with DataFrame. +_one_dimension_types = (int, float, str, bool, list, tuple) + +_DIVE_SCRIPT_TEMPLATE = """ +document.querySelector("#{display_id}").data = {jsonstr};""" +_DIVE_HTML_TEMPLATE = """ +https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/1.3.3/webcomponents-lite.js";> +https://raw.githubusercontent.com/PAIR-code/facets/1.0.0/facets-dist/facets-jupyter.html";> + + + document.querySelector("#{display_id}").data = {jsonstr}; +""" +_OVERVIEW_SCRIPT_TEMPLATE = """ + document.querySelector("#{display_id}").protoInput = "{protostr}"; + """ +_OVERVIEW_HTML_TEMPLATE = """ +https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/1.3.3/webcomponents-lite.js";> +https://raw.githubusercontent.com/PAIR-code/facets/1.0.0/facets-dist/facets-jupyter.html";> + + + document.querySelector("#{display_id}").protoInput = "{protostr}"; +""" +_DATAFRAME_PAGINATION_TEMPLATE = """ +https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js";> +https://cdn.datatables.net/1.10.16/js/jquery.dataTables.js";> +https://cdn.datatables.net/1.10.16/css/jquery.dataTables.css";> +{dataframe_html} + + $("#{table_id}").DataTable(); +""" + + +def visualize(pcoll, dynamic_plotting_interval=None): + """Visualizes the data of a given PCollection. Optionally enables dynamic + plotting with interval in seconds if the PCollection is being produced by a + running pipeline or the pipeline is streaming indefinitely. The function + always returns immediately and is asynchronous when dynamic plotting is on. + + If dynamic plotting enabled, the visualization is updated continuously until + the pipeline producing the PCollection is in an end state. The visualization + would be anchored to the notebook cell output area. The
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=332721&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-332721 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 23/Oct/19 17:46 Start Date: 23/Oct/19 17:46 Worklog Time Spent: 10m Work Description: aaltay commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r338188202 ## File path: sdks/python/setup.py ## @@ -166,6 +166,14 @@ def get_version(): 'google-cloud-bigtable>=0.31.1,<1.1.0', ] +INTERACTIVE_BEAM = [ +'facets-overview>=1.0.0,<2', Review comment: Could you sort these dependencies? 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: 332721) Time Spent: 10h 40m (was: 10.5h) > Visualize PCollection with Interactive Beam > --- > > 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: 10h 40m > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=332710&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-332710 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 23/Oct/19 17:46 Start Date: 23/Oct/19 17:46 Worklog Time Spent: 10m Work Description: aaltay commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r338187025 ## File path: sdks/python/apache_beam/runners/interactive/interactive_environment.py ## @@ -61,8 +66,20 @@ def __init__(self, cache_manager=None): self._watching_set = set() # Holds variables list of (Dict[str, object]). self._watching_dict_list = [] +# Holds results of pipeline runs as Dict[Pipeline, PipelineResult]. +# Each key is a pipeline instance defined by the end user. The +# InteractiveRunner is responsible for populating this dictionary +# implicitly. +self._pipeline_results = {} # Always watch __main__ module. self.watch('__main__') +# Do a warning level logging if current python version is below 2 or 3.5.3. +if sys.version_info < (3,): + logging.warning('Interactive Beam does not support Python 2.') +elif sys.version_info < (3, 5, 3): Review comment: Should we simply say interactivity required 3.5.3 ? 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: 332710) Time Spent: 9h 10m (was: 9h) > Visualize PCollection with Interactive Beam > --- > > 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: 9h 10m > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=332714&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-332714 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 23/Oct/19 17:46 Start Date: 23/Oct/19 17:46 Worklog Time Spent: 10m Work Description: aaltay commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r338188609 ## File path: sdks/python/setup.py ## @@ -219,11 +227,15 @@ def run(self): install_requires=REQUIRED_PACKAGES, python_requires=python_requires, test_suite='nose.collector', -tests_require=REQUIRED_TEST_PACKAGES, +tests_require=[ +REQUIRED_TEST_PACKAGES, +INTERACTIVE_BEAM, Review comment: We can add a tox suite to test interactivity similar to gcp suites and not install these dependencies for all tests. 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: 332714) Time Spent: 9h 50m (was: 9h 40m) > Visualize PCollection with Interactive Beam > --- > > 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: 9h 50m > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=332755&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-332755 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 23/Oct/19 18:13 Start Date: 23/Oct/19 18:13 Worklog Time Spent: 10m Work Description: KevinGG commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r338202593 ## File path: sdks/python/apache_beam/runners/interactive/display/pcoll_visualization.py ## @@ -0,0 +1,279 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +#http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +"""Module visualizes PCollection data. + +For internal use only; no backwards-compatibility guarantees. +Only works with Python 3.5+. +""" +from __future__ import absolute_import + +import base64 +import logging +from datetime import timedelta + +from pandas.io.json import json_normalize + +from apache_beam import pvalue +from apache_beam.runners.interactive import interactive_environment as ie +from apache_beam.runners.interactive import pipeline_instrument as instr + +# jsons doesn't support < Python 3.5. Work around with json for legacy tests. +# TODO(BEAM-8288): clean up once Py2 is deprecated from Beam. +try: + import jsons + _pv_jsons_load = jsons.load + _pv_jsons_dump = jsons.dump +except ImportError: + import json + _pv_jsons_load = json.load Review comment: `json` wouldn't support all the data structure that might come from the user's data. But `jsons` and `json` have similar usage and interfaces. So it's a try-best effort to serialize the user's data. We can also simply NOOP if `jsons` is not available. Here is the reference _Why not use the standard json library_: https://jsons.readthedocs.io/en/latest/faq.html#why-not-use-the-standard-json-library 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: 332755) Time Spent: 11h (was: 10h 50m) > Visualize PCollection with Interactive Beam > --- > > 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: 11h > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=332754&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-332754 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 23/Oct/19 18:13 Start Date: 23/Oct/19 18:13 Worklog Time Spent: 10m Work Description: KevinGG commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r338202593 ## File path: sdks/python/apache_beam/runners/interactive/display/pcoll_visualization.py ## @@ -0,0 +1,279 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +#http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +"""Module visualizes PCollection data. + +For internal use only; no backwards-compatibility guarantees. +Only works with Python 3.5+. +""" +from __future__ import absolute_import + +import base64 +import logging +from datetime import timedelta + +from pandas.io.json import json_normalize + +from apache_beam import pvalue +from apache_beam.runners.interactive import interactive_environment as ie +from apache_beam.runners.interactive import pipeline_instrument as instr + +# jsons doesn't support < Python 3.5. Work around with json for legacy tests. +# TODO(BEAM-8288): clean up once Py2 is deprecated from Beam. +try: + import jsons + _pv_jsons_load = jsons.load + _pv_jsons_dump = jsons.dump +except ImportError: + import json + _pv_jsons_load = json.load Review comment: `json` wouldn't support all the data structure that might come from the user's data. But `jsons` and `json` have similar usage and interfaces. So it's a try-best effort to serialize the user's data. We can also simply NOOP if jsons is not available. Here is the reference _Why not use the standard json library_: https://jsons.readthedocs.io/en/latest/faq.html#why-not-use-the-standard-json-library 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: 332754) Time Spent: 10h 50m (was: 10h 40m) > Visualize PCollection with Interactive Beam > --- > > 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: 10h 50m > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=332764&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-332764 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 23/Oct/19 18:22 Start Date: 23/Oct/19 18:22 Worklog Time Spent: 10m Work Description: KevinGG commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r338206875 ## File path: sdks/python/apache_beam/runners/interactive/display/pcoll_visualization.py ## @@ -0,0 +1,279 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +#http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +"""Module visualizes PCollection data. + +For internal use only; no backwards-compatibility guarantees. +Only works with Python 3.5+. +""" +from __future__ import absolute_import + +import base64 +import logging +from datetime import timedelta + +from pandas.io.json import json_normalize + +from apache_beam import pvalue +from apache_beam.runners.interactive import interactive_environment as ie +from apache_beam.runners.interactive import pipeline_instrument as instr + +# jsons doesn't support < Python 3.5. Work around with json for legacy tests. +# TODO(BEAM-8288): clean up once Py2 is deprecated from Beam. +try: + import jsons + _pv_jsons_load = jsons.load + _pv_jsons_dump = jsons.dump +except ImportError: + import json + _pv_jsons_load = json.load + _pv_jsons_dump = json.dump + +try: + from facets_overview.generic_feature_statistics_generator import GenericFeatureStatisticsGenerator + _facets_gfsg_ready = True +except ImportError: + _facets_gfsg_ready = False Review comment: They can work separately. If not _ipython_ready, the user is not even in an interactive environment. There is no kernel, so there is definitely no frontend connected to the kernel. Thus no notebook, nowhere to visualize, so basically everything is NOOP. If not _facets_gfsg_ready, the user wouldn't see the facets-dive widget, but they can see facets-overview and data-table widgets. If not _tl_ready, the user wouldn't see dynamic plotting but one-shot plotting. Warning about the user to install [interactive] is a great suggestion! I can 1. make it import all and NOOP if any of the dependency is not ready 2. make it import separately and try-best to do visualization Either way, I'll add the warning for users to `pip install apache-beam[interactive]`. Which option do you like? 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: 332764) Time Spent: 11h 10m (was: 11h) > Visualize PCollection with Interactive Beam > --- > > 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: 11h 10m > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=332772&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-332772 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 23/Oct/19 18:31 Start Date: 23/Oct/19 18:31 Worklog Time Spent: 10m Work Description: KevinGG commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r338210890 ## File path: sdks/python/apache_beam/runners/interactive/display/pcoll_visualization.py ## @@ -0,0 +1,279 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +#http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +"""Module visualizes PCollection data. + +For internal use only; no backwards-compatibility guarantees. +Only works with Python 3.5+. +""" +from __future__ import absolute_import + +import base64 +import logging +from datetime import timedelta + +from pandas.io.json import json_normalize + +from apache_beam import pvalue +from apache_beam.runners.interactive import interactive_environment as ie +from apache_beam.runners.interactive import pipeline_instrument as instr + +# jsons doesn't support < Python 3.5. Work around with json for legacy tests. +# TODO(BEAM-8288): clean up once Py2 is deprecated from Beam. +try: + import jsons + _pv_jsons_load = jsons.load + _pv_jsons_dump = jsons.dump +except ImportError: + import json + _pv_jsons_load = json.load + _pv_jsons_dump = json.dump + +try: + from facets_overview.generic_feature_statistics_generator import GenericFeatureStatisticsGenerator + _facets_gfsg_ready = True +except ImportError: + _facets_gfsg_ready = False + +try: + from IPython.core.display import HTML + from IPython.core.display import Javascript + from IPython.core.display import display + from IPython.core.display import display_javascript + from IPython.core.display import update_display + _ipython_ready = True +except ImportError: + _ipython_ready = False + +try: + from timeloop import Timeloop + _tl_ready = True +except ImportError: + _tl_ready = False + +# 1-d types that need additional normalization to be compatible with DataFrame. +_one_dimension_types = (int, float, str, bool, list, tuple) + +_DIVE_SCRIPT_TEMPLATE = """ +document.querySelector("#{display_id}").data = {jsonstr};""" +_DIVE_HTML_TEMPLATE = """ +https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/1.3.3/webcomponents-lite.js";> Review comment: The `facets` templates originate from examples in notebooks shared among the OSS community. The `jquery` template simply uses a jquery DataTable widget. For unittest, the logic of each template is too simple that there is nothing really to be tested. We'll have some integration test later to execute notebook and verify output area. Such integration test framework is being developed by some other team. We'll merge our efforts there. For manual test, I've manually tested them from notebook. I can attach png and gif if needed. Off the topic: In future PRs, we might have `%%javascript` magic involved in the python code. Then we can have some library such as `js2py` for javascript unittests in Python. 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: 332772) Time Spent: 11h 20m (was: 11h 10m) > Visualize PCollection with Interactive Beam > --- > > 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: 11h 20m > Remaining Estimate: 0h > > Support auto plotting / charting of materializ
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=332775&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-332775 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 23/Oct/19 18:32 Start Date: 23/Oct/19 18:32 Worklog Time Spent: 10m Work Description: KevinGG commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r338210890 ## File path: sdks/python/apache_beam/runners/interactive/display/pcoll_visualization.py ## @@ -0,0 +1,279 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +#http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +"""Module visualizes PCollection data. + +For internal use only; no backwards-compatibility guarantees. +Only works with Python 3.5+. +""" +from __future__ import absolute_import + +import base64 +import logging +from datetime import timedelta + +from pandas.io.json import json_normalize + +from apache_beam import pvalue +from apache_beam.runners.interactive import interactive_environment as ie +from apache_beam.runners.interactive import pipeline_instrument as instr + +# jsons doesn't support < Python 3.5. Work around with json for legacy tests. +# TODO(BEAM-8288): clean up once Py2 is deprecated from Beam. +try: + import jsons + _pv_jsons_load = jsons.load + _pv_jsons_dump = jsons.dump +except ImportError: + import json + _pv_jsons_load = json.load + _pv_jsons_dump = json.dump + +try: + from facets_overview.generic_feature_statistics_generator import GenericFeatureStatisticsGenerator + _facets_gfsg_ready = True +except ImportError: + _facets_gfsg_ready = False + +try: + from IPython.core.display import HTML + from IPython.core.display import Javascript + from IPython.core.display import display + from IPython.core.display import display_javascript + from IPython.core.display import update_display + _ipython_ready = True +except ImportError: + _ipython_ready = False + +try: + from timeloop import Timeloop + _tl_ready = True +except ImportError: + _tl_ready = False + +# 1-d types that need additional normalization to be compatible with DataFrame. +_one_dimension_types = (int, float, str, bool, list, tuple) + +_DIVE_SCRIPT_TEMPLATE = """ +document.querySelector("#{display_id}").data = {jsonstr};""" +_DIVE_HTML_TEMPLATE = """ +https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/1.3.3/webcomponents-lite.js";> Review comment: The `facets` templates originate from examples in notebooks shared among the OSS community. The `jquery` template simply uses a jquery DataTable widget. For unittest, the logic of each template is too simple that there is nothing really to be tested. The logic I added to set display_id and update existing widgets have been unittested. We'll have some integration test later to execute notebook and verify output area. Such integration test framework is being developed by some other team. We'll merge our efforts there. For manual test, I've manually tested them from notebook. I can attach png and gif if needed. Off the topic: In future PRs, we might have `%%javascript` magic involved in the python code. Then we can have some library such as `js2py` for javascript unittests in Python. 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: 332775) Time Spent: 11h 40m (was: 11.5h) > Visualize PCollection with Interactive Beam > --- > > 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 Spe
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=332774&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-332774 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 23/Oct/19 18:32 Start Date: 23/Oct/19 18:32 Worklog Time Spent: 10m Work Description: KevinGG commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r338210890 ## File path: sdks/python/apache_beam/runners/interactive/display/pcoll_visualization.py ## @@ -0,0 +1,279 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +#http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +"""Module visualizes PCollection data. + +For internal use only; no backwards-compatibility guarantees. +Only works with Python 3.5+. +""" +from __future__ import absolute_import + +import base64 +import logging +from datetime import timedelta + +from pandas.io.json import json_normalize + +from apache_beam import pvalue +from apache_beam.runners.interactive import interactive_environment as ie +from apache_beam.runners.interactive import pipeline_instrument as instr + +# jsons doesn't support < Python 3.5. Work around with json for legacy tests. +# TODO(BEAM-8288): clean up once Py2 is deprecated from Beam. +try: + import jsons + _pv_jsons_load = jsons.load + _pv_jsons_dump = jsons.dump +except ImportError: + import json + _pv_jsons_load = json.load + _pv_jsons_dump = json.dump + +try: + from facets_overview.generic_feature_statistics_generator import GenericFeatureStatisticsGenerator + _facets_gfsg_ready = True +except ImportError: + _facets_gfsg_ready = False + +try: + from IPython.core.display import HTML + from IPython.core.display import Javascript + from IPython.core.display import display + from IPython.core.display import display_javascript + from IPython.core.display import update_display + _ipython_ready = True +except ImportError: + _ipython_ready = False + +try: + from timeloop import Timeloop + _tl_ready = True +except ImportError: + _tl_ready = False + +# 1-d types that need additional normalization to be compatible with DataFrame. +_one_dimension_types = (int, float, str, bool, list, tuple) + +_DIVE_SCRIPT_TEMPLATE = """ +document.querySelector("#{display_id}").data = {jsonstr};""" +_DIVE_HTML_TEMPLATE = """ +https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/1.3.3/webcomponents-lite.js";> Review comment: The `facets` templates originate from examples in notebooks shared among the OSS community. The `jquery` template simply uses a jquery DataTable widget. For unittest, the logic of each template is too simple that there is nothing really to be tested. The logic I've added to set display_id and update existing widgets have been unittested. We'll have some integration test later to execute notebook and verify output area. Such integration test framework is being developed by some other team. We'll merge our efforts there. For manual test, I've manually tested them from notebook. I can attach png and gif if needed. Off the topic: In future PRs, we might have `%%javascript` magic involved in the python code. Then we can have some library such as `js2py` for javascript unittests in Python. 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: 332774) Time Spent: 11.5h (was: 11h 20m) > Visualize PCollection with Interactive Beam > --- > > 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
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=332777&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-332777 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 23/Oct/19 18:37 Start Date: 23/Oct/19 18:37 Worklog Time Spent: 10m Work Description: KevinGG commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r338213864 ## File path: sdks/python/apache_beam/runners/interactive/display/pcoll_visualization.py ## @@ -0,0 +1,279 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +#http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +"""Module visualizes PCollection data. + +For internal use only; no backwards-compatibility guarantees. +Only works with Python 3.5+. +""" +from __future__ import absolute_import + +import base64 +import logging +from datetime import timedelta + +from pandas.io.json import json_normalize + +from apache_beam import pvalue +from apache_beam.runners.interactive import interactive_environment as ie +from apache_beam.runners.interactive import pipeline_instrument as instr + +# jsons doesn't support < Python 3.5. Work around with json for legacy tests. +# TODO(BEAM-8288): clean up once Py2 is deprecated from Beam. +try: + import jsons + _pv_jsons_load = jsons.load + _pv_jsons_dump = jsons.dump +except ImportError: + import json + _pv_jsons_load = json.load + _pv_jsons_dump = json.dump + +try: + from facets_overview.generic_feature_statistics_generator import GenericFeatureStatisticsGenerator + _facets_gfsg_ready = True +except ImportError: + _facets_gfsg_ready = False + +try: + from IPython.core.display import HTML + from IPython.core.display import Javascript + from IPython.core.display import display + from IPython.core.display import display_javascript + from IPython.core.display import update_display + _ipython_ready = True +except ImportError: + _ipython_ready = False + +try: + from timeloop import Timeloop + _tl_ready = True +except ImportError: + _tl_ready = False + +# 1-d types that need additional normalization to be compatible with DataFrame. +_one_dimension_types = (int, float, str, bool, list, tuple) + +_DIVE_SCRIPT_TEMPLATE = """ +document.querySelector("#{display_id}").data = {jsonstr};""" +_DIVE_HTML_TEMPLATE = """ +https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/1.3.3/webcomponents-lite.js";> +https://raw.githubusercontent.com/PAIR-code/facets/1.0.0/facets-dist/facets-jupyter.html";> + + + document.querySelector("#{display_id}").data = {jsonstr}; +""" +_OVERVIEW_SCRIPT_TEMPLATE = """ + document.querySelector("#{display_id}").protoInput = "{protostr}"; + """ +_OVERVIEW_HTML_TEMPLATE = """ +https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/1.3.3/webcomponents-lite.js";> +https://raw.githubusercontent.com/PAIR-code/facets/1.0.0/facets-dist/facets-jupyter.html";> + + + document.querySelector("#{display_id}").protoInput = "{protostr}"; +""" +_DATAFRAME_PAGINATION_TEMPLATE = """ +https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js";> +https://cdn.datatables.net/1.10.16/js/jquery.dataTables.js";> +https://cdn.datatables.net/1.10.16/css/jquery.dataTables.css";> +{dataframe_html} + + $("#{table_id}").DataTable(); +""" + + +def visualize(pcoll, dynamic_plotting_interval=None): + """Visualizes the data of a given PCollection. Optionally enables dynamic + plotting with interval in seconds if the PCollection is being produced by a + running pipeline or the pipeline is streaming indefinitely. The function + always returns immediately and is asynchronous when dynamic plotting is on. + + If dynamic plotting enabled, the visualization is updated continuously until + the pipeline producing the PCollection is in an end state. The visualization + would be anchored to the notebook cell output area. The
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=332787&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-332787 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 23/Oct/19 18:44 Start Date: 23/Oct/19 18:44 Worklog Time Spent: 10m Work Description: KevinGG commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r338217168 ## File path: sdks/python/apache_beam/runners/interactive/display/pcoll_visualization_test.py ## @@ -0,0 +1,152 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +#http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +"""Tests for apache_beam.runners.interactive.display.pcoll_visualization.""" +from __future__ import absolute_import + +import sys +import time +import unittest + +import apache_beam as beam # pylint: disable=ungrouped-imports +import timeloop +from apache_beam.runners import runner +from apache_beam.runners.interactive import interactive_environment as ie +from apache_beam.runners.interactive.display import pcoll_visualization as pv + +# Work around nose tests using Python2 without unittest.mock module. +try: + from unittest.mock import patch +except ImportError: + from mock import patch + + +class PCollVisualizationTest(unittest.TestCase): + + def setUp(self): +self._p = beam.Pipeline() +# pylint: disable=range-builtin-not-iterating +self._pcoll = self._p | 'Create' >> beam.Create(range(1000)) + + @unittest.skipIf(sys.version_info < (3, 5, 3), + 'PCollVisualization is not supported on Python 2.') + def test_raise_error_for_non_pcoll_input(self): +class Foo(object): + pass + +with self.assertRaises(AssertionError) as ctx: + pv.PCollVisualization(Foo()) + self.assertTrue('pcoll should be apache_beam.pvalue.PCollection' in + ctx.exception) + + @unittest.skipIf(sys.version_info < (3, 5, 3), + 'PCollVisualization is not supported on Python 2.') + def test_pcoll_visualization_generate_unique_display_id(self): +pv_1 = pv.PCollVisualization(self._pcoll) +pv_2 = pv.PCollVisualization(self._pcoll) +self.assertNotEqual(pv_1._dive_display_id, pv_2._dive_display_id) +self.assertNotEqual(pv_1._overview_display_id, pv_2._overview_display_id) +self.assertNotEqual(pv_1._df_display_id, pv_2._df_display_id) + + @unittest.skipIf(sys.version_info < (3, 5, 3), + 'PCollVisualization is not supported on Python 2.') + @patch('apache_beam.runners.interactive.display.pcoll_visualization' + '.PCollVisualization._to_element_list', lambda x: [1, 2, 3]) + def test_one_shot_visualization_not_return_handle(self): +self.assertIsNone(pv.visualize(self._pcoll)) + + def _mock_to_element_list(self): +yield [1, 2, 3] +yield [1, 2, 3, 4] +yield [1, 2, 3, 4, 5] +yield [1, 2, 3, 4, 5, 6] +yield [1, 2, 3, 4, 5, 6, 7] +yield [1, 2, 3, 4, 5, 6, 7, 8] + + @unittest.skipIf(sys.version_info < (3, 5, 3), + 'PCollVisualization is not supported on Python 2.') + @patch('apache_beam.runners.interactive.display.pcoll_visualization' + '.PCollVisualization._to_element_list', _mock_to_element_list) + def test_dynamic_plotting_return_handle(self): +h = pv.visualize(self._pcoll, dynamic_plotting_interval=1) +self.assertIsInstance(h, timeloop.Timeloop) +h.stop() + + @unittest.skipIf(sys.version_info < (3, 5, 3), + 'PCollVisualization is not supported on Python 2.') + @patch('apache_beam.runners.interactive.display.pcoll_visualization' + '.PCollVisualization._to_element_list', _mock_to_element_list) + @patch('apache_beam.runners.interactive.display.pcoll_visualization' + '.PCollVisualization.display_facets') + def test_dynamic_plotting_update_same_display(self, +mocked_display_facets): +fake_pipeline_result = runner.PipelineResult(runner.PipelineState.RUNNING) +ie.current_env().set_pipeline_result(self._p, fake_pipeline_result) +# Starts async dynamic plotting that nev
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=332797&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-332797 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 23/Oct/19 18:47 Start Date: 23/Oct/19 18:47 Worklog Time Spent: 10m Work Description: KevinGG commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r338218476 ## File path: sdks/python/apache_beam/runners/interactive/interactive_environment.py ## @@ -61,8 +66,20 @@ def __init__(self, cache_manager=None): self._watching_set = set() # Holds variables list of (Dict[str, object]). self._watching_dict_list = [] +# Holds results of pipeline runs as Dict[Pipeline, PipelineResult]. +# Each key is a pipeline instance defined by the end user. The +# InteractiveRunner is responsible for populating this dictionary +# implicitly. +self._pipeline_results = {} # Always watch __main__ module. self.watch('__main__') +# Do a warning level logging if current python version is below 2 or 3.5.3. +if sys.version_info < (3,): + logging.warning('Interactive Beam does not support Python 2.') +elif sys.version_info < (3, 5, 3): Review comment: We can. I'll make it simpler. Let's just consider every different component a big feature. The feature requires Py 3.5.3. And we NOOP if dependency is not ready. 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: 332797) Time Spent: 12h 10m (was: 12h) > Visualize PCollection with Interactive Beam > --- > > 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: 12h 10m > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=332798&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-332798 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 23/Oct/19 18:48 Start Date: 23/Oct/19 18:48 Worklog Time Spent: 10m Work Description: KevinGG commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r338218993 ## File path: sdks/python/apache_beam/runners/interactive/interactive_environment_test.py ## @@ -88,6 +91,72 @@ def test_watch_class_instance(self): self.assertVariableWatched('_var_in_class_instance', self._var_in_class_instance) + def test_fail_to_set_pipeline_result_key_not_pipeline(self): +class NotPipeline(object): + pass + +with self.assertRaises(AssertionError) as ctx: + ie.current_env().set_pipeline_result(NotPipeline(), + runner.PipelineResult( + runner.PipelineState.RUNNING)) + self.assertTrue('pipeline must be an instance of apache_beam.Pipeline ' + 'or its subclass' in ctx.exception) + + def test_fail_to_set_pipeline_result_value_not_pipeline_result(self): +class NotResult(object): + pass + +with self.assertRaises(AssertionError) as ctx: + ie.current_env().set_pipeline_result(self._p, NotResult()) + self.assertTrue('result must be an instance of ' + 'apache_beam.runners.runner.PipelineResult or its ' + 'subclass' in ctx.exception) + + def test_set_pipeline_result_successfully(self): +class PipelineSubClass(beam.Pipeline): + pass + +class PipelineResultSubClass(runner.PipelineResult): + pass + +pipeline = PipelineSubClass() +pipeline_result = PipelineResultSubClass(runner.PipelineState.RUNNING) +ie.current_env().set_pipeline_result(pipeline, pipeline_result) +self.assertIs(ie.current_env().pipeline_result(pipeline), pipeline_result) + + def test_determine_terminal_state(self): +for state in (runner.PipelineState.DONE, + runner.PipelineState.FAILED, + runner.PipelineState.CANCELLED, + runner.PipelineState.UPDATED, + runner.PipelineState.DRAINED): + ie.current_env().set_pipeline_result(self._p, runner.PipelineResult( Review comment: Great, thanks! I totally missed it. I'll change it to use that class method. 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: 332798) Time Spent: 12h 20m (was: 12h 10m) > Visualize PCollection with Interactive Beam > --- > > 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: 12h 20m > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=332801&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-332801 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 23/Oct/19 18:56 Start Date: 23/Oct/19 18:56 Worklog Time Spent: 10m Work Description: KevinGG commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r338222750 ## File path: sdks/python/setup.py ## @@ -219,11 +227,15 @@ def run(self): install_requires=REQUIRED_PACKAGES, python_requires=python_requires, test_suite='nose.collector', -tests_require=REQUIRED_TEST_PACKAGES, +tests_require=[ +REQUIRED_TEST_PACKAGES, +INTERACTIVE_BEAM, Review comment: Yes, I agree! This could avoid running those tests when python version is under 3.5.3. I guess then the only task would require [interactive] for older versioned python will be "docs" where it scans the source code. I'll just add the try-import statements everywhere to work around it. 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: 332801) Time Spent: 12.5h (was: 12h 20m) > Visualize PCollection with Interactive Beam > --- > > 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: 12.5h > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=332802&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-332802 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 23/Oct/19 18:57 Start Date: 23/Oct/19 18:57 Worklog Time Spent: 10m Work Description: KevinGG commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r338223025 ## File path: sdks/python/apache_beam/runners/interactive/display/pcoll_visualization.py ## @@ -0,0 +1,279 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +#http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +"""Module visualizes PCollection data. + +For internal use only; no backwards-compatibility guarantees. +Only works with Python 3.5+. +""" +from __future__ import absolute_import + +import base64 +import logging +from datetime import timedelta + +from pandas.io.json import json_normalize + +from apache_beam import pvalue +from apache_beam.runners.interactive import interactive_environment as ie +from apache_beam.runners.interactive import pipeline_instrument as instr + +# jsons doesn't support < Python 3.5. Work around with json for legacy tests. +# TODO(BEAM-8288): clean up once Py2 is deprecated from Beam. +try: + import jsons + _pv_jsons_load = jsons.load + _pv_jsons_dump = jsons.dump +except ImportError: + import json + _pv_jsons_load = json.load + _pv_jsons_dump = json.dump + +try: + from facets_overview.generic_feature_statistics_generator import GenericFeatureStatisticsGenerator + _facets_gfsg_ready = True +except ImportError: + _facets_gfsg_ready = False + +try: + from IPython.core.display import HTML + from IPython.core.display import Javascript + from IPython.core.display import display + from IPython.core.display import display_javascript + from IPython.core.display import update_display + _ipython_ready = True +except ImportError: + _ipython_ready = False + +try: + from timeloop import Timeloop + _tl_ready = True +except ImportError: + _tl_ready = False + +# 1-d types that need additional normalization to be compatible with DataFrame. +_one_dimension_types = (int, float, str, bool, list, tuple) + +_DIVE_SCRIPT_TEMPLATE = """ +document.querySelector("#{display_id}").data = {jsonstr};""" +_DIVE_HTML_TEMPLATE = """ +https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/1.3.3/webcomponents-lite.js";> +https://raw.githubusercontent.com/PAIR-code/facets/1.0.0/facets-dist/facets-jupyter.html";> + + + document.querySelector("#{display_id}").data = {jsonstr}; +""" +_OVERVIEW_SCRIPT_TEMPLATE = """ + document.querySelector("#{display_id}").protoInput = "{protostr}"; + """ +_OVERVIEW_HTML_TEMPLATE = """ +https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/1.3.3/webcomponents-lite.js";> +https://raw.githubusercontent.com/PAIR-code/facets/1.0.0/facets-dist/facets-jupyter.html";> + + + document.querySelector("#{display_id}").protoInput = "{protostr}"; +""" +_DATAFRAME_PAGINATION_TEMPLATE = """ +https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js";> +https://cdn.datatables.net/1.10.16/js/jquery.dataTables.js";> +https://cdn.datatables.net/1.10.16/css/jquery.dataTables.css";> +{dataframe_html} + + $("#{table_id}").DataTable(); +""" + + +def visualize(pcoll, dynamic_plotting_interval=None): + """Visualizes the data of a given PCollection. Optionally enables dynamic + plotting with interval in seconds if the PCollection is being produced by a + running pipeline or the pipeline is streaming indefinitely. The function + always returns immediately and is asynchronous when dynamic plotting is on. + + If dynamic plotting enabled, the visualization is updated continuously until + the pipeline producing the PCollection is in an end state. The visualization + would be anchored to the notebook cell output area. The
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=332826&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-332826 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 23/Oct/19 19:37 Start Date: 23/Oct/19 19:37 Worklog Time Spent: 10m Work Description: KevinGG commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r338240149 ## File path: sdks/python/apache_beam/runners/interactive/display/pcoll_visualization_test.py ## @@ -0,0 +1,152 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +#http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +"""Tests for apache_beam.runners.interactive.display.pcoll_visualization.""" +from __future__ import absolute_import + +import sys +import time +import unittest + +import apache_beam as beam # pylint: disable=ungrouped-imports +import timeloop +from apache_beam.runners import runner +from apache_beam.runners.interactive import interactive_environment as ie +from apache_beam.runners.interactive.display import pcoll_visualization as pv + +# Work around nose tests using Python2 without unittest.mock module. +try: + from unittest.mock import patch +except ImportError: + from mock import patch + + +class PCollVisualizationTest(unittest.TestCase): + + def setUp(self): +self._p = beam.Pipeline() +# pylint: disable=range-builtin-not-iterating +self._pcoll = self._p | 'Create' >> beam.Create(range(1000)) + + @unittest.skipIf(sys.version_info < (3, 5, 3), + 'PCollVisualization is not supported on Python 2.') + def test_raise_error_for_non_pcoll_input(self): +class Foo(object): + pass + +with self.assertRaises(AssertionError) as ctx: + pv.PCollVisualization(Foo()) + self.assertTrue('pcoll should be apache_beam.pvalue.PCollection' in + ctx.exception) + + @unittest.skipIf(sys.version_info < (3, 5, 3), + 'PCollVisualization is not supported on Python 2.') + def test_pcoll_visualization_generate_unique_display_id(self): +pv_1 = pv.PCollVisualization(self._pcoll) +pv_2 = pv.PCollVisualization(self._pcoll) +self.assertNotEqual(pv_1._dive_display_id, pv_2._dive_display_id) +self.assertNotEqual(pv_1._overview_display_id, pv_2._overview_display_id) +self.assertNotEqual(pv_1._df_display_id, pv_2._df_display_id) + + @unittest.skipIf(sys.version_info < (3, 5, 3), + 'PCollVisualization is not supported on Python 2.') + @patch('apache_beam.runners.interactive.display.pcoll_visualization' + '.PCollVisualization._to_element_list', lambda x: [1, 2, 3]) + def test_one_shot_visualization_not_return_handle(self): +self.assertIsNone(pv.visualize(self._pcoll)) + + def _mock_to_element_list(self): +yield [1, 2, 3] +yield [1, 2, 3, 4] +yield [1, 2, 3, 4, 5] +yield [1, 2, 3, 4, 5, 6] +yield [1, 2, 3, 4, 5, 6, 7] +yield [1, 2, 3, 4, 5, 6, 7, 8] + + @unittest.skipIf(sys.version_info < (3, 5, 3), + 'PCollVisualization is not supported on Python 2.') + @patch('apache_beam.runners.interactive.display.pcoll_visualization' + '.PCollVisualization._to_element_list', _mock_to_element_list) + def test_dynamic_plotting_return_handle(self): +h = pv.visualize(self._pcoll, dynamic_plotting_interval=1) +self.assertIsInstance(h, timeloop.Timeloop) +h.stop() + + @unittest.skipIf(sys.version_info < (3, 5, 3), + 'PCollVisualization is not supported on Python 2.') + @patch('apache_beam.runners.interactive.display.pcoll_visualization' + '.PCollVisualization._to_element_list', _mock_to_element_list) + @patch('apache_beam.runners.interactive.display.pcoll_visualization' + '.PCollVisualization.display_facets') + def test_dynamic_plotting_update_same_display(self, +mocked_display_facets): +fake_pipeline_result = runner.PipelineResult(runner.PipelineState.RUNNING) +ie.current_env().set_pipeline_result(self._p, fake_pipeline_result) +# Starts async dynamic plotting that nev
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=332830&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-332830 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 23/Oct/19 19:46 Start Date: 23/Oct/19 19:46 Worklog Time Spent: 10m Work Description: KevinGG commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r338243645 ## File path: sdks/python/setup.py ## @@ -166,6 +166,14 @@ def get_version(): 'google-cloud-bigtable>=0.31.1,<1.1.0', ] +INTERACTIVE_BEAM = [ +'facets-overview>=1.0.0,<2', Review comment: They are already sorted. Do you want me to also sort GCP_REQUIREMENTS? 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: 332830) Time Spent: 13h (was: 12h 50m) > Visualize PCollection with Interactive Beam > --- > > 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: 13h > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=332840&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-332840 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 23/Oct/19 20:10 Start Date: 23/Oct/19 20:10 Worklog Time Spent: 10m Work Description: KevinGG commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r338253651 ## File path: sdks/python/apache_beam/runners/interactive/display/pcoll_visualization.py ## @@ -0,0 +1,279 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +#http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +"""Module visualizes PCollection data. + +For internal use only; no backwards-compatibility guarantees. +Only works with Python 3.5+. +""" +from __future__ import absolute_import + +import base64 +import logging +from datetime import timedelta + +from pandas.io.json import json_normalize + +from apache_beam import pvalue +from apache_beam.runners.interactive import interactive_environment as ie +from apache_beam.runners.interactive import pipeline_instrument as instr + +# jsons doesn't support < Python 3.5. Work around with json for legacy tests. +# TODO(BEAM-8288): clean up once Py2 is deprecated from Beam. +try: + import jsons + _pv_jsons_load = jsons.load + _pv_jsons_dump = jsons.dump +except ImportError: + import json + _pv_jsons_load = json.load + _pv_jsons_dump = json.dump + +try: + from facets_overview.generic_feature_statistics_generator import GenericFeatureStatisticsGenerator + _facets_gfsg_ready = True +except ImportError: + _facets_gfsg_ready = False + +try: + from IPython.core.display import HTML + from IPython.core.display import Javascript + from IPython.core.display import display + from IPython.core.display import display_javascript + from IPython.core.display import update_display + _ipython_ready = True +except ImportError: + _ipython_ready = False + +try: + from timeloop import Timeloop + _tl_ready = True +except ImportError: + _tl_ready = False + +# 1-d types that need additional normalization to be compatible with DataFrame. +_one_dimension_types = (int, float, str, bool, list, tuple) + +_DIVE_SCRIPT_TEMPLATE = """ +document.querySelector("#{display_id}").data = {jsonstr};""" +_DIVE_HTML_TEMPLATE = """ +https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/1.3.3/webcomponents-lite.js";> +https://raw.githubusercontent.com/PAIR-code/facets/1.0.0/facets-dist/facets-jupyter.html";> + + + document.querySelector("#{display_id}").data = {jsonstr}; +""" +_OVERVIEW_SCRIPT_TEMPLATE = """ + document.querySelector("#{display_id}").protoInput = "{protostr}"; + """ +_OVERVIEW_HTML_TEMPLATE = """ +https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/1.3.3/webcomponents-lite.js";> +https://raw.githubusercontent.com/PAIR-code/facets/1.0.0/facets-dist/facets-jupyter.html";> + + + document.querySelector("#{display_id}").protoInput = "{protostr}"; +""" +_DATAFRAME_PAGINATION_TEMPLATE = """ +https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js";> +https://cdn.datatables.net/1.10.16/js/jquery.dataTables.js";> +https://cdn.datatables.net/1.10.16/css/jquery.dataTables.css";> +{dataframe_html} + + $("#{table_id}").DataTable(); +""" + + +def visualize(pcoll, dynamic_plotting_interval=None): + """Visualizes the data of a given PCollection. Optionally enables dynamic + plotting with interval in seconds if the PCollection is being produced by a + running pipeline or the pipeline is streaming indefinitely. The function + always returns immediately and is asynchronous when dynamic plotting is on. + + If dynamic plotting enabled, the visualization is updated continuously until + the pipeline producing the PCollection is in an end state. The visualization + would be anchored to the notebook cell output area. The
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=332841&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-332841 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 23/Oct/19 20:11 Start Date: 23/Oct/19 20:11 Worklog Time Spent: 10m Work Description: KevinGG commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r338254102 ## File path: sdks/python/apache_beam/runners/interactive/display/pcoll_visualization_test.py ## @@ -0,0 +1,152 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +#http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +"""Tests for apache_beam.runners.interactive.display.pcoll_visualization.""" +from __future__ import absolute_import + +import sys +import time +import unittest + +import apache_beam as beam # pylint: disable=ungrouped-imports +import timeloop +from apache_beam.runners import runner +from apache_beam.runners.interactive import interactive_environment as ie +from apache_beam.runners.interactive.display import pcoll_visualization as pv + +# Work around nose tests using Python2 without unittest.mock module. +try: + from unittest.mock import patch +except ImportError: + from mock import patch + + +class PCollVisualizationTest(unittest.TestCase): + + def setUp(self): +self._p = beam.Pipeline() +# pylint: disable=range-builtin-not-iterating +self._pcoll = self._p | 'Create' >> beam.Create(range(1000)) + + @unittest.skipIf(sys.version_info < (3, 5, 3), + 'PCollVisualization is not supported on Python 2.') Review comment: Changing the error message. 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: 332841) Time Spent: 13h 20m (was: 13h 10m) > Visualize PCollection with Interactive Beam > --- > > 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: 13h 20m > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=332904&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-332904 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 23/Oct/19 21:21 Start Date: 23/Oct/19 21:21 Worklog Time Spent: 10m Work Description: pabloem commented on issue #9771: [BEAM-7926] Update dependencies in Java Katas URL: https://github.com/apache/beam/pull/9771#issuecomment-545641711 Alright. LGTM. I'll just ping @henryken once more, and merge in a couple days if he doesn't answer. 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: 332904) Time Spent: 13.5h (was: 13h 20m) > Visualize PCollection with Interactive Beam > --- > > 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: 13.5h > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=332918&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-332918 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 23/Oct/19 21:49 Start Date: 23/Oct/19 21:49 Worklog Time Spent: 10m Work Description: KevinGG commented on issue #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#issuecomment-545650837 I've added two tox env and corresponding Py36 and Py37 test suite. Removed [interactive] from test required packages. Added it to py2:docs env. I'll add [interactive] for other specific envs defined in tox.ini if any of the gradle task needs it. I've also added check and warnings in `interactive_environment.InteractiveEnvironment` to check prerequisites for interactive beam (didn't put them in the global scope because global scoped warning level logging will fail gradle tasks in pre-commit): 1. If Python is above 3.5.3; 2. If [interactive] dependencies are fully available; 3. If current runtime is within an interactive environment, i.e., within an ipython kernel. For the `time.sleep()` and `pcoll_visualization` NOOP strategy when dependencies are not fully installed, please let me know your preference, @aaltay. Personally I'm fine with either approaches, and I'll make change if needed. 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: 332918) Time Spent: 13h 40m (was: 13.5h) > Visualize PCollection with Interactive Beam > --- > > 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: 13h 40m > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=332920&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-332920 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 23/Oct/19 21:50 Start Date: 23/Oct/19 21:50 Worklog Time Spent: 10m Work Description: KevinGG commented on issue #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#issuecomment-545650837 I've added two tox env and corresponding Py36 and Py37 test suite. Removed [interactive] from test required packages. Added it to py2:docs env. I'll add [interactive] for other specific envs defined in tox.ini if any of the gradle task needs it. I've also added checks and warnings in `interactive_environment.InteractiveEnvironment` to check prerequisites for interactive beam (didn't put them in the global scope because global scoped warning level logging will fail gradle tasks in pre-commit): 1. If Python is above 3.5.3; 2. If [interactive] dependencies are fully available; 3. If current runtime is within an interactive environment, i.e., within an ipython kernel. For the `time.sleep()` and `pcoll_visualization` NOOP strategy when dependencies are not fully installed, please let me know your preference, @aaltay. Personally I'm fine with either approaches, and I'll make change if needed. 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: 332920) Time Spent: 13h 50m (was: 13h 40m) > Visualize PCollection with Interactive Beam > --- > > 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: 13h 50m > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=333023&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-333023 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 24/Oct/19 03:19 Start Date: 24/Oct/19 03:19 Worklog Time Spent: 10m Work Description: henryken commented on issue #9771: [BEAM-7926] Update dependencies in Java Katas URL: https://github.com/apache/beam/pull/9771#issuecomment-545724583 LGTM. I had a quick test and nothing breaks. 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: 333023) Time Spent: 14h (was: 13h 50m) > Visualize PCollection with Interactive Beam > --- > > 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: 14h > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=333027&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-333027 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 24/Oct/19 03:24 Start Date: 24/Oct/19 03:24 Worklog Time Spent: 10m Work Description: pabloem commented on issue #9771: [BEAM-7926] Update dependencies in Java Katas URL: https://github.com/apache/beam/pull/9771#issuecomment-545725673 Thanks for the review @henryken and thanks a lot for the PR @leonardoam ! 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: 333027) Time Spent: 14h 20m (was: 14h 10m) > Visualize PCollection with Interactive Beam > --- > > 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: 14h 20m > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=333026&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-333026 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 24/Oct/19 03:24 Start Date: 24/Oct/19 03:24 Worklog Time Spent: 10m Work Description: pabloem commented on pull request #9771: [BEAM-7926] Update dependencies in Java Katas URL: https://github.com/apache/beam/pull/9771 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: 333026) Time Spent: 14h 10m (was: 14h) > Visualize PCollection with Interactive Beam > --- > > 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: 14h 10m > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=333606&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-333606 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 24/Oct/19 17:24 Start Date: 24/Oct/19 17:24 Worklog Time Spent: 10m Work Description: aaltay commented on issue #9771: [BEAM-7926] Update dependencies in Java Katas URL: https://github.com/apache/beam/pull/9771#issuecomment-546019446 Was there a typo in the JIRA (https://issues.apache.org/jira/browse/BEAM-7926) mentioned in the title? JIRA does not appear to be related to this PR. 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: 333606) Time Spent: 14.5h (was: 14h 20m) > Visualize PCollection with Interactive Beam > --- > > 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: 14.5h > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=334317&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-334317 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 25/Oct/19 18:49 Start Date: 25/Oct/19 18:49 Worklog Time Spent: 10m Work Description: aaltay commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r339190776 ## File path: sdks/python/apache_beam/runners/interactive/display/pcoll_visualization_test.py ## @@ -0,0 +1,152 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +#http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +"""Tests for apache_beam.runners.interactive.display.pcoll_visualization.""" +from __future__ import absolute_import + +import sys +import time +import unittest + +import apache_beam as beam # pylint: disable=ungrouped-imports +import timeloop +from apache_beam.runners import runner +from apache_beam.runners.interactive import interactive_environment as ie +from apache_beam.runners.interactive.display import pcoll_visualization as pv + +# Work around nose tests using Python2 without unittest.mock module. +try: + from unittest.mock import patch +except ImportError: + from mock import patch + + +class PCollVisualizationTest(unittest.TestCase): + + def setUp(self): +self._p = beam.Pipeline() +# pylint: disable=range-builtin-not-iterating +self._pcoll = self._p | 'Create' >> beam.Create(range(1000)) + + @unittest.skipIf(sys.version_info < (3, 5, 3), + 'PCollVisualization is not supported on Python 2.') + def test_raise_error_for_non_pcoll_input(self): +class Foo(object): + pass + +with self.assertRaises(AssertionError) as ctx: + pv.PCollVisualization(Foo()) + self.assertTrue('pcoll should be apache_beam.pvalue.PCollection' in + ctx.exception) + + @unittest.skipIf(sys.version_info < (3, 5, 3), + 'PCollVisualization is not supported on Python 2.') + def test_pcoll_visualization_generate_unique_display_id(self): +pv_1 = pv.PCollVisualization(self._pcoll) +pv_2 = pv.PCollVisualization(self._pcoll) +self.assertNotEqual(pv_1._dive_display_id, pv_2._dive_display_id) +self.assertNotEqual(pv_1._overview_display_id, pv_2._overview_display_id) +self.assertNotEqual(pv_1._df_display_id, pv_2._df_display_id) + + @unittest.skipIf(sys.version_info < (3, 5, 3), + 'PCollVisualization is not supported on Python 2.') + @patch('apache_beam.runners.interactive.display.pcoll_visualization' + '.PCollVisualization._to_element_list', lambda x: [1, 2, 3]) + def test_one_shot_visualization_not_return_handle(self): +self.assertIsNone(pv.visualize(self._pcoll)) + + def _mock_to_element_list(self): +yield [1, 2, 3] +yield [1, 2, 3, 4] +yield [1, 2, 3, 4, 5] +yield [1, 2, 3, 4, 5, 6] +yield [1, 2, 3, 4, 5, 6, 7] +yield [1, 2, 3, 4, 5, 6, 7, 8] + + @unittest.skipIf(sys.version_info < (3, 5, 3), + 'PCollVisualization is not supported on Python 2.') + @patch('apache_beam.runners.interactive.display.pcoll_visualization' + '.PCollVisualization._to_element_list', _mock_to_element_list) + def test_dynamic_plotting_return_handle(self): +h = pv.visualize(self._pcoll, dynamic_plotting_interval=1) +self.assertIsInstance(h, timeloop.Timeloop) +h.stop() + + @unittest.skipIf(sys.version_info < (3, 5, 3), + 'PCollVisualization is not supported on Python 2.') + @patch('apache_beam.runners.interactive.display.pcoll_visualization' + '.PCollVisualization._to_element_list', _mock_to_element_list) + @patch('apache_beam.runners.interactive.display.pcoll_visualization' + '.PCollVisualization.display_facets') + def test_dynamic_plotting_update_same_display(self, +mocked_display_facets): +fake_pipeline_result = runner.PipelineResult(runner.PipelineState.RUNNING) +ie.current_env().set_pipeline_result(self._p, fake_pipeline_result) +# Starts async dynamic plotting that neve
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=334319&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-334319 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 25/Oct/19 18:49 Start Date: 25/Oct/19 18:49 Worklog Time Spent: 10m Work Description: aaltay commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r339189834 ## File path: sdks/python/apache_beam/runners/interactive/display/pcoll_visualization.py ## @@ -0,0 +1,279 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +#http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +"""Module visualizes PCollection data. + +For internal use only; no backwards-compatibility guarantees. +Only works with Python 3.5+. +""" +from __future__ import absolute_import + +import base64 +import logging +from datetime import timedelta + +from pandas.io.json import json_normalize + +from apache_beam import pvalue +from apache_beam.runners.interactive import interactive_environment as ie +from apache_beam.runners.interactive import pipeline_instrument as instr + +# jsons doesn't support < Python 3.5. Work around with json for legacy tests. +# TODO(BEAM-8288): clean up once Py2 is deprecated from Beam. +try: + import jsons + _pv_jsons_load = jsons.load + _pv_jsons_dump = jsons.dump +except ImportError: + import json + _pv_jsons_load = json.load + _pv_jsons_dump = json.dump + +try: + from facets_overview.generic_feature_statistics_generator import GenericFeatureStatisticsGenerator + _facets_gfsg_ready = True +except ImportError: + _facets_gfsg_ready = False + +try: + from IPython.core.display import HTML + from IPython.core.display import Javascript + from IPython.core.display import display + from IPython.core.display import display_javascript + from IPython.core.display import update_display + _ipython_ready = True +except ImportError: + _ipython_ready = False + +try: + from timeloop import Timeloop + _tl_ready = True +except ImportError: + _tl_ready = False + +# 1-d types that need additional normalization to be compatible with DataFrame. +_one_dimension_types = (int, float, str, bool, list, tuple) + +_DIVE_SCRIPT_TEMPLATE = """ +document.querySelector("#{display_id}").data = {jsonstr};""" +_DIVE_HTML_TEMPLATE = """ +https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/1.3.3/webcomponents-lite.js";> Review comment: Integration tests sounds good. If not with this PR, I will suggest doing sooner. 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: 334319) Time Spent: 15h (was: 14h 50m) > Visualize PCollection with Interactive Beam > --- > > 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: 15h > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=334315&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-334315 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 25/Oct/19 18:49 Start Date: 25/Oct/19 18:49 Worklog Time Spent: 10m Work Description: aaltay commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r339191310 ## File path: sdks/python/tox.ini ## @@ -189,7 +189,7 @@ commands = time {toxinidir}/scripts/run_pylint.sh [testenv:docs] -extras = test,gcp,docs +extras = test,gcp,docs,interactive Review comment: Does docs need it? 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: 334315) Time Spent: 14h 40m (was: 14.5h) > Visualize PCollection with Interactive Beam > --- > > 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: 14h 40m > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=334314&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-334314 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 25/Oct/19 18:49 Start Date: 25/Oct/19 18:49 Worklog Time Spent: 10m Work Description: aaltay commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r339189616 ## File path: sdks/python/apache_beam/runners/interactive/display/pcoll_visualization.py ## @@ -0,0 +1,279 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +#http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +"""Module visualizes PCollection data. + +For internal use only; no backwards-compatibility guarantees. +Only works with Python 3.5+. +""" +from __future__ import absolute_import + +import base64 +import logging +from datetime import timedelta + +from pandas.io.json import json_normalize + +from apache_beam import pvalue +from apache_beam.runners.interactive import interactive_environment as ie +from apache_beam.runners.interactive import pipeline_instrument as instr + +# jsons doesn't support < Python 3.5. Work around with json for legacy tests. +# TODO(BEAM-8288): clean up once Py2 is deprecated from Beam. +try: + import jsons + _pv_jsons_load = jsons.load + _pv_jsons_dump = jsons.dump +except ImportError: + import json + _pv_jsons_load = json.load + _pv_jsons_dump = json.dump + +try: + from facets_overview.generic_feature_statistics_generator import GenericFeatureStatisticsGenerator + _facets_gfsg_ready = True +except ImportError: + _facets_gfsg_ready = False Review comment: I would suggest first option. Require installation of full [interactive] extra package. 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: 334314) Time Spent: 14h 40m (was: 14.5h) > Visualize PCollection with Interactive Beam > --- > > 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: 14h 40m > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=334318&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-334318 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 25/Oct/19 18:49 Start Date: 25/Oct/19 18:49 Worklog Time Spent: 10m Work Description: aaltay commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r339191742 ## File path: sdks/python/tox.ini ## @@ -208,3 +208,13 @@ commands = coverage report --skip-covered # Generate report in xml format coverage xml + +[testenv:py36-interactive] +extras = test,interactive +commands = + python setup.py nosetests --where 'apache_beam/runners/interactive' {posargs} Review comment: Is it possible that anything else will be broken in interactive environment? 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: 334318) Time Spent: 15h (was: 14h 50m) > Visualize PCollection with Interactive Beam > --- > > 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: 15h > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=334316&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-334316 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 25/Oct/19 18:49 Start Date: 25/Oct/19 18:49 Worklog Time Spent: 10m Work Description: aaltay commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r339191223 ## File path: sdks/python/setup.py ## @@ -166,6 +166,14 @@ def get_version(): 'google-cloud-bigtable>=0.31.1,<1.1.0', ] +INTERACTIVE_BEAM = [ +'facets-overview>=1.0.0,<2', Review comment: Nevermind. This looks good. 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: 334316) > Visualize PCollection with Interactive Beam > --- > > 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: 14h 40m > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=334395&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-334395 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 25/Oct/19 22:20 Start Date: 25/Oct/19 22:20 Worklog Time Spent: 10m Work Description: KevinGG commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r339258088 ## File path: sdks/python/tox.ini ## @@ -208,3 +208,13 @@ commands = coverage report --skip-covered # Generate report in xml format coverage xml + +[testenv:py36-interactive] +extras = test,interactive +commands = + python setup.py nosetests --where 'apache_beam/runners/interactive' {posargs} Review comment: TL;DR: For simplicity, I'll just change to run all tests. It's possible that after setting up a Py36 (or any other) environment with interactive dependencies, some dependencies would conflict or be incompatible. Like the rollback we had, in some test setup (could be totally different from the tox env we have in this repo), some execution path used a newer versioned IPython through transitive dependency causing package usage to fail if there is no try-except for relative import path. To ensure at least all test environments work without conflict in dependencies, we can use the same `commands` used by `testenv:py36-gcp`. It's just now we rerun many tests simply because the result of `pip install ...` might be different. But the test suites are executed in parallel, this just adds more workload to Jenkins without increasing sequenced task elapse, so it should be fine. 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: 334395) Time Spent: 15h 20m (was: 15h 10m) > Visualize PCollection with Interactive Beam > --- > > 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: 15h 20m > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-7926) Visualize PCollection with Interactive Beam
[ https://issues.apache.org/jira/browse/BEAM-7926?focusedWorklogId=334394&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-334394 ] ASF GitHub Bot logged work on BEAM-7926: Author: ASF GitHub Bot Created on: 25/Oct/19 22:20 Start Date: 25/Oct/19 22:20 Worklog Time Spent: 10m Work Description: KevinGG commented on pull request #9741: [BEAM-7926] Visualize PCollection URL: https://github.com/apache/beam/pull/9741#discussion_r339258080 ## File path: sdks/python/tox.ini ## @@ -189,7 +189,7 @@ commands = time {toxinidir}/scripts/run_pylint.sh [testenv:docs] -extras = test,gcp,docs +extras = test,gcp,docs,interactive Review comment: Yes, `docs` needs it because it's generating documentation for all source code. Kind of like a static scan. That's why `test` and `gcp` packages have also been included here. 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: 334394) Time Spent: 15h 10m (was: 15h) > Visualize PCollection with Interactive Beam > --- > > 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: 15h 10m > Remaining Estimate: 0h > > Support auto plotting / charting of materialized data of a given PCollection > with Interactive Beam. > Say an Interactive Beam pipeline defined as > p = create_pipeline() > pcoll = p | 'Transform' >> transform() > The use can call a single function and get auto-magical charting of the data > as materialized pcoll. > e.g., visualize(pcoll) -- This message was sent by Atlassian Jira (v8.3.4#803005)