Skip to content

Commit

Permalink
support multiple test cases for ChatQnA (opea-project#553)
Browse files Browse the repository at this point in the history
Signed-off-by: chensuyue <[email protected]>
  • Loading branch information
chensuyue authored Aug 11, 2024
1 parent a072441 commit 939502d
Show file tree
Hide file tree
Showing 15 changed files with 153 additions and 99 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/_image-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ jobs:
image_repo: ${{ steps.build-megaservice-image.outputs.image_repo }}
image_tag: ${{ steps.build-megaservice-image.outputs.image_tag }}
steps:
- name: Clean up Working Directory
run: |
sudo rm -rf ${{github.workspace}}/* || true
- name: Get checkout ref
run: |
if [ "${{ github.event_name }}" == "pull_request" ] || [ "${{ github.event_name }}" == "pull_request_target" ]; then
Expand Down Expand Up @@ -62,3 +66,4 @@ jobs:
fi
echo "IMAGE_TAG=${IMAGE_TAG}"
echo "image_tag=$IMAGE_TAG" >> $GITHUB_OUTPUT
echo "image_repo=${IMAGE_REPO}" >> $GITHUB_OUTPUT
111 changes: 111 additions & 0 deletions .github/workflows/_run-docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

name: Image Build
permissions: read-all
on:
workflow_call:
inputs:
registry:
description: Container Registry URL
required: false
default: ""
type: string
tag:
description: Container Tag
required: false
default: "latest"
type: string
example:
description: Example to test
required: true
type: string
hardware:
description: Hardware to run the test on
required: true
type: string
jobs:
get-test-case:
runs-on: ubuntu-latest
outputs:
test_cases: ${{ steps.test-case-matrix.outputs.test_cases }}
CHECKOUT_REF: ${{ steps.get-checkout-ref.outputs.CHECKOUT_REF }}
steps:
- name: Get checkout ref
id: get-checkout-ref
run: |
if [ "${{ github.event_name }}" == "pull_request" ] || [ "${{ github.event_name }}" == "pull_request_target" ]; then
CHECKOUT_REF=refs/pull/${{ github.event.number }}/merge
else
CHECKOUT_REF=${{ github.ref }}
fi
echo "CHECHOUT_REF=${CHECKOUT_REF}" >> $GITHUB_OUTPUT
echo "checkout ref ${CHECKOUT_REF}"
- name: Checkout out Repo
uses: actions/checkout@v4
with:
ref: ${{ steps.get-checkout-ref.outputs.CHECKOUT_REF }}
fetch-depth: 0

- name: Get test matrix
shell: bash
id: test-case-matrix
run: |
set -x
example_l=$(echo ${{ inputs.example }} | tr '[:upper:]' '[:lower:]')
cd ${{ github.workspace }}/${{ inputs.example }}/tests
test_cases=$(find . -type f -name "test_${example_l}*on_${{ inputs.hardware }}.sh" -print | cut -d/ -f2 | jq -R '.' | jq -sc '.')
echo "test_cases=$test_cases" >> $GITHUB_OUTPUT
run-test:
needs: [get-test-case]
strategy:
matrix:
test_case: ${{ fromJSON(needs.get-test-case.outputs.test_cases) }}
runs-on: ${{ inputs.hardware }}
continue-on-error: true
steps:
- name: Clean up Working Directory
run: |
sudo rm -rf ${{github.workspace}}/* || true
docker system prune -f
docker rmi $(docker images --filter reference="*/*/*:latest" -q) || true
- name: Checkout out Repo
uses: actions/checkout@v4
with:
ref: ${{ needs.get-test-case.outputs.CHECKOUT_REF }}
fetch-depth: 0

- name: Run test
shell: bash
env:
HUGGINGFACEHUB_API_TOKEN: ${{ secrets.HUGGINGFACEHUB_API_TOKEN }}
GOOGLE_CSE_ID: ${{ secrets.GOOGLE_CSE_ID }}
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
IMAGE_REPO: ${{ inputs.registry }}
IMAGE_TAG: ${{ inputs.tag }}
example: ${{ inputs.example }}
hardware: ${{ inputs.hardware }}
test_case: ${{ matrix.test_case }}
run: |
cd ${{ github.workspace }}/$example/tests
export IMAGE_REPO=${OPEA_IMAGE_REPO}
if [ -f ${test_case} ]; then timeout 30m bash ${test_case}; else echo "Test script {${test_case}} not found, skip test!"; fi
- name: Clean up container
shell: bash
if: cancelled() || failure()
run: |
cd ${{ github.workspace }}/${{ inputs.example }}/docker/${{ inputs.hardware }}
docker compose stop && docker compose rm -f
docker system prune -f
docker rmi $(docker images --filter reference="*:5000/*/*" -q) || true
- name: Publish pipeline artifact
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.test_case }}
path: ${{ github.workspace }}/${{ inputs.example }}/tests/*.log
59 changes: 8 additions & 51 deletions .github/workflows/pr-docker-compose-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ on:
- "**/ui/**"
- "!**.md"
- "!**.txt"
- .github/workflows/docker-compose-e2e.yml
workflow_dispatch:
- .github/workflows/pr-docker-compose-e2e.yml

# If there is a new commit, the previous jobs will be canceled
concurrency:
Expand All @@ -37,55 +36,13 @@ jobs:
mega_service: "${{ matrix.example }}"
runner_label: "docker-build-${{ matrix.hardware }}"

Example-test:
example-test:
needs: [job1, mega-image-build]
strategy:
matrix: ${{ fromJSON(needs.job1.outputs.run_matrix) }}
runs-on: ${{ matrix.hardware }}
continue-on-error: true
steps:
- name: Test example
run: |
echo "Matrix - example ${{ matrix.example }}, hardware ${{ matrix.hardware }}"
- name: Clean Up Working Directory
run: sudo rm -rf ${{github.workspace}}/*

- name: Checkout out Repo
uses: actions/checkout@v4
with:
ref: "refs/pull/${{ github.event.number }}/merge"

- name: Run test
env:
HUGGINGFACEHUB_API_TOKEN: ${{ secrets.HUGGINGFACEHUB_API_TOKEN }}
GOOGLE_CSE_ID: ${{ secrets.GOOGLE_CSE_ID }}
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
example: ${{ matrix.example }}
hardware: ${{ matrix.hardware }}
IMAGE_TAG: ${{ needs.mega-image-build.outputs.image_tag }}
IMAGE_REPO_GAUDI: ${{ vars.IMAGE_REPO_GAUDI }}
IMAGE_REPO_XEON: ${{ vars.IMAGE_REPO_XEON }}
run: |
cd ${{ github.workspace }}/$example/tests
if [ "$hardware" == "gaudi" ]; then IMAGE_REPO=$IMAGE_REPO_GAUDI; else IMAGE_REPO=$IMAGE_REPO_XEON; fi
export IMAGE_REPO=${IMAGE_REPO}
example_l=$(echo $example | tr '[:upper:]' '[:lower:]')
if [ -f test_${example_l}_on_${hardware}.sh ]; then timeout 30m bash test_${example_l}_on_${hardware}.sh; else echo "Test script not found, skip test!"; fi
- name: Clean up container
env:
example: ${{ matrix.example }}
hardware: ${{ matrix.hardware }}
if: cancelled() || failure()
run: |
cd ${{ github.workspace }}/$example/docker/$hardware
docker compose stop && docker compose rm -f
echo y | docker system prune
- name: Publish pipeline artifact
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.example }}-${{ matrix.hardware }}
path: ${{ github.workspace }}/${{ matrix.example }}/tests/*.log
uses: ./.github/workflows/_run-docker-compose.yml
with:
tag: ${{ needs.mega-image-build.outputs.image_tag }}
example: ${{ matrix.example }}
hardware: ${{ matrix.hardware }}
secrets: inherit
4 changes: 2 additions & 2 deletions ChatQnA/docker/gaudi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ docker build --no-cache -t opea/llm-tgi:latest --build-arg https_proxy=$https_pr
Build vllm docker.

```bash
docker build --no-cache -t vllm:hpu --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f comps/llms/text-generation/vllm/docker/Dockerfile.hpu .
docker build --no-cache -t opea/llm-vllm-hpu:latest --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f comps/llms/text-generation/vllm/docker/Dockerfile.hpu .
```

Build microservice docker.
Expand All @@ -60,7 +60,7 @@ docker build --no-cache -t opea/llm-vllm:latest --build-arg https_proxy=$https_p
Build vllm-on-ray docker.

```bash
docker build --no-cache -t vllm_ray:habana --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f comps/llms/text-generation/vllm-ray/docker/Dockerfile.vllmray .
docker build --no-cache -t opea/llm-vllm-ray-hpu:latest --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f comps/llms/text-generation/vllm-ray/docker/Dockerfile.vllmray .
```

Build microservice docker.
Expand Down
2 changes: 1 addition & 1 deletion ChatQnA/docker/gaudi/compose_vllm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ services:
HF_HUB_ENABLE_HF_TRANSFER: 0
restart: unless-stopped
vllm-service:
image: vllm:hpu
image: opea/llm-vllm-hpu:latest
container_name: vllm-gaudi-server
ports:
- "8008:80"
Expand Down
2 changes: 1 addition & 1 deletion ChatQnA/docker/gaudi/compose_vllm_ray.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ services:
HF_HUB_ENABLE_HF_TRANSFER: 0
restart: unless-stopped
vllm-ray-service:
image: vllm_ray:habana
image: opea/llm-vllm-ray-hpu:latest
container_name: vllm-ray-gaudi-server
ports:
- "8008:8000"
Expand Down
2 changes: 1 addition & 1 deletion ChatQnA/docker/xeon/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ Build vLLM docker.
```bash
git clone https://github.com/vllm-project/vllm.git
cd ./vllm/
docker build --no-cache -t vllm:cpu --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f Dockerfile.cpu .
docker build --no-cache -t opea/vllm:latest --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f Dockerfile.cpu .
```

Build microservice.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,19 +189,6 @@ services:
- DELETE_FILE=${DATAPREP_DELETE_FILE_ENDPOINT}
ipc: host
restart: always
chaqna-xeon-conversation-ui-server:
image: opea/chatqna-conversation-ui:latest
container_name: chatqna-xeon-conversation-ui-server
environment:
- no_proxy=${no_proxy}
- https_proxy=${https_proxy}
- http_proxy=${http_proxy}
ports:
- 5174:80
depends_on:
- chaqna-xeon-backend-server
ipc: host
restart: always

networks:
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ services:
LANGCHAIN_PROJECT: "opea-reranking-service"
restart: unless-stopped
vllm_service:
image: vllm:cpu
image: opea/vllm:latest
container_name: vllm-service
ports:
- "9009:80"
Expand Down Expand Up @@ -190,19 +190,6 @@ services:
- DELETE_FILE=${DATAPREP_DELETE_FILE_ENDPOINT}
ipc: host
restart: always
chaqna-xeon-conversation-ui-server:
image: opea/chatqna-conversation-ui:latest
container_name: chatqna-xeon-conversation-ui-server
environment:
- no_proxy=${no_proxy}
- https_proxy=${https_proxy}
- http_proxy=${http_proxy}
ports:
- 5174:80
depends_on:
- chaqna-xeon-backend-server
ipc: host
restart: always

networks:
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function start_services() {
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 .
docker build --no-cache -q -f Dockerfile-hpu -t opea/tei-gaudi:latest .

cd $WORKPATH/docker/gaudi
export EMBEDDING_MODEL_ID="BAAI/bge-base-en-v1.5"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function build_docker_images() {

docker build -t opea/embedding-tei:latest -f comps/embeddings/langchain/docker/Dockerfile .
docker build -t opea/retriever-qdrant:latest -f comps/retrievers/haystack/qdrant/docker/Dockerfile .
docker build -t opea/reranking-tei:latest -f comps/reranks/langchain/docker/Dockerfile .
docker build -t opea/reranking-tei:latest -f comps/reranks/tei/docker/Dockerfile .
docker build -t opea/llm-tgi:latest -f comps/llms/text-generation/tgi/Dockerfile .
docker build -t opea/dataprep-qdrant:latest -f comps/dataprep/qdrant/docker/Dockerfile .

Expand Down Expand Up @@ -55,14 +55,15 @@ function start_services() {
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/chatqna:latest#image: opea/chatqna:${IMAGE_TAG}#g" compose.yaml
sed -i "s#image: opea/chatqna-ui:latest#image: opea/chatqna-ui:${IMAGE_TAG}#g" compose.yaml
sed -i "s#image: opea/chatqna-conversation-ui:latest#image: opea/chatqna-conversation-ui:${IMAGE_TAG}#g" compose.yaml
sed -i "s#image: opea/*#image: ${IMAGE_REPO}opea/#g" compose.yaml
sed -i "s#image: opea/chatqna:latest#image: opea/chatqna:${IMAGE_TAG}#g" compose_qdrant.yaml
sed -i "s#image: opea/chatqna-ui:latest#image: opea/chatqna-ui:${IMAGE_TAG}#g" compose_qdrant.yaml
sed -i "s#image: opea/chatqna-conversation-ui:latest#image: opea/chatqna-conversation-ui:${IMAGE_TAG}#g" compose_qdrant.yaml
sed -i "s#image: opea/*#image: ${IMAGE_REPO}opea/#g" compose_qdrant.yaml
cat compose_qdrant.yaml
fi

# Start Docker Containers
docker compose up -d
docker compose -f compose_qdrant.yaml up -d
n=0
until [[ "$n" -ge 200 ]]; do
docker logs tgi-service > tgi_service_start.log
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function build_docker_images() {
docker build -t opea/embedding-tei:latest -f comps/embeddings/langchain/docker/Dockerfile .
docker build -t opea/retriever-redis:latest -f comps/retrievers/langchain/redis/docker/Dockerfile .
docker build -t opea/reranking-tei:latest -f comps/reranks/tei/docker/Dockerfile .
docker build -t vllm:hpu -f comps/llms/text-generation/vllm/docker/Dockerfile.hpu .
docker build -t opea/llm-vllm-hpu:latest -f comps/llms/text-generation/vllm/docker/Dockerfile.hpu .
docker build -t opea/llm-vllm:latest -f comps/llms/text-generation/vllm/docker/Dockerfile.microservice .
docker build -t opea/dataprep-redis:latest -f comps/dataprep/redis/langchain/docker/Dockerfile .

Expand All @@ -42,7 +42,7 @@ function start_services() {
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 .
docker build --no-cache -q -f Dockerfile-hpu -t opea/tei-gaudi:latest .

cd $WORKPATH/docker/gaudi
export EMBEDDING_MODEL_ID="BAAI/bge-base-en-v1.5"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,21 @@ function build_docker_images() {
cd $WORKPATH/docker/ui
docker build --no-cache -t opea/chatqna-ui:latest -f docker/Dockerfile .

cd $WORKPATH
git clone https://github.com/vllm-project/vllm.git
cd vllm
docker build --no-cache -t vllm:cpu -f Dockerfile.cpu .
# cd $WORKPATH
# git clone https://github.com/vllm-project/vllm.git
# cd vllm
# docker build --no-cache -t opea/vllm:latest -f Dockerfile.cpu .

docker images
}

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

cd $WORKPATH/docker/xeon

export EMBEDDING_MODEL_ID="BAAI/bge-base-en-v1.5"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function build_docker_images() {
docker build -t opea/embedding-tei:latest -f comps/embeddings/langchain/docker/Dockerfile .
docker build -t opea/retriever-redis:latest -f comps/retrievers/langchain/redis/docker/Dockerfile .
docker build -t opea/reranking-tei:latest -f comps/reranks/tei/docker/Dockerfile .
docker build -t vllm_ray:habana -f comps/llms/text-generation/vllm-ray/docker/Dockerfile.vllmray .
docker build -t opea/llm-vllm-ray-hpu:latest -f comps/llms/text-generation/vllm-ray/docker/Dockerfile.vllmray .
docker build -t opea/llm-vllm-ray:latest -f comps/llms/text-generation/vllm-ray/docker/Dockerfile.microservice .
docker build -t opea/dataprep-redis:latest -f comps/dataprep/redis/langchain/docker/Dockerfile .

Expand All @@ -42,7 +42,7 @@ function start_services() {
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 .
docker build --no-cache -q -f Dockerfile-hpu -t opea/tei-gaudi:latest .

cd $WORKPATH/docker/gaudi
export EMBEDDING_MODEL_ID="BAAI/bge-base-en-v1.5"
Expand Down
Loading

0 comments on commit 939502d

Please sign in to comment.