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, 'argparse.ArgumentParser', 'argparse.ArgumentParser', False, 'import argparse\n'), (14, 'apache_beam.options.pipeline_options.PipelineOptions', 'PipelineOptions', False, 'from apache_beam.options.pipeline_options import PipelineOptions\n'), (16, 'apache_beam.Pipeline', 'beam.Pipeline', True, 'import apache_beam as beam\n'), (19, 'apache_beam.Create', 'beam.Create', True, 'import apache_beam as beam\n'), (26, 'logging.getLogger', 'logging.getLogger', False, 'import logging\n')]