Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:Kubeflow Pipelines Compiler Compile

From Leeroopedia
Sources Domains Last Updated
Kubeflow Pipelines, KFP SDK ML_Pipelines, Compilation 2026-02-13

Overview

Concrete tool for compiling pipeline definitions to IR YAML provided by the KFP compiler module.

Description

kfp.compiler.Compiler().compile() takes a @dsl.pipeline-decorated function and produces a YAML file containing the KFP IR spec. The output is a portable artifact.

Usage

Call after defining a pipeline function, typically in if __name__ == '__main__': blocks.

Code Reference

Source Location: Repository: kubeflow/pipelines, File: samples/core/sequential/sequential.py (L49-50)

Signature:

class Compiler:
    def compile(
        self,
        pipeline_func: Callable,
        package_path: str,
        type_check: bool = True,
    ) -> None:
        """Compiles pipeline function to IR YAML."""

Import:

from kfp import compiler
# or
from kfp.compiler import Compiler

I/O Contract

Inputs:

Parameter Type Required Description
pipeline_func Callable Yes @dsl.pipeline-decorated function
package_path str Yes Output YAML file path
type_check bool No Enable type checking (default True)

Outputs:

  • None -- writes YAML file to package_path

Usage Examples

Example 1 -- Basic compilation:

from kfp import compiler

compiler.Compiler().compile(sequential_pipeline, __file__ + '.yaml')

Example 2 -- Compilation with explicit path:

from kfp.compiler import Compiler

Compiler().compile(
    pipeline_func=pipeline_exit_handler,
    package_path=__file__ + '.yaml'
)

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment