Skip to content

Commit 50addde

Browse files
committed
add manifests
1 parent 266cfcb commit 50addde

File tree

2 files changed

+152
-0
lines changed

2 files changed

+152
-0
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#!/bin/bash
2+
# Copyright (C) 2024 Intel Corporation
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
set -xe
6+
USER_ID=$(whoami)
7+
LOG_PATH=/home/$(whoami)/logs
8+
MOUNT_DIR=/home/$USER_ID/.cache/huggingface/hub
9+
IMAGE_REPO=${IMAGE_REPO:-opea}
10+
IMAGE_TAG=${IMAGE_TAG:-latest}
11+
12+
function init_audioqna() {
13+
# executed under path manifest/audioqna/xeon
14+
# replace the mount dir "path: /mnt/model" with "path: $CHART_MOUNT"
15+
find . -name '*.yaml' -type f -exec sed -i "s#path: /mnt/opea-models#path: $MOUNT_DIR#g" {} \;
16+
# replace microservice image tag
17+
find . -name '*.yaml' -type f -exec sed -i "s#image: \"opea/\(.*\):latest#image: \"opea/\1:${IMAGE_TAG}#g" {} \;
18+
# replace the repository "image: opea/*" with "image: $IMAGE_REPO/"
19+
find . -name '*.yaml' -type f -exec sed -i "s#image: \"opea/*#image: \"${IMAGE_REPO}/#g" {} \;
20+
# set huggingface token
21+
find . -name '*.yaml' -type f -exec sed -i "s#insert-your-huggingface-token-here#$(cat /home/$USER_ID/.cache/huggingface/token)#g" {} \;
22+
}
23+
24+
function install_audioqna {
25+
echo "namespace is $NAMESPACE"
26+
kubectl apply -f audioqna.yaml -n $NAMESPACE
27+
}
28+
29+
function validate_audioqna() {
30+
ip_address=$(kubectl get svc $SERVICE_NAME -n $NAMESPACE -o jsonpath='{.spec.clusterIP}')
31+
port=$(kubectl get svc $SERVICE_NAME -n $NAMESPACE -o jsonpath='{.spec.ports[0].port}')
32+
echo "try to curl http://${ip_address}:${port}/v1/audioqna..."
33+
34+
# generate a random logfile name to avoid conflict among multiple runners
35+
LOGFILE=$LOG_PATH/curlmega_$NAMESPACE.log
36+
# Curl the Mega Service
37+
curl http://${ip_address}:${port}/v1/audioqna \
38+
-X POST \
39+
-d '{"audio": "UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA", "max_tokens":64, "voice":"default"}' \
40+
-H 'Content-Type: application/json' | sed 's/^"//;s/"$//' | base64 -d > output.wav
41+
42+
if [[ $(file speech.mp3) == *"RIFF"* ]]; then
43+
echo "Result correct."
44+
else
45+
echo "Result wrong."
46+
return 1
47+
fi
48+
return 0
49+
}
50+
51+
if [ $# -eq 0 ]; then
52+
echo "Usage: $0 <function_name>"
53+
exit 1
54+
fi
55+
56+
case "$1" in
57+
init_AudioQnA)
58+
pushd AudioQnA/kubernetes/intel/hpu/gaudi/manifest
59+
init_audioqna
60+
popd
61+
;;
62+
install_AudioQnA)
63+
pushd AudioQnA/kubernetes/intel/hpu/gaudi/manifest
64+
NAMESPACE=$2
65+
install_audioqna
66+
popd
67+
;;
68+
validate_AudioQnA)
69+
NAMESPACE=$2
70+
SERVICE_NAME=audioqna
71+
validate_audioqna
72+
;;
73+
*)
74+
echo "Unknown function: $1"
75+
;;
76+
esac
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#!/bin/bash
2+
# Copyright (C) 2024 Intel Corporation
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
set -xe
6+
USER_ID=$(whoami)
7+
LOG_PATH=/home/$(whoami)/logs
8+
MOUNT_DIR=/home/$USER_ID/.cache/huggingface/hub
9+
IMAGE_REPO=${IMAGE_REPO:-opea}
10+
IMAGE_TAG=${IMAGE_TAG:-latest}
11+
12+
function init_audioqna() {
13+
# executed under path manifest/audioqna/xeon
14+
# replace the mount dir "path: /mnt/model" with "path: $CHART_MOUNT"
15+
find . -name '*.yaml' -type f -exec sed -i "s#path: /mnt/opea-models#path: $MOUNT_DIR#g" {} \;
16+
# replace microservice image tag
17+
find . -name '*.yaml' -type f -exec sed -i "s#image: \"opea/\(.*\):latest#image: \"opea/\1:${IMAGE_TAG}#g" {} \;
18+
# replace the repository "image: opea/*" with "image: $IMAGE_REPO/opea/"
19+
find . -name '*.yaml' -type f -exec sed -i "s#image: \"opea/*#image: \"${IMAGE_REPO}/#g" {} \;
20+
# set huggingface token
21+
find . -name '*.yaml' -type f -exec sed -i "s#insert-your-huggingface-token-here#$(cat /home/$USER_ID/.cache/huggingface/token)#g" {} \;
22+
}
23+
24+
function install_audioqna {
25+
echo "namespace is $NAMESPACE"
26+
kubectl apply -f audioqna.yaml -n $NAMESPACE
27+
}
28+
29+
function validate_audioqna() {
30+
ip_address=$(kubectl get svc $SERVICE_NAME -n $NAMESPACE -o jsonpath='{.spec.clusterIP}')
31+
port=$(kubectl get svc $SERVICE_NAME -n $NAMESPACE -o jsonpath='{.spec.ports[0].port}')
32+
echo "try to curl http://${ip_address}:${port}/v1/audioqna..."
33+
34+
# generate a random logfile name to avoid conflict among multiple runners
35+
LOGFILE=$LOG_PATH/curlmega_$NAMESPACE.log
36+
# Curl the Mega Service
37+
curl http://${ip_address}:${port}/v1/audioqna \
38+
-X POST \
39+
-d '{"audio": "UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA", "max_tokens":64, "voice":"default"}' \
40+
-H 'Content-Type: application/json' | sed 's/^"//;s/"$//' | base64 -d > speech.mp3
41+
42+
if [[ $(file speech.mp3) == *"RIFF"* ]]; then
43+
echo "Result correct."
44+
else
45+
echo "Result wrong."
46+
return 1
47+
fi
48+
return 0
49+
}
50+
51+
if [ $# -eq 0 ]; then
52+
echo "Usage: $0 <function_name>"
53+
exit 1
54+
fi
55+
56+
case "$1" in
57+
init_AudioQnA)
58+
pushd AudioQnA/kubernetes/intel/cpu/xeon/manifest
59+
init_audioqna
60+
popd
61+
;;
62+
install_AudioQnA)
63+
pushd AudioQnA/kubernetes/intel/cpu/xeon/manifest
64+
NAMESPACE=$2
65+
install_audioqna
66+
popd
67+
;;
68+
validate_AudioQnA)
69+
NAMESPACE=$2
70+
SERVICE_NAME=audioqna
71+
validate_audioqna
72+
;;
73+
*)
74+
echo "Unknown function: $1"
75+
;;
76+
esac

0 commit comments

Comments
 (0)