Uploaded image for project: 'Beam'
  1. Beam
  2. BEAM-7760

Interactive Beam Caching PCollections bound to user defined vars in notebook

    XMLWordPrintableJSON

    Details

    • Type: New Feature
    • Status: Resolved
    • Priority: P2
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.18.0
    • Component/s: runner-py-interactive
    • Labels:
      None

      Description

      Cache only PCollections bound to user defined variables in a pipeline when running pipeline with interactive runner in jupyter notebooks.

      [Interactive Beam|https://github.com/apache/beam/tree/master/sdks/python/apache_beam/runners/interactive] has been caching and using caches of "leaf" PCollections for interactive execution in jupyter notebooks.

      The interactive execution is currently supported so that when appending new transforms to existing pipeline for a new run, executed part of the pipeline doesn't need to be re-executed. 

      A PCollection is "leaf" when it is never used as input in any PTransform in the pipeline.

      The problem with building caches and pipeline to execute around "leaf" is that when a PCollection is consumed by a sink with no output, the pipeline to execute built will miss the subgraph generating and consuming that PCollection.

      An example, "ReadFromPubSub --> WirteToPubSub" will result in an empty pipeline.

      Caching around PCollections bound to user defined variables and replacing transforms with source and sink of caches could resolve the pipeline to execute properly under the interactive execution scenario. Also, cached PCollection now can trace back to user code and can be used for user data visualization if user wants to do it.

      E.g.,

      // ...
      p = beam.Pipeline(interactive_runner.InteractiveRunner(),
                        options=pipeline_options)
      messages = p | "Read" >> beam.io.ReadFromPubSub(subscription='...')
      messages | "Write" >> beam.io.WriteToPubSub(topic_path)
      result = p.run()
      // ...
      visualize(messages)

       The interactive runner automatically figures out that PCollection

      messages

      created by

      p | "Read" >> beam.io.ReadFromPubSub(subscription='...')

      should be cached and reused if the notebook user appends more transforms.
      And once the pipeline gets executed, the user could use any visualize(PCollection) module to visualize the data statically (batch) or dynamically (stream)

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                ningk Ning Kang
                Reporter:
                ningk Ning Kang
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 18h
                  18h