kfp.compiler

The kfp.compiler module contains the compiler for compiling pipeline definitions.

class kfp.compiler.Compiler[source]

Bases: object

Compiles pipelines composed using the KFP SDK DSL to a YAML pipeline definition.

The pipeline definition is PipelineSpec IR, the protobuf message that defines a pipeline.

Example

@dsl.pipeline(
  name='name',
)
def my_pipeline(a: int, b: str = 'default value'):
    ...

kfp.compiler.Compiler().compile(
    pipeline_func=my_pipeline,
    package_path='path/to/pipeline.yaml',
    pipeline_parameters={'a': 1},
)
compile(pipeline_func: Union[Callable[[...], Any], BaseComponent], package_path: str, pipeline_name: Optional[str] = None, pipeline_parameters: Optional[Dict[str, Any]] = None, type_check: bool = True) None[source]

Compiles the pipeline or component function into IR YAML.

Parameters
  • pipeline_func – Pipeline function constructed with the @dsl.pipeline or component constructed with the @dsl.component decorator.

  • package_path – Output YAML file path. For example, '~/my_pipeline.yaml' or '~/my_component.yaml'.

  • pipeline_name – Name of the pipeline.

  • pipeline_parameters – Map of parameter names to argument values.

  • type_check – Whether to enable type checking of component interfaces during compilation.