Skip to content

Commit

Permalink
Logger (kubeflow#467)
Browse files Browse the repository at this point in the history
* Request Logging in Control Plane

* change executor to logger in release scripts

* change executor into logger

* initial inference logger commit

* initial Q version of inference logger

* Add initial cloudevents code

* add cloudevents and opencensus vendor additions

* update cloudevents and create example

* add log_type and sample

* Add logging to transformers and explainers

* Add validation tests

* Allow default log url to be knative default broker

* Bring inference logger annotations into single method

* add model_url and update examples

* refactor to logger

* Update logger Dockerfile

* Fix compile errors after rebase

* Logger files, and test

* Remove sample and add modelId

* Updates from review

* Updates from review

* Updates from testing

* Update from review comments

* update workflow to replace executor with logger

* regenerate tf2openapi

* Updates from review

* review updates

* Updates from review
  • Loading branch information
ukclivecox authored and k8s-ci-robot committed Nov 18, 2019
1 parent a5f1eff commit cfd3905
Show file tree
Hide file tree
Showing 41 changed files with 1,190 additions and 68 deletions.
8 changes: 8 additions & 0 deletions config/default/configmap/inferenceservice.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,11 @@ data:
"ingressGateway" : "knative-ingress-gateway.knative-serving",
"ingressService" : "istio-ingressgateway.istio-system.svc.cluster.local"
}
logger: |-
{
"image" : "gcr.io/kfserving/logger:0.2.1",
"memoryRequest": "100Mi",
"memoryLimit": "1Gi",
"cpuRequest": "100m",
"cpuLimit": "1"
}
52 changes: 20 additions & 32 deletions config/default/crds/serving_v1alpha2_inferenceservice.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ spec:
type: object
runtimeVersion:
description: Allowed runtime versions are [v0.5.0, latest]
and defaults to the version specified in inferenceservice
and defaults to the version specified in the inferenceservice
config map
type: string
storageUri:
Expand All @@ -167,9 +167,8 @@ spec:
MEM.
type: object
runtimeVersion:
description: Allowed runtime versions are [0.2.0, latest]
and defaults to the version specified in inferenceservice
config map
description: Allowed runtime versions are specified in the
inferenceservice config map
type: string
storageUri:
description: The location of the trained model
Expand All @@ -189,9 +188,8 @@ spec:
MEM.
type: object
runtimeVersion:
description: Allowed runtime versions are [0.2.0, latest]
and defaults to the version specified in inferenceservice
config map
description: Allowed runtime versions are specified in the
inferenceservice config map
type: string
storageUri:
description: The location of the trained model
Expand All @@ -207,11 +205,8 @@ spec:
MEM.
type: object
runtimeVersion:
description: Allowed runtime versions are [1.11.0, 1.12.0,
1.13.0, 1.14.0, latest] or [1.11.0-gpu, 1.12.0-gpu, 1.13.0-gpu,
1.14.0-gpu, latest-gpu] if gpu resource is specified and
defaults to the version specified in inferenceservice
config map.
description: Allowed runtime versions are specified in the
inferenceservice config map.
type: string
storageUri:
description: The location of the trained model
Expand All @@ -228,7 +223,7 @@ spec:
type: object
runtimeVersion:
description: Allowed runtime versions are [19.05-py3] and
defaults to the version specified in inferenceservice
defaults to the version specified in the inferenceservice
config map
type: string
storageUri:
Expand All @@ -245,9 +240,8 @@ spec:
MEM.
type: object
runtimeVersion:
description: Allowed runtime versions are [0.2.0, latest]
and defaults to the version specified in inferenceservice
config map
description: Allowed runtime versions are specified in the
inferenceservice config map
type: string
storageUri:
description: The location of the trained model
Expand Down Expand Up @@ -401,7 +395,7 @@ spec:
type: object
runtimeVersion:
description: Allowed runtime versions are [v0.5.0, latest]
and defaults to the version specified in inferenceservice
and defaults to the version specified in the inferenceservice
config map
type: string
storageUri:
Expand All @@ -421,9 +415,8 @@ spec:
MEM.
type: object
runtimeVersion:
description: Allowed runtime versions are [0.2.0, latest]
and defaults to the version specified in inferenceservice
config map
description: Allowed runtime versions are specified in the
inferenceservice config map
type: string
storageUri:
description: The location of the trained model
Expand All @@ -443,9 +436,8 @@ spec:
MEM.
type: object
runtimeVersion:
description: Allowed runtime versions are [0.2.0, latest]
and defaults to the version specified in inferenceservice
config map
description: Allowed runtime versions are specified in the
inferenceservice config map
type: string
storageUri:
description: The location of the trained model
Expand All @@ -461,11 +453,8 @@ spec:
MEM.
type: object
runtimeVersion:
description: Allowed runtime versions are [1.11.0, 1.12.0,
1.13.0, 1.14.0, latest] or [1.11.0-gpu, 1.12.0-gpu, 1.13.0-gpu,
1.14.0-gpu, latest-gpu] if gpu resource is specified and
defaults to the version specified in inferenceservice
config map.
description: Allowed runtime versions are specified in the
inferenceservice config map.
type: string
storageUri:
description: The location of the trained model
Expand All @@ -482,7 +471,7 @@ spec:
type: object
runtimeVersion:
description: Allowed runtime versions are [19.05-py3] and
defaults to the version specified in inferenceservice
defaults to the version specified in the inferenceservice
config map
type: string
storageUri:
Expand All @@ -499,9 +488,8 @@ spec:
MEM.
type: object
runtimeVersion:
description: Allowed runtime versions are [0.2.0, latest]
and defaults to the version specified in inferenceservice
config map
description: Allowed runtime versions are specified in the
inferenceservice config map
type: string
storageUri:
description: The location of the trained model
Expand Down
135 changes: 135 additions & 0 deletions docs/samples/logger/basic/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
# Inference Logger Demo

First let us create a message dumper KNative service which will print out the Cloud Events it receives.
We will use the following resource yaml:

```
apiVersion: serving.knative.dev/v1alpha1
kind: Service
metadata:
name: message-dumper
spec:
template:
spec:
containers:
- image: gcr.io/knative-releases/github.com/knative/eventing-sources/cmd/event_display
```

Let's apply the resource to the cluster:

```
kubectl create -f message-dumper.yaml
```

We can now create a sklearn predictor with a logger which points at the message dumper. The yaml is shown below.

```
apiVersion: "serving.kubeflow.org/v1alpha2"
kind: "InferenceService"
metadata:
name: "sklearn-iris"
spec:
default:
predictor:
minReplicas: 1
logger:
url: http://message-dumper.default/
mode: all
sklearn:
storageUri: "gs://kfserving-samples/models/sklearn/iris"
```

Let's apply this yaml:

```
kubectl create -f sklearn-logging.yaml
```

We can now send a request to the sklearn model:

```
MODEL_NAME=sklearn-iris
INPUT_PATH=@./iris-input.json
CLUSTER_IP=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
SERVICE_HOSTNAME=$(kubectl get inferenceservice sklearn-iris -o jsonpath='{.status.url}' | cut -d "/" -f 3)
curl -v -H "Host: ${SERVICE_HOSTNAME}" http://$CLUSTER_IP/v1/models/$MODEL_NAME:predict -d $INPUT_PATH -H "Content-Type: application/json"
```

Expected Output

```
* Trying 169.63.251.68...
* TCP_NODELAY set
* Connected to 169.63.251.68 (169.63.251.68) port 80 (#0)
> POST /models/sklearn-iris:predict HTTP/1.1
> Host: sklearn-iris.default.svc.cluster.local
> User-Agent: curl/7.60.0
> Accept: */*
> Content-Length: 76
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 76 out of 76 bytes
< HTTP/1.1 200 OK
< content-length: 23
< content-type: application/json; charset=UTF-8
< date: Mon, 20 May 2019 20:49:02 GMT
< server: istio-envoy
< x-envoy-upstream-service-time: 1943
<
* Connection #0 to host 169.63.251.68 left intact
{"predictions": [1, 1]}
```

If we now check the logs of the message dumper:

```
kubectl logs $(kubectl get pod -l serving.knative.dev/service=message-dumper -o jsonpath='{.items[0].metadata.name}') user-container
```

Expected output:

```
☁️ cloudevents.Event
Validation: valid
Context Attributes,
cloudEventsVersion: 0.1
eventType: org.kubeflow.serving.inference.request
source: http://localhost:8080/
eventID: 462af46b-d582-4f3a-9f2a-6851d4143e3d
eventTime: 2019-10-21T12:12:49.82518115Z
contentType: application/json
Data,
{
"instances": [
[
6.8,
2.8,
4.8,
1.4
],
[
6.0,
3.4,
4.5,
1.6
]
]
}
☁️ cloudevents.Event
Validation: valid
Context Attributes,
cloudEventsVersion: 0.1
eventType: org.kubeflow.serving.inference.response
source: http://localhost:8080/
eventID: 462af46b-d582-4f3a-9f2a-6851d4143e3d
eventTime: 2019-10-21T12:12:49.83269988Z
contentType: application/json; charset=UTF-8
Data,
{
"predictions": [
1,
1
]
}
```
6 changes: 6 additions & 0 deletions docs/samples/logger/basic/iris-input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"instances": [
[6.8, 2.8, 4.8, 1.4],
[6.0, 3.4, 4.5, 1.6]
]
}
Loading

0 comments on commit cfd3905

Please sign in to comment.