Skip to content

Commit

Permalink
refactor searchqna ci test (#437)
Browse files Browse the repository at this point in the history
Signed-off-by: chensuyue <[email protected]>
  • Loading branch information
chensuyue authored Jul 23, 2024
1 parent b7975e7 commit ecf3338
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 48 deletions.
12 changes: 6 additions & 6 deletions SearchQnA/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,22 +63,22 @@ bash ./docker/set_env.sh

## Deploy SearchQnA on Gaudi

If your version of `Habana Driver` < 1.16.0 (check with `hl-smi`), run the following command directly to start SearchQnA services. Please find corresponding [docker_compose.yaml](./docker/gaudi/docker_compose.yaml).
If your version of `Habana Driver` < 1.16.0 (check with `hl-smi`), run the following command directly to start SearchQnA services. Please find corresponding [compose.yaml](./docker/gaudi/compose.yaml).

```bash
cd GenAIExamples/SearchQnA/docker/gaudi/
docker compose -f docker_compose.yaml up -d
docker compose up -d
```

If your version of `Habana Driver` >= 1.16.0, refer to the [Gaudi Guide](./docker/gaudi/README.md) to build docker images from source.

## Deploy SearchQnA on Xeon

Please find corresponding [docker_compose.yaml](./docker/xeon/docker_compose.yaml).
Please find corresponding [compose.yaml](./docker/xeon/compose.yaml).

```bash
cd GenAIExamples/SearchQnA/docker/xeon/
docker compose -f docker_compose.yaml up -d
docker compose up -d
```

Refer to the [Xeon Guide](./docker/xeon/README.md) for more instructions on building docker images from source.
Expand Down Expand Up @@ -116,6 +116,6 @@ curl http://${host_ip}:3001/embed \
-H 'Content-Type: application/json'
```

2. (Docker only) If all microservices work well, please check the port ${host_ip}:3008, the port may be allocated by other users, you can modify the `docker_compose.yaml`.
2. (Docker only) If all microservices work well, please check the port ${host_ip}:3008, the port may be allocated by other users, you can modify the `compose.yaml`.

3. (Docker only) If you get errors like "The container name is in use", please change container name in `docker_compose.yaml`.
3. (Docker only) If you get errors like "The container name is in use", please change container name in `compose.yaml`.
2 changes: 1 addition & 1 deletion SearchQnA/docker/gaudi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export LLM_SERVICE_PORT=3007

```bash
cd GenAIExamples/SearchQnA/docker/gaudi/
docker compose -f docker_compose.yaml up -d
docker compose up -d
```

## 🚀 Test MicroServices
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion SearchQnA/docker/xeon/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export LLM_SERVICE_PORT=3007

```bash
cd GenAIExamples/SearchQnA/docker/xeon/
docker compose -f docker_compose.yaml up -d
docker compose up -d
```

## 🚀 Test MicroServices
Expand Down
File renamed without changes.
48 changes: 26 additions & 22 deletions SearchQnA/tests/test_searchqna_on_gaudi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ function build_docker_images() {
docker build --no-cache -t opea/reranking-tei:latest -f comps/reranks/tei/docker/Dockerfile .
docker build --no-cache -t opea/llm-tgi:latest -f comps/llms/text-generation/tgi/Dockerfile .

cd ..
git clone https://github.com/huggingface/tei-gaudi
cd tei-gaudi/
docker build --no-cache -f Dockerfile-hpu -t opea/tei-gaudi:latest .
# cd ..
# git clone https://github.com/huggingface/tei-gaudi
# cd tei-gaudi/
# docker build --no-cache -f Dockerfile-hpu -t opea/tei-gaudi:latest .

docker pull ghcr.io/huggingface/text-embeddings-inference:cpu-1.2
docker pull ghcr.io/huggingface/tgi-gaudi:2.0.1
Expand All @@ -37,6 +37,12 @@ function build_docker_images() {
}

function start_services() {
# build tei-gaudi for each test instead of pull from local registry
cd $WORKPATH
git clone https://github.com/huggingface/tei-gaudi
cd tei-gaudi/
docker build --no-cache -f Dockerfile-hpu -t opea/tei-gaudi:latest .

cd $WORKPATH/docker/gaudi
export GOOGLE_CSE_ID=$GOOGLE_CSE_ID
export GOOGLE_API_KEY=$GOOGLE_API_KEY
Expand All @@ -63,17 +69,23 @@ function start_services() {

# sed -i "s/backend_address/$ip_address/g" $WORKPATH/docker/ui/svelte/.env

# Replace the container name with a test-specific name
# echo "using image repository $IMAGE_REPO and image tag $IMAGE_TAG"
# sed -i "s#image: opea/chatqna:latest#image: opea/chatqna:${IMAGE_TAG}#g" docker_compose.yaml
# sed -i "s#image: opea/chatqna-ui:latest#image: opea/chatqna-ui:${IMAGE_TAG}#g" docker_compose.yaml
# sed -i "s#image: opea/*#image: ${IMAGE_REPO}opea/#g" docker_compose.yaml
if [[ "$IMAGE_REPO" != "" ]]; then
# Replace the container name with a test-specific name
echo "using image repository $IMAGE_REPO and image tag $IMAGE_TAG"
sed -i "s#image: opea/searchqna:latest#image: opea/searchqna:${IMAGE_TAG}#g" compose.yaml
sed -i "s#image: opea/searchqna-ui:latest#image: opea/searchqna-ui:${IMAGE_TAG}#g" compose.yaml
sed -i "s#image: opea/*#image: ${IMAGE_REPO}opea/#g" compose.yaml
sed -i "s#image: ${IMAGE_REPO}opea/tei-gaudi:latest#image: opea/tei-gaudi:latest#g" compose.yaml
echo "cat compose.yaml"
cat compose.yaml
fi

# Start Docker Containers
docker compose -f docker_compose.yaml up -d
docker compose up -d
n=0
until [[ "$n" -ge 500 ]]; do
docker logs tgi-gaudi-server > tgi_service_start.log
if grep -q Connected tgi_service_start.log; then
docker logs tgi-gaudi-server > $LOG_PATH/tgi_service_start.log
if grep -q Connected $LOG_PATH/tgi_service_start.log; then
break
fi
sleep 1s
Expand Down Expand Up @@ -126,22 +138,14 @@ function validate_megaservice() {

function stop_docker() {
cd $WORKPATH/docker/gaudi
container_list=$(cat docker_compose.yaml | grep container_name | cut -d':' -f2)
for container_name in $container_list; do
cid=$(docker ps -aq --filter "name=$container_name")
if [[ ! -z "$cid" ]]; then docker stop $cid && docker rm $cid && sleep 1s; fi
done
docker compose down
}

function main() {

stop_docker
build_docker_images
# begin_time=$(date +%s)
if [[ "$IMAGE_REPO" == "" ]]; then build_docker_images; fi
start_services
# end_time=$(date +%s)
# maximal_duration=$((end_time-begin_time))
# echo "Mega service start duration is "$maximal_duration"s" && sleep 1s

validate_megaservice
# validate_frontend
Expand Down
33 changes: 15 additions & 18 deletions SearchQnA/tests/test_searchqna_on_xeon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,22 @@ function start_services() {

# sed -i "s/backend_address/$ip_address/g" $WORKPATH/docker/ui/svelte/.env

# Replace the container name with a test-specific name
# echo "using image repository $IMAGE_REPO and image tag $IMAGE_TAG"
# sed -i "s#image: opea/chatqna:latest#image: opea/chatqna:${IMAGE_TAG}#g" docker_compose.yaml
# sed -i "s#image: opea/chatqna-ui:latest#image: opea/chatqna-ui:${IMAGE_TAG}#g" docker_compose.yaml
# sed -i "s#image: opea/*#image: ${IMAGE_REPO}opea/#g" docker_compose.yaml
if [[ "$IMAGE_REPO" != "" ]]; then
# Replace the container name with a test-specific name
echo "using image repository $IMAGE_REPO and image tag $IMAGE_TAG"
sed -i "s#image: opea/searchqna:latest#image: opea/searchqna:${IMAGE_TAG}#g" compose.yaml
sed -i "s#image: opea/searchqna-ui:latest#image: opea/searchqna-ui:${IMAGE_TAG}#g" compose.yaml
sed -i "s#image: opea/*#image: ${IMAGE_REPO}opea/#g" compose.yaml
echo "cat compose.yaml"
cat compose.yaml
fi

# Start Docker Containers
docker compose -f docker_compose.yaml up -d
docker compose up -d
n=0
until [[ "$n" -ge 200 ]]; do
docker logs tgi-service > tgi_service_start.log
if grep -q Connected tgi_service_start.log; then
docker logs tgi-service > $LOG_PATH/tgi_service_start.log
if grep -q Connected $LOG_PATH/tgi_service_start.log; then
break
fi
sleep 1s
Expand Down Expand Up @@ -116,22 +121,14 @@ function validate_megaservice() {

function stop_docker() {
cd $WORKPATH/docker/xeon
container_list=$(cat docker_compose.yaml | grep container_name | cut -d':' -f2)
for container_name in $container_list; do
cid=$(docker ps -aq --filter "name=$container_name")
if [[ ! -z "$cid" ]]; then docker stop $cid && docker rm $cid && sleep 1s; fi
done
docker compose down
}

function main() {

stop_docker
build_docker_images
# begin_time=$(date +%s)
if [[ "$IMAGE_REPO" == "" ]]; then build_docker_images; fi
start_services
# end_time=$(date +%s)
# maximal_duration=$((end_time-begin_time))
# echo "Mega service start duration is "$maximal_duration"s" && sleep 1s

validate_megaservice
# validate_frontend
Expand Down

0 comments on commit ecf3338

Please sign in to comment.