Skip to content

Commit

Permalink
Merge branch 'main' into mmqna-audio-query
Browse files Browse the repository at this point in the history
  • Loading branch information
mhbuehler authored Dec 4, 2024
2 parents 7f7236d + 031cf6e commit 56db11a
Show file tree
Hide file tree
Showing 12 changed files with 642 additions and 232 deletions.
88 changes: 81 additions & 7 deletions .github/workflows/_manifest-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,72 @@ on:
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 "CHECKOUT_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: |
example_l=$(echo ${{ inputs.example }} | tr '[:upper:]' '[:lower:]')
cd ${{ github.workspace }}/${{ inputs.example }}/tests
run_test_cases=""
default_test_case=$(find . -type f -name "test_manifest_on_${{ inputs.hardware }}.sh" | cut -d/ -f2)
if [ "$default_test_case" ]; then run_test_cases="$default_test_case"; fi
other_test_cases=$(find . -type f -name "test_manifest_*_on_${{ inputs.hardware }}.sh" | cut -d/ -f2)
echo "default_test_case=$default_test_case"
echo "other_test_cases=$other_test_cases"
if [ "${{ inputs.tag }}" == "ci" ]; then
base_commit=$(curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/opea-project/GenAIExamples/commits?sha=${{ github.event.pull_request.base.ref }}" | jq -r '.[0].sha')
merged_commit=$(git log -1 --format='%H')
changed_files="$(git diff --name-only ${base_commit} ${merged_commit} | grep -vE '${{ inputs.diff_excluded_files }}')" || true
fi
for test_case in $other_test_cases; do
if [ "${{ inputs.tag }}" == "ci" ]; then
flag=${test_case%_on_*}
flag=${flag#test_compose_}
if [[ $(printf '%s\n' "${changed_files[@]}" | grep ${{ inputs.example }} | grep ${flag}) ]]; then
run_test_cases="$run_test_cases $test_case"
fi
else
run_test_cases="$run_test_cases $test_case"
fi
done
test_cases=$(echo $run_test_cases | tr ' ' '\n' | sort -u | jq -R '.' | jq -sc '.')
echo "test_cases=$test_cases"
echo "test_cases=$test_cases" >> $GITHUB_OUTPUT
manifest-test:
needs: [get-test-case]
strategy:
matrix:
test_case: ${{ fromJSON(needs.get-test-case.outputs.test_cases) }}
fail-fast: false
runs-on: "k8s-${{ inputs.hardware }}"
continue-on-error: true
steps:
Expand All @@ -45,11 +110,14 @@ jobs:
fetch-depth: 0

- name: Set variables
env:
test_case: ${{ matrix.test_case }}
run: |
echo "IMAGE_REPO=${OPEA_IMAGE_REPO}opea" >> $GITHUB_ENV
echo "IMAGE_TAG=${{ inputs.tag }}" >> $GITHUB_ENV
lower_example=$(echo "${{ inputs.example }}" | tr '[:upper:]' '[:lower:]')
echo "NAMESPACE=$lower_example-$(tr -dc a-z0-9 </dev/urandom | head -c 16)" >> $GITHUB_ENV
name=$(echo "$test_case" | cut -d/ -f2 | cut -d'_' -f3- |cut -d'_' -f1 | grep -v 'on' | sed 's/^/-/')
echo "NAMESPACE=$lower_example$name-$(tr -dc a-z0-9 </dev/urandom | head -c 16)" >> $GITHUB_ENV
echo "ROLLOUT_TIMEOUT_SECONDS=1800s" >> $GITHUB_ENV
echo "KUBECTL_TIMEOUT_SECONDS=60s" >> $GITHUB_ENV
echo "continue_test=true" >> $GITHUB_ENV
Expand All @@ -59,15 +127,19 @@ jobs:
- name: Kubectl install
id: install
env:
test_case: ${{ matrix.test_case }}
run: |
if [[ ! -f ${{ github.workspace }}/${{ inputs.example }}/tests/test_manifest_on_${{ inputs.hardware }}.sh ]]; then
set -x
echo "test_case=$test_case"
if [[ ! -f ${{ github.workspace }}/${{ inputs.example }}/tests/${test_case} ]]; then
echo "No test script found, exist test!"
exit 0
else
${{ github.workspace }}/${{ inputs.example }}/tests/test_manifest_on_${{ inputs.hardware }}.sh init_${{ inputs.example }}
${{ github.workspace }}/${{ inputs.example }}/tests/${test_case} init_${{ inputs.example }}
echo "should_cleanup=true" >> $GITHUB_ENV
kubectl create ns $NAMESPACE
${{ github.workspace }}/${{ inputs.example }}/tests/test_manifest_on_${{ inputs.hardware }}.sh install_${{ inputs.example }} $NAMESPACE
${{ github.workspace }}/${{ inputs.example }}/tests/${test_case} install_${{ inputs.example }} $NAMESPACE
echo "Testing ${{ inputs.example }}, waiting for pod ready..."
if kubectl rollout status deployment --namespace "$NAMESPACE" --timeout "$ROLLOUT_TIMEOUT_SECONDS"; then
echo "Testing manifests ${{ inputs.example }}, waiting for pod ready done!"
Expand All @@ -82,14 +154,16 @@ jobs:
- name: Validate e2e test
if: always()
env:
test_case: ${{ matrix.test_case }}
run: |
if $skip_validate; then
echo "Skip validate"
else
if ${{ github.workspace }}/${{ inputs.example }}/tests/test_manifest_on_${{ inputs.hardware }}.sh validate_${{ inputs.example }} $NAMESPACE ; then
echo "Validate ${{ inputs.example }} successful!"
if ${{ github.workspace }}/${{ inputs.example }}/tests/${test_case} validate_${{ inputs.example }} $NAMESPACE ; then
echo "Validate ${test_case} successful!"
else
echo "Validate ${{ inputs.example }} failure!!!"
echo "Validate ${test_case} failure!!!"
echo "Check the logs in 'Dump logs when e2e test failed' step!!!"
exit 1
fi
Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/pr-check-duplicated-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

name: Check Duplicated Images

on:
pull_request:
branches: [main]
types: [opened, reopened, ready_for_review, synchronize]
paths:
- "**/docker_image_build/*.yaml"
- ".github/workflows/pr-check-duplicated-image.yml"
- ".github/workflows/scripts/check_duplicated_image.py"
workflow_dispatch:

# If there is a new commit, the previous jobs will be canceled
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
check-duplicated-image:
runs-on: ubuntu-latest
steps:
- name: Clean Up Working Directory
run: sudo rm -rf ${{github.workspace}}/*

- name: Checkout Repo
uses: actions/checkout@v4

- name: Check all the docker image build files
run: |
pip install PyYAML
cd ${{github.workspace}}
build_files=""
for f in `find . -path "*/docker_image_build/build.yaml"`; do
build_files="$build_files $f"
done
python3 .github/workflows/scripts/check_duplicated_image.py $build_files
shell: bash
63 changes: 63 additions & 0 deletions .github/workflows/scripts/check_duplicated_image.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

import argparse
import os.path
import subprocess
import sys

import yaml

images = {}


def check_docker_compose_build_definition(file_path):
with open(file_path, "r") as f:
data = yaml.load(f, Loader=yaml.FullLoader)
for service in data["services"]:
if "build" in data["services"][service] and "image" in data["services"][service]:
bash_command = "echo " + data["services"][service]["image"]
image = (
subprocess.run(["bash", "-c", bash_command], check=True, capture_output=True)
.stdout.decode("utf-8")
.strip()
)
build = data["services"][service]["build"]
context = build.get("context", "")
dockerfile = os.path.normpath(
os.path.join(os.path.dirname(file_path), context, build.get("dockerfile", ""))
)
if not os.path.isfile(dockerfile):
# dockerfile not exists in the current repo context, assume it's in 3rd party context
dockerfile = os.path.normpath(os.path.join(context, build.get("dockerfile", "")))
item = {"file_path": file_path, "service": service, "dockerfile": dockerfile}
if image in images and dockerfile != images[image]["dockerfile"]:
print("ERROR: !!! Found Conflicts !!!")
print(f"Image: {image}, Dockerfile: {dockerfile}, defined in Service: {service}, File: {file_path}")
print(
f"Image: {image}, Dockerfile: {images[image]['dockerfile']}, defined in Service: {images[image]['service']}, File: {images[image]['file_path']}"
)
sys.exit(1)
else:
# print(f"Add Image: {image} Dockerfile: {dockerfile}")
images[image] = item


def parse_arg():
parser = argparse.ArgumentParser(
description="Check for conflicts in image build definition in docker-compose.yml files"
)
parser.add_argument("files", nargs="+", help="list of files to be checked")
return parser.parse_args()


def main():
args = parse_arg()
for file_path in args.files:
check_docker_compose_build_definition(file_path)
print("SUCCESS: No Conlicts Found.")
return 0


if __name__ == "__main__":
main()
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,8 @@ data:
no_proxy: ""
LOGFLAG: ""
vLLM_ENDPOINT: "insert-your-remote-inference-endpoint"
LLM_MODEL: "meta-llama/Meta-Llama-3.1-8B-Instruct"
LLM_MODEL_ID: "meta-llama/Meta-Llama-3.1-8B-Instruct"
MODEL_ID: "meta-llama/Meta-Llama-3.1-8B-Instruct"
LLM_MODEL: "meta-llama/Meta-Llama-3.1-70B-Instruct"
MODEL_ID: "meta-llama/Meta-Llama-3.1-70B-Instruct"
CLIENTID: ""
CLIENT_SECRET: ""
TOKEN_URL: ""
Expand Down Expand Up @@ -216,6 +215,10 @@ data:
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_buffering off;
proxy_cache off;
proxy_request_buffering off;
gzip off;
}
location /v1/dataprep {
Expand Down Expand Up @@ -552,6 +555,9 @@ spec:
{}
containers:
- name: chatqna-ui
env:
- name: MODEL_ID
value: "meta-llama/Meta-Llama-3.1-70B-Instruct"
securityContext:
{}
image: "opea/chatqna-ui:latest"
Expand Down Expand Up @@ -691,7 +697,7 @@ spec:
seccompProfile:
type: RuntimeDefault
image: "opea/embedding-tei:latest"
imagePullPolicy: IfNotPresent
imagePullPolicy: Always
ports:
- name: embedding-usvc
containerPort: 6000
Expand Down Expand Up @@ -769,7 +775,7 @@ spec:
seccompProfile:
type: RuntimeDefault
image: "opea/llm-vllm:latest"
imagePullPolicy: IfNotPresent
imagePullPolicy: Always
ports:
- name: llm-uservice
containerPort: 9000
Expand Down Expand Up @@ -919,7 +925,7 @@ spec:
seccompProfile:
type: RuntimeDefault
image: "opea/reranking-tei:latest"
imagePullPolicy: IfNotPresent
imagePullPolicy: Always
ports:
- name: reranking-usvc
containerPort: 8000
Expand Down Expand Up @@ -1257,7 +1263,7 @@ spec:
- name: EMBEDDING_SERVICE_HOST_IP
value: chatqna-embedding-usvc
- name: MODEL_ID
value: "meta-llama/Meta-Llama-3.1-8B-Instruct"
value: "meta-llama/Meta-Llama-3.1-70B-Instruct"
securityContext:
allowPrivilegeEscalation: false
capabilities:
Expand All @@ -1269,7 +1275,7 @@ spec:
seccompProfile:
type: RuntimeDefault
image: "opea/chatqna-wrapper:latest"
imagePullPolicy: IfNotPresent
imagePullPolicy: Always
volumeMounts:
- mountPath: /tmp
name: tmp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ data:
no_proxy: ""
LOGFLAG: ""
vLLM_ENDPOINT: "insert-your-remote-vllm-inference-endpoint"
LLM_MODEL: "meta-llama/Meta-Llama-3.1-8B-Instruct"
MODEL_ID: "meta-llama/Meta-Llama-3.1-8B-Instruct"
LLM_MODEL: "meta-llama/Meta-Llama-3.1-70B-Instruct"
MODEL_ID: "meta-llama/Meta-Llama-3.1-70B-Instruct"
CLIENTID: ""
CLIENT_SECRET: ""
TOKEN_URL: ""
Expand Down Expand Up @@ -174,6 +174,10 @@ data:
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_buffering off;
proxy_cache off;
proxy_request_buffering off;
gzip off;
}
location /v1/dataprep {
Expand Down Expand Up @@ -459,6 +463,9 @@ spec:
{}
containers:
- name: chatqna-ui
env:
- name: MODEL_ID
value: "meta-llama/Meta-Llama-3.1-70B-Instruct"
securityContext:
{}
image: "opea/chatqna-ui:latest"
Expand Down Expand Up @@ -981,7 +988,7 @@ spec:
- name: EMBEDDING_SERVICE_HOST_IP
value: chatqna-embedding-usvc
- name: MODEL_ID
value: "meta-llama/Meta-Llama-3.1-8B-Instruct"
value: "meta-llama/Meta-Llama-3.1-70B-Instruct"
securityContext:
allowPrivilegeEscalation: false
capabilities:
Expand All @@ -993,7 +1000,7 @@ spec:
seccompProfile:
type: RuntimeDefault
image: "opea/chatqna-wrapper:latest"
imagePullPolicy: IfNotPresent
imagePullPolicy: Always
volumeMounts:
- mountPath: /tmp
name: tmp
Expand Down
Loading

0 comments on commit 56db11a

Please sign in to comment.