my_app/app.py (15 lines of code) (raw):

# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or # https://www.apache.org/licenses/LICENSE-2.0> or the MIT license # <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your # option. This file may not be copied, modified, or distributed # except according to those terms. from typing import Callable, Optional import apache_beam as beam from apache_beam.options.pipeline_options import PipelineOptions def run( input_text: str, beam_options: Optional[PipelineOptions] = None, test: Callable[[beam.PCollection], None] = lambda _: None, ) -> None: with beam.Pipeline(options=beam_options) as pipeline: elements = ( pipeline | "Create elements" >> beam.Create(["Hello", "World!", input_text]) | "Print elements" >> beam.Map(print) ) # Used for testing only. test(elements)