import argparse
import logging

import apache_beam as beam
from apache_beam.options.pipeline_options import PipelineOptions
from apache_beam.options.pipeline_options import SetupOptions


def run(argv=None, save_main_session=True):
  """Dummy pipeline to test Python3 operator."""
  parser = argparse.ArgumentParser()
  known_args, pipeline_args = parser.parse_known_args(argv)

  pipeline_options = PipelineOptions(pipeline_args)
  pipeline_options.view_as(SetupOptions).save_main_session = save_main_session
  p = beam.Pipeline(options=pipeline_options)

  # Just a simple test
  p | 'Create Events' >> beam.Create([1, 2, 3])

  result = p.run()
  result.wait_until_finish()


if __name__ == '__main__':
  logging.getLogger().setLevel(logging.INFO)
  run()

[((11, 11, 11, 36), 'argparse.ArgumentParser', 'argparse.ArgumentParser', ({}, {}), '()', False, 'import argparse\n'), ((14, 21, 14, 51), 'apache_beam.options.pipeline_options.PipelineOptions', 'PipelineOptions', ({(14, 37, 14, 50): 'pipeline_args'}, {}), '(pipeline_args)', False, 'from apache_beam.options.pipeline_options import PipelineOptions\n'), ((16, 6, 16, 45), 'apache_beam.Pipeline', 'beam.Pipeline', (), '', True, 'import apache_beam as beam\n'), ((19, 25, 19, 47), 'apache_beam.Create', 'beam.Create', ({(19, 37, 19, 46): '[1, 2, 3]'}, {}), '([1, 2, 3])', True, 'import apache_beam as beam\n'), ((26, 2, 26, 21), 'logging.getLogger', 'logging.getLogger', ({}, {}), '()', False, 'import logging\n')]