Export a pipeline to an Kubeflow YAML file
Convert and save a Link pipeline from Python code to an Kubeflow YAML file.
This is possible after all components of the pipeline have been successfully executed.
pipeline.convert_to_kfp(file="str")
- Parameters
file
(str): The path and name of the Kubeflowyaml
file you wish to convert and save
- Troubleshooting
- RuntimeError: Please try again after running the pipeline successfully
- This occurs when conversion to YAML encounters a problem during pipeline execution.
- NameError: It must not be blank
- This occurs when the file name is blank.
- NameError: It must not include [: * " ? < > |]
- This occurs when
: * " ? < > |
is included infile
.
- This occurs when
- NameError: The file name must end with .yaml or .yml
- This occurs when the name of
file
does not end with.yaml
or.yml
.
- This occurs when the name of
- RuntimeError: Please try again after running the pipeline successfully
Example
from mrx_link.sdk.utils import *
# Code cell
code1 = """
x = 1
"""
code2 = """
print(f"{x=}, {y=}")
"""
if __name__ == "__main__":
# Create components
component1 = create_link_component(identifier="111-1", name="test", code=code1)
component2 = create_link_component(identifier="111-2", name="test2", code=code2)
components = [component1, component2]
# Create edges
edge1 = create_link_edge(parent_id="111-1", child_id="111-2")
edges = [edge1]
# Create pipeline parameters
parameter1 = create_link_parameter(name="x", value="123")
parameter2 = create_link_parameter(name="y", value="baregasdv")
parameters = [parameter1, parameter2]
# Create pipeline
pipeline = create_link_pipeline(components=components, parameters=parameters, edges=edges)
# Run the pipeline
pipeline.execute_all()
# Convert the pipeline to `sample.yaml` file
pipeline.convert_to_kfp(file="sample.yaml")