Skip to main content

Convert JupyterNotebooks to Kubeflow Pipelines deployments

Project description

Kale Logo

GitHub License PyPI Version npm Version Kale CI Workflow Status


[!NOTE]

Project Status Update 🚀

After several years of inactivity, we’re excited to announce that Kale development has restarted! 🎉 Kale was widely appreciated by the community back in the day, and our current goal is to re-establish a solid baseline by updating all components to the latest versions and ensuring full compatibility with the most recent Kubeflow releases.

See all details in the Road to 2.0 issue

KALE (Kubeflow Automated pipeLines Engine) is a project that aims at simplifying the Data Science experience of deploying Kubeflow Pipelines workflows.

Kubeflow is a great platform for orchestrating complex workflows on top of Kubernetes, and Kubeflow Pipelines provide the means to create reusable components that can be executed as part of workflows. The self-service nature of Kubeflow makes it extremely appealing for Data Science use, at it provides an easy access to advanced distributed jobs orchestration, re-usability of components, Jupyter Notebooks, rich UIs and more. Still, developing and maintaining Kubeflow workflows can be hard for data scientists, who may not be experts in working orchestration platforms and related SDKs. Additionally, data science often involve processes of data exploration, iterative modelling and interactive environments (mostly Jupyter notebook).

Kale bridges this gap by providing a simple UI to define Kubeflow Pipelines workflows directly from your JupyterLab interface, without the need to change a single line of code.

See the Kale v2.0 Demo video at the bottom of the README for more details.

Read more about Kale and how it works in this Medium post: Automating Jupyter Notebook Deployments to Kubeflow Pipelines with Kale

Getting started

Requirements

  • Python 3.11+
  • Kubeflow Pipelines v2.16.0+
    • The securityContext field in the Kubernetes executor config is not recognized by older KFP servers (kfp[kubernetes] < 2.16.0), causing pipeline submission to fail.
    • Install KFP as recommended in the official Kubeflow Pipelines Installation documentation (make sure to set PIPELINE_VERSION=2.16.0 or later)
    • If you are upgrading from an earlier version, make sure you have kfp[kubernetes]>=2.16.0 in your dependencies along with kfp>=2.0.0
  • A Kubernetes cluster (minikube, kind, or any K8s cluster)

Installation

[!IMPORTANT] Kale v2.0 is not yet released on PyPI. Until then, install from source:

git clone https://github.com/kubeflow-kale/kale.git
cd kale
make dev      # Set up development environment
make jupyter  # Start JupyterLab

See CONTRIBUTING.md for detailed setup instructions.

Once v2.0 is released, you'll be able to install from PyPI:

pip install "jupyterlab>=4.0.0" kubeflow-kale[jupyter]
jupyter lab

Verify installation

  1. Start your Kubernetes cluster and KFP:

    minikube start
    kubectl port-forward -n kubeflow svc/ml-pipeline-ui 8080:80
    
  2. Test the CLI:

    kale --nb examples/base/candies_sharing.ipynb --kfp_host http://127.0.0.1:8080 --run_pipeline
    

    This generates a pipeline in .kale/ and submits it to KFP.

  3. Test the JupyterLab extension:

    • Open JupyterLab (make jupyter or jupyter lab)
    • Open a notebook from examples/base/
    • Click the Kale icon in the left panel
    • Enable the Kale panel with the toggle
Kale JupyterLab Extension

Docker (Local Testing)

You can test Kale in a Kubeflow-like notebook environment using Docker. The image is based on the official Kubeflow notebook image (jupyter-scipy) with Kale pre-installed.

make docker-build   # Build wheels + Docker image
make docker-run     # Start JupyterLab on http://localhost:8889

To connect to a KFP cluster, run these in separate terminals:

# Terminal 1: Serve the dev wheel (so compiled pipelines can install Kale)
make kfp-serve

# Terminal 2: Port-forward the KFP API
kubectl port-forward -n kubeflow svc/ml-pipeline 8080:8888

# Terminal 3: Start the container
make docker-run

make docker-run automatically configures:

  • KFP API via host.docker.internal (works on macOS, Windows, and Linux)
  • KFP UI links pointing to localhost:8080 (so pipeline links open in your browser)
  • Wheel server connectivity for compiled pipelines

Cell Types

Kale uses special cell types (tags) to organize your notebook into pipeline components. You can assign these types to cells using the Kale JupyterLab extension or by adding tags directly in the notebook metadata.

Cell Types Reference

Cell Type Status Description
Imports ✅ Works The code in this cell will be pre-pended to every step of the pipeline. Used for all import statements. All imports must be placed in cells tagged as imports. Importing libraries (pandas, tensorflow, etc.) in other cell types will cause pipeline execution errors.
Functions ✅ Works The code in this cell will be pre-pended to every step of the pipeline, after imports. Used for function and class definitions only. Do not include top-level executable statements
Pipeline Parameters ✅ Works Define variables that will become pipeline parameters. If more than one Pipeline Parameters cell exists, and a parameter is defined in each cell, only the final value will be taken.
Pipeline Metrics ✅ Works Print scalar metrics and transform it into pipeline metrics.
Step ✅ Works Regular pipeline steps with custom names. This is the default cell type for your data processing and ML logic. Each step can have dependencies on other steps. Steps can also define their own image and GPU requirements.
Skip Cell ✅ Works Cells marked as skip will be excluded from the pipeline. Useful for exploratory code or debugging that shouldn't be part of the production pipeline.

Important Guidelines

[!WARNING] Imports outside Imports cells won't be detected for automatic dependency installation, which causes ImportError at runtime if the package isn't pre-installed in the container image.

Best Practices:

  • Place all imports at the beginning of your notebook in cells tagged as Imports
  • Keep function definitions pure - no side effects (modifying global variables or mutable parameters), prints, or imports
  • Use pipeline-parameters for values you might want to tune between runs
  • Use skip cells for exploratory analysis that shouldn't be in the pipeline

Example

Check out the example notebooks at examples/ to see cell types in action.

FAQ

Head over to FAQ to read about some known issues and some of the limitations imposed by the Kale data marshalling model.

Resources

Contribute

make dev      # Set up development environment
make test     # Run all tests
make jupyter  # Start JupyterLab

See CONTRIBUTING.md for detailed development instructions, including:

  • Available make commands
  • Testing with KFP clusters
  • Building release artifacts
  • Live reload setup

Kale v2.0 Demo

Watch the KubeFlow Kale Demo - Introduction video below.

Demo

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kubeflow_kale-2.0.0a5.tar.gz (11.5 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kubeflow_kale-2.0.0a5-py3-none-any.whl (346.7 kB view details)

Uploaded Python 3

File details

Details for the file kubeflow_kale-2.0.0a5.tar.gz.

File metadata

  • Download URL: kubeflow_kale-2.0.0a5.tar.gz
  • Upload date:
  • Size: 11.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for kubeflow_kale-2.0.0a5.tar.gz
Algorithm Hash digest
SHA256 2c2a4b23282fb16a24584db1a468b7eb9ca9c641089edf71a1f019bce25a6631
MD5 e75bc50b1489f14c2e1ea99dbaf2f999
BLAKE2b-256 8d5486942f79c1779771e9fb73f2d84c3bb1f7ad5b59b950a7f8767e7beaac09

See more details on using hashes here.

File details

Details for the file kubeflow_kale-2.0.0a5-py3-none-any.whl.

File metadata

File hashes

Hashes for kubeflow_kale-2.0.0a5-py3-none-any.whl
Algorithm Hash digest
SHA256 8ab61022614218ead39a8dd40f694aa50eb12c2073a732fedb5015eba9d93051
MD5 ec11f9cb1b265daa39b27704129272a6
BLAKE2b-256 a85baec751c6d13673f00e60b25d2835d3b04c05e47b03578b370eaeb90d8bc9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page