Skip to content

Commit

Permalink
KServe deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
truskovskiyk committed Sep 12, 2024
1 parent eba2cab commit 1db9af7
Show file tree
Hide file tree
Showing 11 changed files with 85 additions and 97 deletions.
1 change: 1 addition & 0 deletions module-5/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.lock-file
seldon-core
28 changes: 27 additions & 1 deletion module-5/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,38 @@ make run_pytriton

# KServe

Install
Install KServe

```
curl -s "https://raw.githubusercontent.com/kserve/kserve/release-0.13/hack/quick_install.sh" | bash
```

Deploy custom model

```
kubectl create -f ./k8s/kserve-inferenceserver.yaml
```

Call API

```
kubectl get inferenceservices custom-model
kubectl get svc --namespace istio-system
kubectl port-forward --namespace istio-system svc/istio-ingressgateway 8080:80
curl -v -H "Host: custom-model.default.example.com" -H "Content-Type: application/json" "http://localhost:8080/v1/models/custom-model:predict" -d @data-samples/iris-input.json
```


# Seldon V2

```
git clone https://github.com/SeldonIO/seldon-core --branch=v2
```



## IRIS

```
Expand Down
6 changes: 0 additions & 6 deletions module-5/data-samples/iris-input.json

This file was deleted.

37 changes: 37 additions & 0 deletions module-5/k8s/app-triton.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: app-triton
spec:
replicas: 2
selector:
matchLabels:
app: app-triton
template:
metadata:
labels:
app: app-triton
spec:
containers:
- name: app-triton
image: ghcr.io/kyryl-opens-ml/app-triton:latest
env:
- name: WANDB_API_KEY
valueFrom:
secretKeyRef:
name: wandb
key: WANDB_API_KEY
---
apiVersion: v1
kind: Service
metadata:
name: app-triton
labels:
app: app-triton
spec:
ports:
- port: 8080
protocol: TCP
selector:
app: app-triton
17 changes: 0 additions & 17 deletions module-5/k8s/kind.yaml

This file was deleted.

9 changes: 0 additions & 9 deletions module-5/k8s/kserve-custom.yaml

This file was deleted.

15 changes: 15 additions & 0 deletions module-5/k8s/kserve-inferenceserver.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: serving.kserve.io/v1beta1
kind: InferenceService
metadata:
name: custom-model
spec:
predictor:
containers:
- name: kserve-container
image: ghcr.io/kyryl-opens-ml/app-kserve:latest
env:
- name: WANDB_API_KEY
valueFrom:
secretKeyRef:
name: wandb
key: WANDB_API_KEY
11 changes: 0 additions & 11 deletions module-5/k8s/kserve-iris.yaml

This file was deleted.

37 changes: 0 additions & 37 deletions module-5/k8s/seldon-custom.yaml

This file was deleted.

14 changes: 0 additions & 14 deletions module-5/k8s/seldon-iris.yaml

This file was deleted.

7 changes: 5 additions & 2 deletions module-5/serving/kserve_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ def load(self):
self.ready = True

def predict(self, payload: Dict, headers: Dict[str, str] = None) -> Dict:
json_payload = json.loads(payload.decode("utf-8"))
instances = json_payload["instances"]
print(payload)
print(type(payload))
# json_payload = json.loads(payload.decode("utf-8"))
# instances = json_payload["instances"]
instances = payload["instances"]
predictions = self.predictor.predict(instances)
return {"predictions": predictions.tolist()}

Expand Down

0 comments on commit 1db9af7

Please sign in to comment.