KServe Python SDK

Python SDK for KServe Server and Client.

Installation

KServe Python SDK can be installed by pip or Setuptools.

pip install

  1. pip install kserve

Setuptools

Install via Setuptools.

  1. python setup.py install --user

(or sudo python setup.py install to install the package for all users)

KServe Python Server

KServe’s python server libraries implement a standardized library that is extended by model serving frameworks such as Scikit Learn, XGBoost and PyTorch. It encapsulates data plane API definitions and storage retrieval for models.

It provides many functionalities, including among others:

  • Registering a model and starting the server
  • Prediction Handler
  • Pre/Post Processing Handler
  • Liveness Handler
  • Readiness Handlers

It supports the following storage providers:

  • Google Cloud Storage with a prefix: “gs://“
    • By default, it uses GOOGLE_APPLICATION_CREDENTIALS environment variable for user authentication.
    • If GOOGLE_APPLICATION_CREDENTIALS is not provided, anonymous client will be used to download the artifacts.
  • S3 Compatible Object Storage with a prefix “s3://“
    • By default, it uses S3_ENDPOINT, AWS_ACCESS_KEY_ID, and AWS_SECRET_ACCESS_KEY environment variables for user authentication.
  • Azure Blob Storage with the format: “https://{$STORAGE\_ACCOUNT\_NAME}.blob.core.windows.net/{$CONTAINER}/{$PATH}
  • Local filesystem either without any prefix or with a prefix “file://“. For example:
    • Absolute path: /absolute/path or file:///absolute/path
    • Relative path: relative/path or file://relative/path
    • For local filesystem, we recommended to use relative path without any prefix.
  • Persistent Volume Claim (PVC) with the format “pvc://{$pvcname}/[path]“.
    • The pvcname is the name of the PVC that contains the model.
    • The [path] is the relative path to the model on the PVC.
    • For e.g. pvc://mypvcname/model/path/on/pvc
  • Generic URI, over either HTTP, prefixed with http:// or HTTPS, prefixed with https://. For example:
    • https://<some_url>.com/model.joblib
    • http://<some_url>.com/model.joblib

KServe Client

Getting Started

KServe’s python client interacts with KServe control plane APIs for executing operations on a remote KServe cluster, such as creating, patching and deleting of a InferenceService instance. See the Sample for Python SDK Client to get started.

Documentation for Client API

ClassMethodDescription
KServeClientset_credentialsSet Credentials
KServeClientcreateCreate InferenceService
KServeClientgetGet or watch the specified InferenceService or all InferenceServices in the namespace
KServeClientpatchPatch the specified InferenceService
KServeClientreplaceReplace the specified InferenceService
KServeClientdeleteDelete the specified InferenceService
KServeClientwait_isvc_readyWait for the InferenceService to be ready
KServeClientis_isvc_readyCheck if the InferenceService is ready

Documentation For Models