Skip to content

Commit be8e283

Browse files
Fix InstructionTuning and RerankFinetuning tests (opea-project#785)
Signed-off-by: Ye, Xinyu <xinyu.ye@intel.com>
1 parent 7b2194f commit be8e283

File tree

2 files changed

+44
-15
lines changed

2 files changed

+44
-15
lines changed

InstructionTuning/tests/test_compose_on_xeon.sh

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Copyright (C) 2024 Intel Corporation
33
# SPDX-License-Identifier: Apache-2.0
44

5-
set -ex
5+
set -x
66

77
WORKPATH=$(dirname "$PWD")
88
LOG_PATH="$WORKPATH/tests"
@@ -12,8 +12,11 @@ ray_port=8265
1212

1313
function build_docker_images() {
1414
cd $WORKPATH
15-
echo $(pwd)
16-
git clone https://github.com/opea-project/GenAIComps.git && cd GenAIComps && git checkout "${opea_branch:-"main"}"
15+
if [ ! -d "GenAIComps" ] ; then
16+
git clone https://github.com/opea-project/GenAIComps.git
17+
fi
18+
cd GenAIComps
19+
echo PWD: $(pwd)
1720
docker build -t opea/finetuning:latest --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy --build-arg HF_TOKEN=$HF_TOKEN -f comps/finetuning/Dockerfile .
1821
if [ $? -ne 0 ]; then
1922
echo "opea/finetuning built fail"
@@ -34,21 +37,30 @@ function validate_microservice() {
3437
export no_proxy="localhost,127.0.0.1,"${ip_address}
3538

3639
# test /v1/dataprep upload file
37-
URL="http://${ip_address}:$finetuning_service_port/v1/finetune/upload_training_files"
40+
URL="http://${ip_address}:$finetuning_service_port/v1/files"
3841
echo '[{"instruction": "Give three tips for staying healthy.", "input": "", "output": "1.Eat a balanced diet and make sure to include plenty of fruits and vegetables. \n2. Exercise regularly to keep your body active and strong. \n3. Get enough sleep and maintain a consistent sleep schedule."},{"instruction": "Give three tips for staying healthy.", "input": "", "output": "1.Eat a balanced diet and make sure to include plenty of fruits and vegetables. \n2. Exercise regularly to keep your body active and strong. \n3. Get enough sleep and maintain a consistent sleep schedule."},{"instruction": "Give three tips for staying healthy.", "input": "", "output": "1.Eat a balanced diet and make sure to include plenty of fruits and vegetables. \n2. Exercise regularly to keep your body active and strong. \n3. Get enough sleep and maintain a consistent sleep schedule."},{"instruction": "Give three tips for staying healthy.", "input": "", "output": "1.Eat a balanced diet and make sure to include plenty of fruits and vegetables. \n2. Exercise regularly to keep your body active and strong. \n3. Get enough sleep and maintain a consistent sleep schedule."},{"instruction": "Give three tips for staying healthy.", "input": "", "output": "1.Eat a balanced diet and make sure to include plenty of fruits and vegetables. \n2. Exercise regularly to keep your body active and strong. \n3. Get enough sleep and maintain a consistent sleep schedule."},{"instruction": "Give three tips for staying healthy.", "input": "", "output": "1.Eat a balanced diet and make sure to include plenty of fruits and vegetables. \n2. Exercise regularly to keep your body active and strong. \n3. Get enough sleep and maintain a consistent sleep schedule."},{"instruction": "Give three tips for staying healthy.", "input": "", "output": "1.Eat a balanced diet and make sure to include plenty of fruits and vegetables. \n2. Exercise regularly to keep your body active and strong. \n3. Get enough sleep and maintain a consistent sleep schedule."},{"instruction": "Give three tips for staying healthy.", "input": "", "output": "1.Eat a balanced diet and make sure to include plenty of fruits and vegetables. \n2. Exercise regularly to keep your body active and strong. \n3. Get enough sleep and maintain a consistent sleep schedule."},{"instruction": "Give three tips for staying healthy.", "input": "", "output": "1.Eat a balanced diet and make sure to include plenty of fruits and vegetables. \n2. Exercise regularly to keep your body active and strong. \n3. Get enough sleep and maintain a consistent sleep schedule."},{"instruction": "Give three tips for staying healthy.", "input": "", "output": "1.Eat a balanced diet and make sure to include plenty of fruits and vegetables. \n2. Exercise regularly to keep your body active and strong. \n3. Get enough sleep and maintain a consistent sleep schedule."},{"instruction": "Give three tips for staying healthy.", "input": "", "output": "1.Eat a balanced diet and make sure to include plenty of fruits and vegetables. \n2. Exercise regularly to keep your body active and strong. \n3. Get enough sleep and maintain a consistent sleep schedule."},{"instruction": "Give three tips for staying healthy.", "input": "", "output": "1.Eat a balanced diet and make sure to include plenty of fruits and vegetables. \n2. Exercise regularly to keep your body active and strong. \n3. Get enough sleep and maintain a consistent sleep schedule."},{"instruction": "Give three tips for staying healthy.", "input": "", "output": "1.Eat a balanced diet and make sure to include plenty of fruits and vegetables. \n2. Exercise regularly to keep your body active and strong. \n3. Get enough sleep and maintain a consistent sleep schedule."},{"instruction": "Give three tips for staying healthy.", "input": "", "output": "1.Eat a balanced diet and make sure to include plenty of fruits and vegetables. \n2. Exercise regularly to keep your body active and strong. \n3. Get enough sleep and maintain a consistent sleep schedule."},{"instruction": "Give three tips for staying healthy.", "input": "", "output": "1.Eat a balanced diet and make sure to include plenty of fruits and vegetables. \n2. Exercise regularly to keep your body active and strong. \n3. Get enough sleep and maintain a consistent sleep schedule."},{"instruction": "Give three tips for staying healthy.", "input": "", "output": "1.Eat a balanced diet and make sure to include plenty of fruits and vegetables. \n2. Exercise regularly to keep your body active and strong. \n3. Get enough sleep and maintain a consistent sleep schedule."},{"instruction": "Give three tips for staying healthy.", "input": "", "output": "1.Eat a balanced diet and make sure to include plenty of fruits and vegetables. \n2. Exercise regularly to keep your body active and strong. \n3. Get enough sleep and maintain a consistent sleep schedule."},{"instruction": "Give three tips for staying healthy.", "input": "", "output": "1.Eat a balanced diet and make sure to include plenty of fruits and vegetables. \n2. Exercise regularly to keep your body active and strong. \n3. Get enough sleep and maintain a consistent sleep schedule."},{"instruction": "Give three tips for staying healthy.", "input": "", "output": "1.Eat a balanced diet and make sure to include plenty of fruits and vegetables. \n2. Exercise regularly to keep your body active and strong. \n3. Get enough sleep and maintain a consistent sleep schedule."},{"instruction": "Give three tips for staying healthy.", "input": "", "output": "1.Eat a balanced diet and make sure to include plenty of fruits and vegetables. \n2. Exercise regularly to keep your body active and strong. \n3. Get enough sleep and maintain a consistent sleep schedule."}]' > $LOG_PATH/test_data.json
39-
HTTP_RESPONSE=$(curl --silent --write-out "HTTPSTATUS:%{http_code}" -X POST -F 'files=@./test_data.json' -H 'Content-Type: multipart/form-data' "$URL")
42+
HTTP_RESPONSE=$(curl --silent --write-out "HTTPSTATUS:%{http_code}" -X POST -F 'file=@./test_data.json' -F purpose="fine-tune" -H 'Content-Type: multipart/form-data' "$URL")
4043
HTTP_STATUS=$(echo $HTTP_RESPONSE | tr -d '\n' | sed -e 's/.*HTTPSTATUS://')
4144
RESPONSE_BODY=$(echo $HTTP_RESPONSE | sed -e 's/HTTPSTATUS\:.*//g')
4245
SERVICE_NAME="finetuning-server - upload - file"
4346

47+
# Parse the JSON response
48+
purpose=$(echo "$RESPONSE_BODY" | jq -r '.purpose')
49+
filename=$(echo "$RESPONSE_BODY" | jq -r '.filename')
50+
51+
# Define expected values
52+
expected_purpose="fine-tune"
53+
expected_filename="test_data.json"
54+
4455
if [ "$HTTP_STATUS" -ne "200" ]; then
4556
echo "[ $SERVICE_NAME ] HTTP status is not 200. Received status was $HTTP_STATUS"
4657
docker logs finetuning-server >> ${LOG_PATH}/finetuning-server_upload_file.log
4758
exit 1
4859
else
4960
echo "[ $SERVICE_NAME ] HTTP status is 200. Checking content..."
5061
fi
51-
if [[ "$RESPONSE_BODY" != *"Training files uploaded"* ]]; then
62+
# Check if the parsed values match the expected values
63+
if [[ "$purpose" != "$expected_purpose" || "$filename" != "$expected_filename" ]]; then
5264
echo "[ $SERVICE_NAME ] Content does not match the expected result: $RESPONSE_BODY"
5365
docker logs finetuning-server >> ${LOG_PATH}/finetuning-server_upload_file.log
5466
exit 1

RerankFinetuning/tests/test_compose_on_xeon.sh

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
#!/bin/bash
21
# Copyright (C) 2024 Intel Corporation
32
# SPDX-License-Identifier: Apache-2.0
43

5-
set -ex
4+
set -x
65

76
WORKPATH=$(dirname "$PWD")
87
LOG_PATH="$WORKPATH/tests"
@@ -12,9 +11,18 @@ ray_port=8265
1211

1312
function build_docker_images() {
1413
cd $WORKPATH
15-
echo $(pwd)
16-
git clone https://github.com/opea-project/GenAIComps.git && cd GenAIComps && git checkout "${opea_branch:-"main"}"
14+
if [ ! -d "GenAIComps" ] ; then
15+
git clone https://github.com/opea-project/GenAIComps.git
16+
fi
17+
cd GenAIComps
18+
echo PWD: $(pwd)
1719
docker build -t opea/finetuning:latest --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy --build-arg HF_TOKEN=$HF_TOKEN -f comps/finetuning/Dockerfile .
20+
if [ $? -ne 0 ]; then
21+
echo "opea/finetuning built fail"
22+
exit 1
23+
else
24+
echo "opea/finetuning built successful"
25+
fi
1826
}
1927

2028
function start_service() {
@@ -28,7 +36,7 @@ function validate_microservice() {
2836
export no_proxy="localhost,127.0.0.1,"${ip_address}
2937

3038
# test /v1/dataprep upload file
31-
URL="http://${ip_address}:$finetuning_service_port/v1/finetune/upload_training_files"
39+
URL="http://${ip_address}:$finetuning_service_port/v1/files"
3240
cat <<EOF > test_data.json
3341
{"query": "Five women walk along a beach wearing flip-flops.", "pos": ["Some women with flip-flops on, are walking along the beach"], "neg": ["The 4 women are sitting on the beach.", "There was a reform in 1996.", "She's not going to court to clear her record.", "The man is talking about hawaii.", "A woman is standing outside.", "The battle was over. ", "A group of people plays volleyball."]}
3442
{"query": "A woman standing on a high cliff on one leg looking over a river.", "pos": ["A woman is standing on a cliff."], "neg": ["A woman sits on a chair.", "George Bush told the Republicans there was no way he would let them even consider this foolish idea, against his top advisors advice.", "The family was falling apart.", "no one showed up to the meeting", "A boy is sitting outside playing in the sand.", "Ended as soon as I received the wire.", "A child is reading in her bedroom."]}
@@ -37,19 +45,28 @@ function validate_microservice() {
3745
{"query": "A yellow dog running along a forest path.", "pos": ["a dog is running"], "neg": ["a cat is running", "Steele did not keep her original story.", "The rule discourages people to pay their child support.", "A man in a vest sits in a car.", "Person in black clothing, with white bandanna and sunglasses waits at a bus stop.", "Neither the Globe or Mail had comments on the current state of Canada's road system. ", "The Spring Creek facility is old and outdated."]}
3846
{"query": "It sets out essential activities in each phase along with critical factors related to those activities.", "pos": ["Critical factors for essential activities are set out."], "neg": ["It lays out critical activities but makes no provision for critical factors related to those activities.", "People are assembled in protest.", "The state would prefer for you to do that.", "A girl sits beside a boy.", "Two males are performing.", "Nobody is jumping", "Conrad was being plotted against, to be hit on the head."]}
3947
EOF
40-
HTTP_RESPONSE=$(curl --silent --write-out "HTTPSTATUS:%{http_code}" -X POST -F 'files=@./test_data.json' -H 'Content-Type: multipart/form-data' "$URL")
48+
HTTP_RESPONSE=$(curl --silent --write-out "HTTPSTATUS:%{http_code}" -X POST -F 'file=@./test_data.json' -F purpose="fine-tune" -H 'Content-Type: multipart/form-data' "$URL")
4149
HTTP_STATUS=$(echo $HTTP_RESPONSE | tr -d '\n' | sed -e 's/.*HTTPSTATUS://')
4250
RESPONSE_BODY=$(echo $HTTP_RESPONSE | sed -e 's/HTTPSTATUS\:.*//g')
4351
SERVICE_NAME="finetuning-server - upload - file"
4452

53+
# Parse the JSON response
54+
purpose=$(echo "$RESPONSE_BODY" | jq -r '.purpose')
55+
filename=$(echo "$RESPONSE_BODY" | jq -r '.filename')
56+
57+
# Define expected values
58+
expected_purpose="fine-tune"
59+
expected_filename="test_data.json"
60+
4561
if [ "$HTTP_STATUS" -ne "200" ]; then
4662
echo "[ $SERVICE_NAME ] HTTP status is not 200. Received status was $HTTP_STATUS"
4763
docker logs finetuning-server >> ${LOG_PATH}/finetuning-server_upload_file.log
4864
exit 1
4965
else
5066
echo "[ $SERVICE_NAME ] HTTP status is 200. Checking content..."
5167
fi
52-
if [[ "$RESPONSE_BODY" != *"Training files uploaded"* ]]; then
68+
# Check if the parsed values match the expected values
69+
if [[ "$purpose" != "$expected_purpose" || "$filename" != "$expected_filename" ]]; then
5370
echo "[ $SERVICE_NAME ] Content does not match the expected result: $RESPONSE_BODY"
5471
docker logs finetuning-server >> ${LOG_PATH}/finetuning-server_upload_file.log
5572
exit 1
@@ -59,7 +76,7 @@ EOF
5976

6077
# test /v1/fine_tuning/jobs
6178
URL="http://${ip_address}:$finetuning_service_port/v1/fine_tuning/jobs"
62-
HTTP_RESPONSE=$(curl --silent --write-out "HTTPSTATUS:%{http_code}" -X POST -H 'Content-Type: application/json' -d '{"training_file": "test_data.json","model": "BAAI/bge-reranker-base"}' "$URL")
79+
HTTP_RESPONSE=$(curl --silent --write-out "HTTPSTATUS:%{http_code}" -X POST -H 'Content-Type: application/json' -d '{"training_file": "test_data.json","model": "BAAI/bge-reranker-base","General":{"task":"rerank","lora_config":null}}' "$URL")
6380
HTTP_STATUS=$(echo $HTTP_RESPONSE | tr -d '\n' | sed -e 's/.*HTTPSTATUS://')
6481
RESPONSE_BODY=$(echo $HTTP_RESPONSE | sed -e 's/HTTPSTATUS\:.*//g')
6582
SERVICE_NAME="finetuning-server - create finetuning job"
@@ -79,7 +96,7 @@ EOF
7996
echo "[ $SERVICE_NAME ] Content is as expected."
8097
fi
8198

82-
sleep 3m
99+
sleep 10m
83100
}
84101

85102
function stop_docker() {

0 commit comments

Comments
 (0)