Kubeflow SDK library

To help K3ai users to interact with Kubeflow we are introducing the support of Kubeflow SDK library (kfp).

The Kubeflow Pipelines SDK provides a set of Python packages that you can use to specify and run your machine learning (ML) workflows. A pipeline is a description of an ML workflow, including all of the components that make up the steps in the workflow and how the components interact with each other - https://www.kubeflow.org/docs/pipelines/sdk/sdk-overview/****

We offer two different way to consume kfp within k3ai:

  • by a virtual environment on the local computer of the user

  • by one of our Jupyter notebooks directly within k3ai

KFP with VirtualEnv

virtualenv is a tool to create isolated Python environments. Since Python 3.3, a subset of it has been integrated into the standard library under the venv module. -https://virtualenv.pypa.io/en/latest/

Step 1

Please check you have virtualenv installed on your machine. Depending on the OS you are using you may use different approaches. Please follow the official guides to install virtualenv at https://virtualenv.pypa.io/en/latest/installation.html****

Step 2

Run the following command:

curl -sfL https://get.k3ai.in | bash -s -- --cpu --plugin_kfp_sdk

Once the installer has finished please proceed to the "How to use KFP SDK" section.

KFP within K3ai environment

We leverage Jupyter Notebooks to provide a pre-installed kfp environment so that one may immediately experiment with this.

If you are using WSL

If you already deployed the pipelines simply run:

Once the installer has finished please proceed to the "How to use KFP SDK" section.

How to use KFP SDK

We present here a simple example to explain how the KFP SDK may be used. More examples may be found at https://www.kubeflow.org/docs/pipelines/tutorials/sdk-examples/****

Testing KFP SDK from virtualenv

This procedure will require you the K3ai IP address in case you forgot it the simplest way to grab it is execute the following command:

In your terminal create a file called demo.py, use your favorite IDE to copy and paste the below example, and change it accordingly to your K3ai environment.

save the file and execute it with

You should get a result like in the "Checking the results" section.

Testing with Jupyter Notebooks

Open your Jupyter Notebook at the address provided during the plugin installation. If you forgot the ip you may retrieve it this way

Once the Notebook is open click on top right of the notebook to create a new ipython environment

Create a new python notebook in Jupyter

In the first cell paste the following script

Pres CTRL+ENTER to execute the cell.

Checking the results

If everything went well in both virtualenv and jupyter notebooks samples you should have a result similar to this:

Last updated

Was this helpful?