Create parameterized pipelines¶
This guide will walk you through parameterizing a Kubeflow Pipeline using the Kale SDK.
- An EKF or MiniKF deployment with the default Kale Docker image.
- An understanding of how Kale SDK works.
Create a new Notebook server using the default Kale Docker image. The image will have the following naming scheme:
<IMAGE_TAG>varies based on the MiniKF or EKF release.
Connect to the server, open a terminal, and install
$ pip3 install --user scikit-learn==0.23.0
Create a new python file and name it
$ touch kale_parameters.py
Copy and paste the following code inside
Alternatively, download the
In this code sample, you start with a standard Python script that trains a Logistic Regression model. Moreover, you have decorated the functions using the Kale SDK. To read more about how to create this file, head to the corresponding Kale SDK user guide.
The pipeline resulting from the compilation of the this Python script will have two parameters:
rs: to pass a random seed to the dataset generator, with a default value of
iters: to define the number of iterations for the model, with a default value of
You should always provide default values for the parameters. These defaults will end up in the definition of the uploaded pipeline. You can override them by calling the pipeline function with new argument values, or set different values when creating a Run from the KFP UI. Head to the KFP macros guide to learn how to provide dynamic values as input to your pipelines.
Run the script locally to test whether your code runs successfully using Kale’s marshalling mechanism:
$ python3 -m kale kale_parameters.py
(Optional) Produce a workflow YAML file that you can inspect:
$ python3 -m kale kale_parameters.py --compile
After the successful execution of this command, look for the workflow YAML file inside a
.kaledirectory inside your working directory. This is a file that you could upload and submit to Kubeflow manually through its User Interface (KFP UI).
Deploy and run your code as a KFP pipeline:
$ python3 -m kale kale_parameters.py --kfp
To see the complete list of arguments and their respective usage, run
python3 -m kale --help.