Skip to content

Commit a68a686

Browse files
yao531441ZePan110pre-commit-ci[bot]joshuayao
authored
[Feature] Support one click deployment (#2087)
Signed-off-by: Yao, Qing <qing.yao@intel.com> Signed-off-by: ZePan110 <ze.pan@intel.com> Signed-off-by: Yi Yao <yi.a.yao@intel.com> Co-authored-by: ZePan110 <ze.pan@intel.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Yi Yao <yi.a.yao@intel.com>
1 parent 5457289 commit a68a686

33 files changed

Lines changed: 4734 additions & 53 deletions

File tree

Lines changed: 269 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,269 @@
1+
# Copyright (C) 2024 Intel Corporation
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
name: One Click test on call
5+
6+
permissions:
7+
contents: read
8+
9+
on:
10+
workflow_call:
11+
inputs:
12+
registry:
13+
description: Container Registry URL
14+
required: false
15+
default: ""
16+
type: string
17+
tag:
18+
description: Container Tag
19+
required: false
20+
default: "latest"
21+
type: string
22+
example:
23+
description: Example to test
24+
required: true
25+
type: string
26+
test_compose:
27+
default: true
28+
description: 'Test examples with docker compose'
29+
required: false
30+
type: boolean
31+
test_helmchart:
32+
default: true
33+
description: 'Test examples with helm charts'
34+
required: false
35+
type: boolean
36+
hardware:
37+
description: Hardware to run the test on
38+
required: true
39+
type: string
40+
opea_branch:
41+
default: "main"
42+
required: false
43+
type: string
44+
jobs:
45+
docker-test:
46+
if: ${{ inputs.test_compose || inputs.tag == 'ci' }}
47+
runs-on: ${{ inputs.hardware }}
48+
continue-on-error: true
49+
steps:
50+
- name: Clean up Working Directory
51+
run: |
52+
sudo rm -rf ${{github.workspace}}/* || true
53+
54+
echo "Cleaning up containers using ports..."
55+
cid=$(docker ps --format '{{.Names}} : {{.Ports}}' | grep -v ' : $' | grep -v 0.0.0.0:5000 | awk -F' : ' '{print $1}')
56+
if [[ ! -z "$cid" ]]; then docker stop $cid && docker rm $cid && sleep 1s; fi
57+
docker system prune -f
58+
59+
echo "Cleaning up images ..."
60+
docker images --filter reference="*/*/*:latest" -q | xargs -r docker rmi && sleep 1s
61+
docker images --filter reference="*/*:ci" -q | xargs -r docker rmi && sleep 1s
62+
docker images --filter reference="*:5000/*/*" -q | xargs -r docker rmi && sleep 1s
63+
docker images --filter reference="opea/comps-base" -q | xargs -r docker rmi && sleep 1s
64+
docker images
65+
66+
- name: Checkout out Repo
67+
uses: actions/checkout@v4
68+
with:
69+
ref: ${{ needs.get-test-case.outputs.CHECKOUT_REF }}
70+
fetch-depth: 0
71+
72+
- name: Clean up container before test
73+
shell: bash
74+
run: |
75+
docker ps
76+
cd ${{ github.workspace }}/${{ inputs.example }}
77+
export test_case=${{ matrix.test_case }}
78+
export hardware=${{ inputs.hardware }}
79+
bash ${{ github.workspace }}/.github/workflows/scripts/docker_compose_clean_up.sh "containers"
80+
bash ${{ github.workspace }}/.github/workflows/scripts/docker_compose_clean_up.sh "ports"
81+
docker ps
82+
83+
- name: Log in DockerHub
84+
uses: docker/login-action@v3.2.0
85+
with:
86+
username: ${{ secrets.DOCKERHUB_USER }}
87+
password: ${{ secrets.DOCKERHUB_TOKEN }}
88+
89+
- name: deploy docker and test
90+
shell: bash
91+
env:
92+
HUGGINGFACEHUB_API_TOKEN: ${{ secrets.HF_TOKEN }}
93+
HF_TOKEN: ${{ secrets.HF_TOKEN }}
94+
GOOGLE_CSE_ID: ${{ secrets.GOOGLE_CSE_ID }}
95+
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
96+
PINECONE_KEY: ${{ secrets.PINECONE_KEY }}
97+
PINECONE_KEY_LANGCHAIN_TEST: ${{ secrets.PINECONE_KEY_LANGCHAIN_TEST }}
98+
SDK_BASE_URL: ${{ secrets.SDK_BASE_URL }}
99+
SERVING_TOKEN: ${{ secrets.SERVING_TOKEN }}
100+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
101+
FINNHUB_API_KEY: ${{ secrets.FINNHUB_API_KEY }}
102+
FINANCIAL_DATASETS_API_KEY: ${{ secrets.FINANCIAL_DATASETS_API_KEY }}
103+
IMAGE_REPO: ${{ inputs.registry }}
104+
IMAGE_TAG: ${{ inputs.tag }}
105+
opea_branch: ${{ inputs.opea_branch }}
106+
example: ${{ inputs.example }}
107+
hardware: ${{ inputs.hardware }}
108+
test_case: ${{ matrix.test_case }}
109+
use_model_cache: ${{ inputs.use_model_cache }}
110+
run: |
111+
set -x
112+
sudo apt update
113+
sudo apt install -y python3-pip
114+
cd ${{ github.workspace }}/one_click_deploy
115+
python3 -m pip install -r requirements.txt
116+
117+
export LLM_model=meta-llama/Meta-Llama-3-8B-Instruct
118+
export Embedding_model=BAAI/bge-base-en-v1.5
119+
export Reranking_model=BAAI/bge-reranker-base
120+
export Mount_dir=./data
121+
export CodeTrans_model=mistralai/Mistral-7B-Instruct-v0.3
122+
export DocSum_model=meta-llama/Meta-Llama-3-8B-Instruct
123+
export CodeGen_model=Qwen/Qwen2.5-Coder-7B-Instruct
124+
export AudioQnA_model=meta-llama/Meta-Llama-3-8B-Instruct
125+
export VisualQnA_model=llava-hf/llava-v1.6-mistral-7b-hf
126+
export FaqGen_model=meta-llama/Meta-Llama-3-8B-Instruct
127+
128+
INPUT_DATA=$(
129+
jq -r --arg type "docker" --arg id "${{ inputs.example }}" \
130+
'.[$type][$id].inputs.deploy[]' ${{ github.workspace }}/.github/workflows/one-click-inputs-nobuild.json | \
131+
sed "s|\$hardware|$hardware|g; \
132+
s|\$HF_TOKEN|$HF_TOKEN|g; \
133+
s|\$LLM_model|$LLM_model|g; \
134+
s|\$Embedding_model|$Embedding_model|g; \
135+
s|\$Reranking_model|$Reranking_model|g; \
136+
s|\$CodeTrans_model|$CodeTrans_model|g; \
137+
s|\$DocSum_model|$DocSum_model|g; \
138+
s|\$CodeGen_model|$CodeGen_model|g; \
139+
s|\$AudioQnA_model|$AudioQnA_model|g; \
140+
s|\$VisualQnA_model|$VisualQnA_model|g; \
141+
s|\$FaqGen_model|$FaqGen_model|g; \
142+
s|\$Mount_dir|$Mount_dir|g"
143+
)
144+
echo "Generated input:"
145+
echo "$INPUT_DATA"
146+
147+
python3 one_click_deploy.py << INPUTS
148+
$INPUT_DATA
149+
INPUTS
150+
151+
- name: Clean up deployment
152+
run: |
153+
cd ${{ github.workspace }}/one_click_deploy
154+
155+
INPUT_DATA=$(
156+
jq -r --arg type "docker" --arg id "${{ inputs.example }}" \
157+
'.[$type][$id].inputs.clear[]' ${{ github.workspace }}/.github/workflows/one-click-inputs.json | \
158+
sed "s/\$hardware/$hardware/g"
159+
)
160+
echo "Generated input:"
161+
echo "$INPUT_DATA"
162+
163+
python3 one_click_deploy.py << INPUTS
164+
$INPUT_DATA
165+
INPUTS
166+
167+
- name: Publish docker pipeline artifact
168+
if: ${{ !cancelled() }}
169+
uses: actions/upload-artifact@v4
170+
with:
171+
name: docker
172+
path: ${{ github.workspace }}/docker-tests/*.log
173+
174+
175+
k8s-test:
176+
if: ${{ inputs.test_helmchart || inputs.tag == 'ci' }}
177+
runs-on: k8s-${{ inputs.hardware }}
178+
continue-on-error: true
179+
steps:
180+
- name: Clean Up Working Directory
181+
run: |
182+
echo "value_file=${{ matrix.value_file }}"
183+
sudo rm -rf ${{github.workspace}}/*
184+
185+
- name: Checkout out Repo
186+
uses: actions/checkout@v4
187+
with:
188+
ref: ${{ needs.get-test-case.outputs.CHECKOUT_REF }}
189+
fetch-depth: 0
190+
191+
- name: deploy k8s and test
192+
shell: bash
193+
env:
194+
HUGGINGFACEHUB_API_TOKEN: ${{ secrets.HF_TOKEN }}
195+
HF_TOKEN: ${{ secrets.HF_TOKEN }}
196+
GOOGLE_CSE_ID: ${{ secrets.GOOGLE_CSE_ID }}
197+
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
198+
PINECONE_KEY: ${{ secrets.PINECONE_KEY }}
199+
PINECONE_KEY_LANGCHAIN_TEST: ${{ secrets.PINECONE_KEY_LANGCHAIN_TEST }}
200+
SDK_BASE_URL: ${{ secrets.SDK_BASE_URL }}
201+
SERVING_TOKEN: ${{ secrets.SERVING_TOKEN }}
202+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
203+
FINNHUB_API_KEY: ${{ secrets.FINNHUB_API_KEY }}
204+
FINANCIAL_DATASETS_API_KEY: ${{ secrets.FINANCIAL_DATASETS_API_KEY }}
205+
IMAGE_REPO: ${{ inputs.registry }}
206+
IMAGE_TAG: ${{ inputs.tag }}
207+
opea_branch: ${{ inputs.opea_branch }}
208+
example: ${{ inputs.example }}
209+
hardware: ${{ inputs.hardware }}
210+
test_case: ${{ matrix.test_case }}
211+
use_model_cache: ${{ inputs.use_model_cache }}
212+
run: |
213+
cd ${{ github.workspace }}/one_click_deploy
214+
python3 -m pip install -r requirements.txt
215+
216+
export LLM_model=meta-llama/Meta-Llama-3-8B-Instruct
217+
export Embedding_model=BAAI/bge-base-en-v1.5
218+
export Reranking_model=BAAI/bge-reranker-base
219+
export Mount_dir=./data
220+
export CodeTrans_model=mistralai/Mistral-7B-Instruct-v0.3
221+
export DocSum_model=meta-llama/Meta-Llama-3-8B-Instruct
222+
export CodeGen_model=Qwen/Qwen2.5-Coder-7B-Instruct
223+
export AudioQnA_model=meta-llama/Meta-Llama-3-8B-Instruct
224+
export VisualQnA_model=llava-hf/llava-v1.6-mistral-7b-hf
225+
export FaqGen_model=meta-llama/Meta-Llama-3-8B-Instruct
226+
227+
INPUT_DATA=$(
228+
jq -r --arg type "k8s" --arg id "${{ inputs.example }}" \
229+
'.[$type][$id].inputs.deploy[]' ${{ github.workspace }}/.github/workflows/one-click-inputs-nobuild.json | \
230+
sed "s|\$hardware|$hardware|g; \
231+
s|\$HF_TOKEN|$HF_TOKEN|g; \
232+
s|\$LLM_model|$LLM_model|g; \
233+
s|\$Embedding_model|$Embedding_model|g; \
234+
s|\$Reranking_model|$Reranking_model|g; \
235+
s|\$CodeTrans_model|$CodeTrans_model|g; \
236+
s|\$DocSum_model|$DocSum_model|g; \
237+
s|\$CodeGen_model|$CodeGen_model|g; \
238+
s|\$AudioQnA_model|$AudioQnA_model|g; \
239+
s|\$VisualQnA_model|$VisualQnA_model|g; \
240+
s|\$FaqGen_model|$FaqGen_model|g; \
241+
s|\$Mount_dir|$Mount_dir|g"
242+
)
243+
echo "Generated input:"
244+
echo "$INPUT_DATA"
245+
246+
python3 one_click_deploy.py << INPUTS
247+
$INPUT_DATA
248+
INPUTS
249+
250+
- name: Clean up deployment
251+
run: |
252+
cd ${{ github.workspace }}/one_click_deploy
253+
INPUT_DATA=$(
254+
jq -r --arg type "k8s" --arg id "${{ inputs.example }}" \
255+
'.[$type][$id].inputs.clear[]' ${{ github.workspace }}/.github/workflows/one-click-inputs.json
256+
)
257+
echo "Generated input:"
258+
echo "$INPUT_DATA"
259+
260+
python3 one_click_deploy.py << INPUTS
261+
$INPUT_DATA
262+
INPUTS
263+
264+
- name: Publish pipeline artifact
265+
if: ${{ !cancelled() }}
266+
uses: actions/upload-artifact@v4
267+
with:
268+
name: k8s
269+
path: ${{ github.workspace }}/k8s-tests/*.log
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# Copyright (C) 2024 Intel Corporation
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
name: One Click workflow on manual event
5+
6+
permissions:
7+
contents: read
8+
# actions: read
9+
# checks: read
10+
# deployments: read
11+
# discussions: read
12+
# issues: read
13+
# packages: read
14+
# pages: read
15+
# pull-requests: read
16+
# repository-projects: read
17+
# statuses: read
18+
# security-events: read
19+
# id-token: write
20+
# attestations: read
21+
# models: read
22+
23+
on:
24+
workflow_dispatch:
25+
inputs:
26+
nodes:
27+
default: "gaudi,xeon"
28+
description: "Hardware to run test gaudi,xeon,rocm,arc,gaudi3,xeon-gnr"
29+
required: true
30+
type: string
31+
examples:
32+
default: "ChatQnA"
33+
description: 'List of examples to test [ChatQnA, CodeTrans, DocSum, CodeGen, AudioQnA, VisualQnA, FaqGen, AgentQnA]'
34+
required: true
35+
type: string
36+
tag:
37+
default: "latest"
38+
description: "Tag to apply to images"
39+
required: true
40+
type: string
41+
build:
42+
default: true
43+
description: 'Build test required images for Examples'
44+
required: false
45+
type: boolean
46+
test_compose:
47+
default: true
48+
description: 'Test examples with docker compose'
49+
required: false
50+
type: boolean
51+
test_helmchart:
52+
default: true
53+
description: 'Test examples with helm charts'
54+
required: false
55+
type: boolean
56+
57+
jobs:
58+
get-test-matrix:
59+
runs-on: ubuntu-latest
60+
outputs:
61+
examples: ${{ steps.get-matrix.outputs.examples }}
62+
nodes: ${{ steps.get-matrix.outputs.nodes }}
63+
steps:
64+
- name: Create Matrix
65+
id: get-matrix
66+
run: |
67+
examples=($(echo ${{ inputs.examples }} | tr ',' ' '))
68+
examples_json=$(printf '%s\n' "${examples[@]}" | sort -u | jq -R '.' | jq -sc '.')
69+
echo "examples=$examples_json" >> $GITHUB_OUTPUT
70+
nodes=($(echo ${{ inputs.nodes }} | tr ',' ' '))
71+
nodes_json=$(printf '%s\n' "${nodes[@]}" | sort -u | jq -R '.' | jq -sc '.')
72+
echo "nodes=$nodes_json" >> $GITHUB_OUTPUT
73+
74+
run-examples:
75+
# permissions:
76+
# actions: read
77+
# attestations: read
78+
# discussions: read
79+
# models: read
80+
# repository-projects: read
81+
# id-token: write
82+
# contents: read
83+
# checks: write
84+
# deployments: write
85+
# issues: write
86+
# packages: write
87+
# pages: write
88+
# pull-requests: write
89+
# statuses: write
90+
# security-events: read
91+
needs: [get-test-matrix]
92+
strategy:
93+
matrix:
94+
example: ${{ fromJson(needs.get-test-matrix.outputs.examples) }}
95+
node: ${{ fromJson(needs.get-test-matrix.outputs.nodes) }}
96+
fail-fast: false
97+
uses: ./.github/workflows/_run-one-click.yml
98+
with:
99+
node: ${{ matrix.node }}
100+
example: ${{ matrix.example }}
101+
tag: ${{ inputs.tag }}
102+
registry: "opea"
103+
test_compose: ${{ fromJSON(inputs.test_compose) }}
104+
test_helmchart: ${{ fromJSON(inputs.test_helmchart) }}
105+
secrets: inherit

0 commit comments

Comments
 (0)