Jupyter Notebook operator for Kubeflow Pipelines
Project description
KFP-Notebook is an operator that enable running notebooks as part of a Kubeflow Pipeline.
Building kfp-notebook
make clean install
Usage
The example below can easily be added to a python script
or jupyter notebook
for testing purposes.
import os
import kfp
from notebook.pipeline import NotebookOp
from kubernetes.client.models import V1EnvVar
# KubeFlow Pipelines API Endpoint
kfp_url = 'http://dataplatform.ibm.com:32488/pipeline'
# S3 Object Storage
cos_endpoint = 'http://s3.us-south.cloud-object-storage.appdomain.cloud'
cos_bucket = 'test-bucket'
cos_username = 'test'
cos_password = 'test123'
cos_directory = 'test-directory'
cos_pull_archive = 'test-archive.tar.gz'
# Inputs and Outputs
inputs = []
outputs = []
# Container Image
image = 'tensorflow/tensorflow:latest'
def run_notebook_op(op_name, notebook_path):
notebook_op = NotebookOp(name=op_name,
notebook=notebook_path,
cos_endpoint=cos_endpoint,
cos_bucket=cos_bucket,
cos_directory=cos_directory,
cos_pull_archive=cos_pull_archive,
pipeline_outputs=outputs,
pipeline_inputs=inputs,
image=image)
notebook_op.container.add_env_variable(V1EnvVar(name='AWS_ACCESS_KEY_ID', value=cos_username))
notebook_op.container.add_env_variable(V1EnvVar(name='AWS_SECRET_ACCESS_KEY', value=cos_password))
notebook_op.container.set_image_pull_policy('Always')
return op
def demo_pipeline():
stats_op = run_notebook_op('stats', 'generate-community-overview')
contributions_op = run_notebook_op('contributions', 'generate-community-contributions')
run_notebook_op('overview', 'overview').after(stats_op, contributions_op)
# Compile the new pipeline
kfp.compiler.Compiler().compile(demo_pipeline,'pipelines/pipeline.tar.gz')
# Upload the compiled pipeline
client = kfp.Client(host=kfp_url)
pipeline_info = client.upload_pipeline('pipelines/pipeline.tar.gz',pipeline_name='pipeline-demo')
# Create a new experiment
experiment = client.create_experiment(name='demo-experiment')
# Create a new run associated with experiment and our uploaded pipeline
run = client.run_pipeline(experiment.id, 'demo-run', pipeline_id=pipeline_info.id)
Generated Kubeflow Pipelines
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
kfp-notebook-0.13.0.tar.gz
(10.1 kB
view details)
Built Distribution
File details
Details for the file kfp-notebook-0.13.0.tar.gz
.
File metadata
- Download URL: kfp-notebook-0.13.0.tar.gz
- Upload date:
- Size: 10.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0.post20200714 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 094b027dbf183c6e05e328c9f299930723abe0221acdded92d7a14ad709a1dbf |
|
MD5 | ab1f00ae75d3957980f269f58cd85de1 |
|
BLAKE2b-256 | 45e4c14422723d9175e9f59ac23923474392849c7ac94b0867864d7524075dbf |
File details
Details for the file kfp_notebook-0.13.0-py3-none-any.whl
.
File metadata
- Download URL: kfp_notebook-0.13.0-py3-none-any.whl
- Upload date:
- Size: 11.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0.post20200714 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1f98652bd9bef779e5cbcbac3b6200a93189ac4a7ef736b78f3f1539dd0f69c8 |
|
MD5 | cb641814fd9a4e7f92ff3597f8aa7cc3 |
|
BLAKE2b-256 | 39638a52465a8fb8fc0364a2a035481d7b3d0bb02bab43d79c9ad44358650e2f |