Skip to content

Commit 7590b05

Browse files
Integrate DBQnA set_env to ut scripts and enhanced validation checks. (#1915)
Integrate DBQnA set_env to ut scripts. Add README.md for ut scripts. Enhanced validation checks Signed-off-by: ZePan110 <ze.pan@intel.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 4efb1e0 commit 7590b05

File tree

6 files changed

+42
-50
lines changed

6 files changed

+42
-50
lines changed

DBQnA/docker_compose/amd/gpu/rocm/set_env.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,13 @@
33
# Copyright (C) 2024 Intel Corporation
44
# SPDX-License-Identifier: Apache-2.0
55

6-
export host_ip=""
7-
export DBQNA_HUGGINGFACEHUB_API_TOKEN=""
6+
pushd "../../" > /dev/null
7+
ls -l
8+
source .set_env.sh
9+
popd > /dev/null
10+
11+
export host_ip=${ip_address}
12+
export DBQNA_HUGGINGFACEHUB_API_TOKEN=${HUGGINGFACEHUB_API_TOKEN}
813
export DBQNA_TGI_SERVICE_PORT=8008
914
export DBQNA_TGI_LLM_ENDPOINT="http://${host_ip}:${DBQNA_TGI_SERVICE_PORT}"
1015
export DBQNA_LLM_MODEL_ID="mistralai/Mistral-7B-Instruct-v0.3"
@@ -14,3 +19,4 @@ export POSTGRES_PASSWORD="testpwd"
1419
export POSTGRES_DB="chinook"
1520
export DBQNA_TEXT_TO_SQL_PORT=9090
1621
export DBQNA_UI_PORT=5174
22+
export build_texttosql_url="${ip_address}:${DBQNA_TEXT_TO_SQL_PORT}/v1"

DBQnA/docker_compose/intel/cpu/xeon/set_env.sh

100644100755
Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,19 @@
22

33
# Copyright (C) 2024 Intel Corporation
44
# SPDX-License-Identifier: Apache-2.0
5+
56
pushd "../../../../../" > /dev/null
67
source .set_env.sh
78
popd > /dev/null
89

9-
#export host_ip=$(hostname -I | awk '{print $1}')
10-
11-
if [ -z "${HUGGINGFACEHUB_API_TOKEN}" ]; then
12-
echo "Error: HUGGINGFACEHUB_API_TOKEN is not set. Please set HUGGINGFACEHUB_API_TOKEN."
13-
fi
14-
15-
if [ -z "${host_ip}" ]; then
16-
echo "Error: host_ip is not set. Please set host_ip first."
17-
fi
10+
export host_ip=${ip_address}
1811
export no_proxy=$no_proxy,$host_ip,dbqna-xeon-react-ui-server,text2sql-service,tgi-service,postgres-container
1912
export HUGGINGFACEHUB_API_TOKEN=${HUGGINGFACEHUB_API_TOKEN}
20-
export TGI_PORT=8008
21-
export TGI_LLM_ENDPOINT="http://${host_ip}:${TGI_PORT}"
22-
export LLM_MODEL_ID="mistralai/Mistral-7B-Instruct-v0.3"
13+
export HF_TOKEN=${HUGGINGFACEHUB_API_TOKEN}
2314
export POSTGRES_USER=postgres
2415
export POSTGRES_PASSWORD=testpwd
2516
export POSTGRES_DB=chinook
17+
export TGI_PORT=8008
2618
export TEXT2SQL_PORT=9090
27-
"set_env.sh" 27L, 974B
19+
export TGI_LLM_ENDPOINT="http://${host_ip}:${TGI_PORT}"
20+
export LLM_MODEL_ID="mistralai/Mistral-7B-Instruct-v0.3"

DBQnA/docker_compose/set_env.sh

Lines changed: 0 additions & 11 deletions
This file was deleted.

DBQnA/tests/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# DBQnA E2E test scripts
2+
3+
## Set the required environment variable
4+
5+
```bash
6+
export HUGGINGFACEHUB_API_TOKEN="Your_Huggingface_API_Token"
7+
```
8+
9+
## Run test
10+
11+
On Intel Xeon with TGI:
12+
13+
```bash
14+
bash test_compose_on_xeon.sh
15+
```
16+
17+
On AMD ROCm with TGI:
18+
19+
```bash
20+
bash test_compose_on_rocm.sh
21+
```

DBQnA/tests/test_compose_on_rocm.sh

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,10 @@ set -xe
77
WORKPATH=$(dirname "$PWD")
88
LOG_PATH="$WORKPATH/tests"
99
ip_address=$(hostname -I | awk '{print $1}')
10-
tgi_port=8008
11-
tgi_volume=$WORKPATH/data
1210

1311
export host_ip=${ip_address}
14-
export DBQNA_HUGGINGFACEHUB_API_TOKEN=${HUGGINGFACEHUB_API_TOKEN}
15-
export DBQNA_TGI_SERVICE_PORT=8008
16-
export DBQNA_TGI_LLM_ENDPOINT="http://${host_ip}:${DBQNA_TGI_SERVICE_PORT}"
17-
export DBQNA_LLM_MODEL_ID="mistralai/Mistral-7B-Instruct-v0.3"
18-
export MODEL_ID=${DBQNA_LLM_MODEL_ID}
19-
export POSTGRES_USER="postgres"
20-
export POSTGRES_PASSWORD="testpwd"
21-
export POSTGRES_DB="chinook"
22-
export DBQNA_TEXT_TO_SQL_PORT=9090
23-
export DBQNA_UI_PORT=5174
24-
export build_texttosql_url="${ip_address}:${DBQNA_TEXT_TO_SQL_PORT}/v1"
12+
source $WORKPATH/docker_compose/amd/gpu/rocm/set_env.sh
13+
2514
export MODEL_CACHE=${model_cache:-"/var/lib/GenAI/data"}
2615

2716
function build_docker_images() {
@@ -57,7 +46,8 @@ function validate_microservice() {
5746
-d '{"input_text": "Find the total number of Albums.","conn_str": {"user": "'${POSTGRES_USER}'","password": "'${POSTGRES_PASSWORD}'","host": "'${ip_address}'", "port": "5442", "database": "'${POSTGRES_DB}'" }}' \
5847
-H 'Content-Type: application/json')
5948

60-
if [[ $result == *"output"* ]]; then
49+
if echo "$result" | jq -e '.result.output' > /dev/null 2>&1; then
50+
# if [[ $result == *"output"* ]]; then
6151
echo $result
6252
echo "Result correct."
6353
else

DBQnA/tests/test_compose_on_xeon.sh

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ export MODEL_CACHE=${model_cache:-"./data"}
1515
WORKPATH=$(dirname "$PWD")
1616
LOG_PATH="$WORKPATH/tests"
1717
ip_address=$(hostname -I | awk '{print $1}')
18-
tgi_port=8008
1918

2019
function build_docker_images() {
2120
cd $WORKPATH/docker_image_build
@@ -30,14 +29,7 @@ function build_docker_images() {
3029

3130
function start_service() {
3231
cd $WORKPATH/docker_compose/intel/cpu/xeon
33-
export model="mistralai/Mistral-7B-Instruct-v0.3"
34-
export LLM_MODEL_ID=${model}
35-
export HUGGINGFACEHUB_API_TOKEN=${HUGGINGFACEHUB_API_TOKEN}
36-
export POSTGRES_USER=postgres
37-
export POSTGRES_PASSWORD=testpwd
38-
export POSTGRES_DB=chinook
39-
export TEXT2SQL_PORT=9090
40-
export TGI_LLM_ENDPOINT="http://${ip_address}:${tgi_port}"
32+
source ./set_env.sh
4133

4234
# Start Docker Containers
4335
docker compose -f compose.yaml up -d > ${LOG_PATH}/start_services_with_compose.log
@@ -60,7 +52,8 @@ function validate_microservice() {
6052
-d '{"input_text": "Find the total number of Albums.","conn_str": {"user": "'${POSTGRES_USER}'","password": "'${POSTGRES_PASSWORD}'","host": "'${ip_address}'", "port": "5442", "database": "'${POSTGRES_DB}'" }}' \
6153
-H 'Content-Type: application/json')
6254

63-
if [[ $result == *"output"* ]]; then
55+
if echo "$result" | jq -e '.result.output' > /dev/null 2>&1; then
56+
# if [[ $result == *"output"* ]]; then
6457
echo $result
6558
echo "Result correct."
6659
else

0 commit comments

Comments
 (0)