Metadata-Version: 2.1
Name: kserve
Version: 0.11.0
Summary: KServe Python SDK
Home-page: https://github.com/kserve/kserve/tree/master/python/kserve
License: Apache-2.0
Author: The KServe Authors
Author-email: dsun20@bloomberg.net
Requires-Python: >=3.8,<3.12
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Education
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Provides-Extra: logging
Provides-Extra: storage
Requires-Dist: asgi-logger (>=0.1.0,<0.2.0) ; (python_full_version > "3.8.0" and python_version < "3.11") and (extra == "logging")
Requires-Dist: azure-identity (>=1.8.0,<2.0.0) ; extra == "storage"
Requires-Dist: azure-storage-blob (>=12.10.0,<13.0.0) ; extra == "storage"
Requires-Dist: azure-storage-file-share (>=12.7.0,<13.0.0) ; extra == "storage"
Requires-Dist: boto3 (>=1.21.0,<2.0.0) ; extra == "storage"
Requires-Dist: cloudevents (>=1.6.2,<2.0.0)
Requires-Dist: fastapi (>=0.95.0,<0.96.0)
Requires-Dist: google-cloud-storage (>=1.20.0,<2.0.0) ; extra == "storage"
Requires-Dist: grpcio (>=1.49.1,<2.0.0)
Requires-Dist: httpx (>=0.23.0,<0.24.0)
Requires-Dist: kubernetes (>=23.3.0)
Requires-Dist: numpy (>=1.23.5,<2.0.0)
Requires-Dist: orjson (>=3.8.0,<4.0.0)
Requires-Dist: pandas (>=1.3.5)
Requires-Dist: prometheus-client (>=0.13.1,<0.14.0)
Requires-Dist: protobuf (>=3.19.0,<4.0.0)
Requires-Dist: psutil (>=5.9.0,<6.0.0)
Requires-Dist: python-dateutil (>=2.8.0,<3.0.0)
Requires-Dist: ray[serve] (>=2.4.0,<2.5.0)
Requires-Dist: requests (>=2.20.0,<3.0.0) ; extra == "storage"
Requires-Dist: six (>=1.16.0,<2.0.0)
Requires-Dist: tabulate (>=0.9.0,<0.10.0)
Requires-Dist: timing-asgi (>=0.3.0,<0.4.0)
Requires-Dist: tritonclient (>=2.18.0,<3.0.0)
Requires-Dist: urllib3 (>=1.26.8,<2.0.0) ; extra == "storage"
Requires-Dist: uvicorn[standard] (>=0.19.0,<0.20.0)
Project-URL: Repository, https://github.com/kserve/kserve/tree/master/python/kserve
Description-Content-Type: text/markdown

# KServe Python SDK
Python SDK for KServe Server and Client.

## Installation

KServe Python SDK can be installed by `pip` or `poetry`.

### pip install

```sh
pip install kserve
```

To install Kserve with storage support
```sh
pip install kserve[storage]
```

### Poetry

Install via [Poetry](https://python-poetry.org/).

```sh
make dev_install
```
To install Kserve with storage support
```sh
poetry install -E storage
```
or 
```sh
poetry install --extras "storage"
```

## 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}"
    * By default, it uses anonymous client to download the artifacts.
    * For e.g. https://kfserving.blob.core.windows.net/triton/simple_string/
* 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`

### Metrics

For latency metrics, send a request to `/metrics`. Prometheus latency histograms are emitted for each of the steps (pre/postprocessing, explain, predict).
Additionally, the latencies of each step are logged per request.

| Metric Name                       | Description                    | Type      |
|-----------------------------------|--------------------------------|-----------| 
| request_preprocess_seconds        | pre-processing request latency | Histogram | 
| request_explain_seconds | explain request latency        | Histogram | 
| request_predict_seconds | prediction request latency     | Histogram |
| request_postprocess_seconds    | pre-processing request latency | Histogram | 


## 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](../../docs/samples/client) to get started.

### Documentation for Client API

Please review [KServe Client API](https://github.com/kserve/website/blob/main/docs/sdk_docs/docs/KServeClient.md) docs.

## Documentation For Models

 - [KnativeAddressable](docs/KnativeAddressable.md)
 - [KnativeCondition](docs/KnativeCondition.md)
 - [KnativeURL](docs/KnativeURL.md)
 - [KnativeVolatileTime](docs/KnativeVolatileTime.md)
 - [NetUrlUserinfo](docs/NetUrlUserinfo.md)
 - [V1alpha1InferenceGraph](docs/V1alpha1InferenceGraph.md)
 - [V1alpha1InferenceGraphList](docs/V1alpha1InferenceGraphList.md)
 - [V1alpha1InferenceGraphSpec](docs/V1alpha1InferenceGraphSpec.md)
 - [V1alpha1InferenceGraphStatus](docs/V1alpha1InferenceGraphStatus.md)
 - [V1alpha1InferenceRouter](docs/V1alpha1InferenceRouter.md)
 - [V1alpha1InferenceStep](docs/V1alpha1InferenceStep.md)
 - [V1alpha1InferenceTarget](docs/V1alpha1InferenceTarget.md)
 - [V1beta1AlibiExplainerSpec](docs/V1beta1AlibiExplainerSpec.md)
 - [V1beta1Batcher](docs/V1beta1Batcher.md)
 - [V1beta1ComponentExtensionSpec](docs/V1beta1ComponentExtensionSpec.md)
 - [V1beta1ComponentStatusSpec](docs/V1beta1ComponentStatusSpec.md)
 - [V1beta1CustomExplainer](docs/V1beta1CustomExplainer.md)
 - [V1beta1CustomPredictor](docs/V1beta1CustomPredictor.md)
 - [V1beta1CustomTransformer](docs/V1beta1CustomTransformer.md)
 - [V1beta1ExplainerConfig](docs/V1beta1ExplainerConfig.md)
 - [V1beta1ExplainerSpec](docs/V1beta1ExplainerSpec.md)
 - [V1beta1ExplainersConfig](docs/V1beta1ExplainersConfig.md)
 - [V1beta1InferenceService](docs/V1beta1InferenceService.md)
 - [V1beta1InferenceServiceList](docs/V1beta1InferenceServiceList.md)
 - [V1beta1InferenceServiceSpec](docs/V1beta1InferenceServiceSpec.md)
 - [V1beta1InferenceServiceStatus](docs/V1beta1InferenceServiceStatus.md)
 - [V1beta1InferenceServicesConfig](docs/V1beta1InferenceServicesConfig.md)
 - [V1beta1IngressConfig](docs/V1beta1IngressConfig.md)
 - [V1beta1LoggerSpec](docs/V1beta1LoggerSpec.md)
 - [V1beta1ModelSpec](docs/V1beta1ModelSpec.md)
 - [V1beta1ONNXRuntimeSpec](docs/V1beta1ONNXRuntimeSpec.md)
 - [V1beta1PodSpec](docs/V1beta1PodSpec.md)
 - [V1beta1PredictorConfig](docs/V1beta1PredictorConfig.md)
 - [V1beta1PredictorExtensionSpec](docs/V1beta1PredictorExtensionSpec.md)
 - [V1beta1PredictorSpec](docs/V1beta1PredictorSpec.md)
 - [V1beta1PredictorsConfig](docs/V1beta1PredictorsConfig.md)
 - [V1beta1SKLearnSpec](docs/V1beta1SKLearnSpec.md)
 - [V1beta1TFServingSpec](docs/V1beta1TFServingSpec.md)
 - [V1beta1TorchServeSpec](docs/V1beta1TorchServeSpec.md)
 - [V1beta1TrainedModel](docs/V1beta1TrainedModel.md)
 - [V1beta1TrainedModelList](docs/V1beta1TrainedModelList.md)
 - [V1beta1TrainedModelSpec](docs/V1beta1TrainedModelSpec.md)
 - [V1beta1TrainedModelStatus](docs/V1beta1TrainedModelStatus.md)
 - [V1beta1TransformerConfig](docs/V1beta1TransformerConfig.md)
 - [V1beta1TransformerSpec](docs/V1beta1TransformerSpec.md)
 - [V1beta1TransformersConfig](docs/V1beta1TransformersConfig.md)
 - [V1beta1TritonSpec](docs/V1beta1TritonSpec.md)
 - [V1beta1XGBoostSpec](docs/V1beta1XGBoostSpec.md)

