kfp.compiler package

class kfp.compiler.Compiler[source]

Bases: object

DSL Compiler.

It compiles DSL pipeline functions into workflow yaml. Example usage: ```python @dsl.pipeline(

name=’name’, description=’description’

) def my_pipeline(a: dsl.PipelineParam, b: dsl.PipelineParam):

pass

Compiler().compile(my_pipeline, ‘path/to/workflow.yaml’) ```

compile(pipeline_func, package_path, type_check=True)[source]

Compile the given pipeline function into workflow yaml.

Parameters:
  • pipeline_func – pipeline functions with @dsl.pipeline decorator.
  • package_path – the output workflow tar.gz file path. for example, “~/a.tar.gz”
  • type_check – whether to enable the type check or not, default: False.
class kfp.compiler.VersionedDependency(name, version=None, min_version=None, max_version=None)[source]

Bases: object

DependencyVersion specifies the versions

has_max_version()[source]
has_min_version()[source]
has_versions()[source]
max_version
min_version
name
kfp.compiler.build_docker_image(staging_gcs_path, target_image, dockerfile_path, timeout=600, namespace='kubeflow')[source]

build_docker_image automatically builds a container image based on the specification in the dockerfile and pushes to the target_image.

Parameters:
  • staging_gcs_path (str) – GCS blob that can store temporary build files
  • target_image (str) – gcr path to push the final image
  • dockerfile_path (str) – local path to the dockerfile
  • timeout (int) – the timeout for the image build(in secs), default is 600 seconds
  • namespace (str) – the namespace within which to run the kubernetes kaniko job, default is “kubeflow”
kfp.compiler.build_python_component(component_func, target_image, base_image=None, dependency=[], staging_gcs_path=None, build_image=True, timeout=600, namespace='kubeflow', target_component_file=None, python_version='python3')[source]

build_component automatically builds a container image for the component_func based on the base_image and pushes to the target_image.

Parameters:
  • component_func (python function) – The python function to build components upon
  • base_image (str) – Docker image to use as a base image
  • target_image (str) – Full URI to push the target image
  • staging_gcs_path (str) – GCS blob that can store temporary build files
  • target_image – target image path
  • build_image (bool) – whether to build the image or not. Default is True.
  • timeout (int) – the timeout for the image build(in secs), default is 600 seconds
  • namespace (str) – the namespace within which to run the kubernetes kaniko job, default is “kubeflow”
  • dependency (list) – a list of VersionedDependency, which includes the package name and versions, default is empty
  • python_version (str) – choose python2 or python3, default is python3
Raises:

ValueError – The function is not decorated with python_component decorator or the python_version is neither python2 nor python3