def run(self, request, context): job_id = uuid.uuid4().get_hex() pipeline_result = Pipeline.from_runner_api(request.pipeline, 'DirectRunner', PipelineOptions()).run() self.jobs[job_id] = pipeline_result return beam_job_api_pb2.SubmitJobResponse(jobId=job_id)
def run(self, request, context): job_id = uuid.uuid4().get_hex() pipeline_result = Pipeline.from_runner_api( request.pipeline, 'DirectRunner', PipelineOptions()).run() self.jobs[job_id] = pipeline_result return beam_job_api_pb2.SubmitJobResponse(jobId=job_id)
def test_simple(self): """Tests serializing, deserializing, and running a simple pipeline. More extensive tests are done at pipeline.run for each suitable test. """ p = beam.Pipeline() p | beam.Create([None]) | beam.Map(lambda x: x) # pylint: disable=expression-not-assigned proto = p.to_runner_api() p2 = Pipeline.from_runner_api(proto, p.runner, p.options) p2.run()
def test_simple(self): """Tests serializing, deserializing, and running a simple pipeline. More extensive tests are done at pipeline.run for each suitable test. """ p = beam.Pipeline() p | beam.Create([None]) | beam.Map(lambda x: x) # pylint: disable=expression-not-assigned proto = p.to_runner_api() p2 = Pipeline.from_runner_api(proto, p.runner, p._options) p2.run()
def test_parent_pointer(self): class MyPTransform(beam.PTransform): def expand(self, p): self.p = p return p | beam.Create([None]) p = beam.Pipeline() p | MyPTransform() # pylint: disable=expression-not-assigned p = Pipeline.from_runner_api(Pipeline.to_runner_api(p), None, None) self.assertIsNotNone(p.transforms_stack[0].parts[0].parent) self.assertEquals(p.transforms_stack[0].parts[0].parent, p.transforms_stack[0])