kfp.compiler

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

Classes:

Compiler()

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

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},
)

Methods:

compile(pipeline_func, package_path[, ...])

Compiles the pipeline or component function into IR YAML.

compile(pipeline_func: BaseComponent, package_path: str, pipeline_name: str | None = None, pipeline_parameters: dict[str, Any] | None = None, type_check: bool = True) None[source]

Compiles the pipeline or component function into IR YAML.

Parameters
pipeline_func: BaseComponent

Pipeline function constructed with the @dsl.pipeline or component constructed with the @dsl.component decorator.

package_path: str

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

pipeline_name: str | None = None

Name of the pipeline.

pipeline_parameters: dict[str, Any] | None = None

Map of parameter names to argument values.

type_check: bool = True

Whether to enable type checking of component interfaces during compilation.