Compiler¶
Compile a Kale Pipeline into a Kubeflow Pipelines v2 DSL script.
This module renders the Jinja2 templates in kale/templates/ to produce a
ready-to-run KFP v2 pipeline script, formats it, and optionally hands it off to
the KFP SDK for compilation and submission.
- kale.compiler.to_kale_env_var_name(pvc_name: str) str[source]¶
Derive a KALE_VOLUME_<NAME> env var name from a PVC name.
Non-alphanumeric characters are collapsed to
_. This mapping is lossy for DNS subdomain names (both-and.become_), so callers that expose multiple volumes must ensure the derived names stay unique.
- class kale.compiler.Artifact(name: str, type: str, is_input: bool = False)[source]¶
Bases:
NamedTupleA Step artifact.
- class kale.compiler.Compiler(pipeline: Pipeline, imports_and_functions: str)[source]¶
Bases:
objectConverts a Pipeline object into a KFP executable.
Compiler provides the tools to convert a Pipeline object into an executable script that uses the KFP DSL to create and upload a new pipeline.
The Pipeline object is assumed to provide all the necessary information (environment, configuration, etc…) for the script to be compiled.
- generate_dsl()[source]¶
Generate a Python KFP DSL executable starting from the pipeline.
Returns (str): A Python executable script
- generate_composition(nodes)[source]¶
Generate the DSL for a pipeline that references other notebooks.
Every referenced notebook becomes an importable module of its own, holding its components and a nested pipeline, and this notebook’s DSL imports them and wires them together with its own steps. The modules are written next to it by
_save_compiled_code().