How to get PipelineOptions in composite PTransform in Beam 2.0?

After upgrading to Beam 2.0, a class Pipelineno longer has a class getOptions(). I have a compound PTransformthat relies on getting options in its method expand:

public class MyCompositeTransform extends PTransform<PBegin, PDone> {
    @Override
    public PDone expand(PBegin input) {
        Pipeline pipeline = input.getPipeline();
        MyPipelineOptions options = pipeline.getOptions().as(MyPipelineOptions.class);
        ...
    }
}

In Beam 2.0, there is no way to access the method at PipelineOptionsall expand.

Which alternative?

+4
source share
1 answer

Pablo's answer is right. I also want to clarify that there is a significant change in management PipelineOptions.

main ( , ), PipelineOptions, , .

Beam Pipeline , PipelineRunner PipelineOptions . .

, PTransform ( ) - , , PTransform , , ValueProvider

+1

Source: https://habr.com/ru/post/1681145/


All Articles