What is the best practice to get arguments from pipeline_options?
Dummy code example:
known_args, pipeline_args = parser.parse_known_args()
pipeline_options = PipelineOptions(pipeline_args)
with beam.Pipeline(options=pipeline_options) as pipeline:
# here I want to use project argument
# I can't do pipeline.options.project
# because warning is displayed
(
pipeline
| "Transformation 1" >> beam.Map(lambda x: known_args.pubsub_sub) # this is fine
| "Transformation 2" >> beam.Map(lambda x: pipeline.options.project) # this is not fine
)
How to use those standard arguments needed by pipeline (project, region etc.), not those user-defined?
I think the best practice is using Options as follow, I kept your intial code :
I think for predifined options like
project, you have to add them in theMyPipelineOptionsclass to use it in your Python code.