예제 #1
0
 def run(self, transform, options=None):
   """Run the given transform or callable with this runner.
   """
   # Imported here to avoid circular dependencies.
   # pylint: disable=wrong-import-order, wrong-import-position
   from apache_beam import PTransform
   from apache_beam.pvalue import PBegin
   from apache_beam.pipeline import Pipeline
   p = Pipeline(runner=self, options=options)
   if isinstance(transform, PTransform):
     p | transform
   else:
     transform(PBegin(p))
   return p.run()
예제 #2
0
    def run_async(self, transform, options=None):
        """Run the given transform or callable with this runner.

    May return immediately, executing the pipeline in the background.
    The returned result object can be queried for progress, and
    `wait_until_finish` may be called to block until completion.
    """
        # Imported here to avoid circular dependencies.
        # pylint: disable=wrong-import-order, wrong-import-position
        from apache_beam import PTransform
        from apache_beam.pvalue import PBegin
        from apache_beam.pipeline import Pipeline
        p = Pipeline(runner=self, options=options)
        if isinstance(transform, PTransform):
            p | transform
        else:
            transform(PBegin(p))
        return p.run()