Skip to content

Commit

Permalink
helm: Enhance dataprep to support local embedding and getfile
Browse files Browse the repository at this point in the history
- By setting TEI_EMBEDDING_ENDPOINT to empty and EMBED_MODEL to non-empty, data-prep can support local embedding.

- Support getfile and delete URL

Signed-off-by: Lianhao Lu <[email protected]>
  • Loading branch information
lianhao committed Aug 6, 2024
1 parent 847878a commit 73b5b65
Show file tree
Hide file tree
Showing 8 changed files with 111 additions and 25 deletions.
35 changes: 32 additions & 3 deletions helm-charts/common/data-prep/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,43 @@ Helm chart for deploying data-prep microservice.

data-prep will use redis and tei service, please specify the endpoints.

## Installing the Chart
## (Option1): Installing the chart separately:

To install the chart, run the following:
First, you need to install the tei and redis-vector-db chart, please refer to the [tei](../tei) and [redis-vector-db](../redis-vector-db) for more information.

After you've deployted the tei and redis-vector-db chart successfully, please run `kubectl get svc` to get the service endpoint and URL respectively, i.e. `http://tei`, `redis://redis-vector-db:6379`.

To install data-prep chart, run the following:

```console
cd GenAIInfra/helm-charts/common/data-prep
export REDIS_URL="redis://redis-vector-db:6379"
export TEI_EMBEDDING_ENDPOINT="http://tei"
helm install dataprep data-prep --set REDIS_URL=${REDIS_URL} --set TEI_EMBEDDING_ENDPOINT=${TEI_EMBEDDING_ENDPOINT}
helm dependency update
helm install data-prep . --set REDIS_URL=${REDIS_URL} --set TEI_EMBEDDING_ENDPOINT=${TEI_EMBEDDING_ENDPOINT}
```

## (Option2): Installing the chart with dependencies automatically:

```console
cd GenAIInfra/helm-charts/common/data-prep
helm dependency update
helm install data-prep . --set autodependency.enabled=true
```

## Verify

To verify the installation, run the command `kubectl get pod` to make sure all pods are running.

Then run the command `kubectl port-forward svc/data-prep 6007:6007` to expose the data-prep service for access.

Open another terminal and run the following command to verify the service if working:

```console
curl http://localhost:6007/v1/dataprep \
-X POST \
-H "Content-Type: multipart/form-data" \
-F "files=@./README.md"
```

## Values
Expand Down
16 changes: 0 additions & 16 deletions helm-charts/common/data-prep/templates/NOTES.txt

This file was deleted.

5 changes: 3 additions & 2 deletions helm-charts/common/data-prep/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@ metadata:
data:
{{- if .Values.TEI_EMBEDDING_ENDPOINT }}
TEI_ENDPOINT: {{ .Values.TEI_EMBEDDING_ENDPOINT | quote}}
{{- else }}
{{- else if not .Values.EMBED_MODEL }}
TEI_ENDPOINT: "http://{{ .Release.Name }}-tei"
{{- end }}
EMBED_MODEL: {{ .Values.EMBED_MODEL | quote }}
{{- if .Values.REDIS_URL }}
REDIS_URL: {{ .Values.REDIS_URL | quote}}
{{- else }}
REDIS_URL: "redis://{{ .Release.Name }}-redis-vector-db:6379"
{{- end }}
INDEX_NAME: "rag-redis"
INDEX_NAME: {{ .Values.INDEX_NAME | quote }}
HUGGINGFACEHUB_API_TOKEN: {{ .Values.global.HUGGINGFACEHUB_API_TOKEN | quote}}
HF_HOME: "/tmp/.cache/huggingface"
http_proxy: {{ .Values.global.http_proxy | quote }}
Expand Down
6 changes: 6 additions & 0 deletions helm-charts/common/data-prep/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ spec:
- name: data-prep
containerPort: 6007
protocol: TCP
# The following need to be modified after GenAIComps bug #282 is resolved.
# https://github.com/opea-project/GenAIComps/issues/282
- containerPort: 6008
protocol: TCP
- containerPort: 6009
protocol: TCP
volumeMounts:
- mountPath: /tmp
name: tmp
Expand Down
8 changes: 5 additions & 3 deletions helm-charts/common/data-prep/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ metadata:
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: 6007
{{- range .Values.service.ports }}
- port: {{ .port }}
targetPort: {{ .targetPort }}
protocol: TCP
name: data-prep
name: {{ .name }}
{{- end }}
selector:
{{- include "data-prep.selectorLabels" . | nindent 4 }}
34 changes: 34 additions & 0 deletions helm-charts/common/data-prep/templates/tests/test-pod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

apiVersion: v1
kind: Pod
metadata:
name: {{ include "data-prep.fullname" . }}-testpod
labels:
{{- include "data-prep.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": test
#"helm.sh/hook-delete-policy": "hook-succeeded, hook-failure"
spec:
containers:
- name: curl
#image: alpine/curl
image: python:3.10.14
command: ['bash', '-c']
args:
- |
echo "test file" > /tmp/file1.txt;
{{- with index .Values.service.ports 0 }}
export port={{.port}};
{{- end }}
max_retry=20;
for ((i=1; i<=max_retry; i++)); do
curl http://{{ include "data-prep.fullname" . }}:$port/v1/dataprep -sS --fail-with-body \
-X POST \
-H "Content-Type: multipart/form-data" \
-F "files=@/tmp/file1.txt" && break;
sleep 10;
done;
if [ $i -gt $max_retry ]; then echo "dataprep test failed."; exit 1; fi
restartPolicy: Never
17 changes: 16 additions & 1 deletion helm-charts/common/data-prep/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,19 @@ securityContext:

service:
type: ClusterIP
# The following need to be modified after GenAIComps bug #282 is resolved.
# https://github.com/opea-project/GenAIComps/issues/282
ports:
# The default port for data prep service is 6007
port: 6007
- port: 6007
targetPort: 6007
name: data-prep
- port: 6008
targetPort: 6008
name: data-prep-get
- port: 6009
targetPort: 6009
name: data-prep-delete

resources: {}
# We usually recommend not to specify default resources and to leave this as a conscious
Expand Down Expand Up @@ -83,8 +94,12 @@ affinity: {}
# text embedding inference service URL, e.g. http://<service-name>:<port>
TEI_EMBEDDING_ENDPOINT: ""

# local embedder's model
EMBED_MODEL: ""

# redis DB service URL, e.g. redis://<service-name>:<port>
REDIS_URL: ""
INDEX_NAME: "rag-redis"

global:
http_proxy: ""
Expand Down
15 changes: 15 additions & 0 deletions manifests/common/data-prep.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ metadata:
app.kubernetes.io/managed-by: Helm
data:
TEI_ENDPOINT: "http://data-prep-tei"
EMBED_MODEL: ""
REDIS_URL: "redis://data-prep-redis-vector-db:6379"
INDEX_NAME: "rag-redis"
HUGGINGFACEHUB_API_TOKEN: "insert-your-huggingface-token-here"
Expand Down Expand Up @@ -47,6 +48,14 @@ spec:
targetPort: 6007
protocol: TCP
name: data-prep
- port: 6008
targetPort: 6008
protocol: TCP
name: data-prep-get
- port: 6009
targetPort: 6009
protocol: TCP
name: data-prep-delete
selector:
app.kubernetes.io/name: data-prep
app.kubernetes.io/instance: data-prep
Expand Down Expand Up @@ -103,6 +112,12 @@ spec:
- name: data-prep
containerPort: 6007
protocol: TCP
# The following need to be modified after GenAIComps bug #282 is resolved.
# https://github.com/opea-project/GenAIComps/issues/282
- containerPort: 6008
protocol: TCP
- containerPort: 6009
protocol: TCP
volumeMounts:
- mountPath: /tmp
name: tmp
Expand Down

0 comments on commit 73b5b65

Please sign in to comment.