Skip to content

Commit 4821b63

Browse files
authored
[CI]skip unnecessary executions (#10509)
* skip unnecessary executions for unittest * fix * fix * skip unnecessary executions for distribute * fix unittest * fix
1 parent e7516ee commit 4821b63

File tree

2 files changed

+60
-27
lines changed

2 files changed

+60
-27
lines changed

scripts/distribute/run_ci.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ install_paddle(){
6363
install_paddlenlp(){
6464
echo -e "\033[31m ---- Install paddlenlp by set PYTHONPATH \033"
6565
export PYTHONPATH=${nlp_dir}:$PYTHONPATH
66+
# python -m pip install -r ${nlp_dir}/requirements.txt
6667
sed -i -e "s/paddlenlp/#paddlenlp/g" model_zoo/gpt-3/requirements.txt
6768
# export http_proxy=${proxy} && export https_proxy=${proxy}
6869
# python -m pip uninstall paddlenlp -y
@@ -87,9 +88,9 @@ install_external_ops(){
8788

8889
function is_a100() {
8990
if [ $(nvidia-smi|grep A100|wc -l) -ne 0 ];then
90-
echo 1
91+
echo 1 # A100
9192
else
92-
echo 0
93+
echo 0 # not A100
9394
fi
9495
}
9596

@@ -131,9 +132,6 @@ get_diff_TO_case(){
131132
fi
132133
done
133134
else
134-
case_list[${#case_list[*]}]=gpt-3_auto
135-
case_list[${#case_list[*]}]=llama_auto
136-
case_list[${#case_list[*]}]=deepseek_auto
137135
for file_name in `git diff --numstat upstream/${AGILE_COMPILE_BRANCH} |awk '{print $NF}'`;do
138136
arr_file_name=(${file_name//// })
139137
dir1=${arr_file_name[0]}
@@ -147,6 +145,9 @@ get_diff_TO_case(){
147145
elif [[ ${file_name##*.} == "md" ]] || [[ ${file_name##*.} == "rst" ]] || [[ ${dir1} == "docs" ]];then
148146
continue
149147
else
148+
case_list[${#case_list[*]}]=gpt-3_auto
149+
case_list[${#case_list[*]}]=llama_auto
150+
case_list[${#case_list[*]}]=deepseek_auto
150151
for ((i=0; i<${#target_lists_for_gpt[@]}; i++)); do
151152
if [[ ! ${dir3} =~ "benchmarks" ]] && [[ ${file_item} == *${target_lists_for_gpt[i]}* ]];then
152153
case_list[${#case_list[*]}]=gpt-3_dygraph

scripts/unit_test/ci_unit.sh

Lines changed: 54 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
set -e
1818
export paddle=$1
19+
export FLAGS_enable_CE=${2-false}
1920
export nlp_dir=/workspace/PaddleNLP
2021
export log_path=/workspace/PaddleNLP/unittest_logs
2122
cd $nlp_dir
@@ -49,10 +50,17 @@ set_env() {
4950
export FLAGS_cudnn_deterministic=1
5051
export HF_ENDPOINT=https://hf-mirror.com
5152
export FLAGS_use_cuda_managed_memory=true
53+
export running_time=30m
54+
5255
# for CE
53-
# export CE_TEST_ENV=1
54-
# export RUN_SLOW_TEST=1
55-
# export PYTHONPATH=${nlp_dir}:${nlp_dir/llm/
56+
if [[ ${FLAGS_enable_CE} == "true" ]];then
57+
export CE_TEST_ENV=1
58+
export RUN_SLOW_TEST=1
59+
export PYTHONPATH=${nlp_dir}:${nlp_dir}/llm:${PYTHONPATH}
60+
export running_time=5h
61+
else
62+
continue
63+
fi
5664
}
5765

5866
print_info() {
@@ -74,25 +82,49 @@ print_info() {
7482
fi
7583
}
7684

77-
install_requirements
85+
get_diff_TO_case(){
86+
export FLAGS_enable_CI=false
87+
for file_name in `git diff --numstat ${AGILE_COMPILE_BRANCH} |awk '{print $NF}'`;do
88+
arr_file_name=(${file_name//// })
89+
dir1=${arr_file_name[0]}
90+
dir2=${arr_file_name[1]}
91+
dir3=${arr_file_name[2]}
92+
dir4=${arr_file_name[3]}
93+
file_item=$dir1/$dir2/$dir3/$dir4
94+
echo "file_name:"${file_name}, "dir1:"${dir1}, "dir2:"${dir2},"dir3:"${dir3},".xx:" ${file_name##*.}
95+
if [ ! -f ${file_name} ];then # 针对pr删掉文件
96+
continue
97+
elif [[ ${file_name##*.} == "md" ]] || [[ ${file_name##*.} == "rst" ]] || [[ ${dir1} == "docs" ]];then
98+
continue
99+
else
100+
FLAGS_enable_CI=true
101+
fi
102+
done
103+
}
104+
get_diff_TO_case
78105
set_env
79-
cd ${nlp_dir}
80-
echo ' Testing all unittest cases '
81-
export http_proxy=${proxy} && export https_proxy=${proxy}
82-
set +e
83-
timeout 30m python -m pytest -v -n 8 \
84-
--dist loadgroup \
85-
--retries 1 --retry-delay 1 \
86-
--timeout 200 --durations 20 --alluredir=result \
87-
--cov paddlenlp --cov-report xml:coverage.xml > ${log_path}/unittest.log 2>&1
88-
exit_code=$?
89-
print_info $exit_code unittest
90-
91-
cd ${nlp_dir}
92-
echo -e "\033[35m ---- Genrate Allure Report \033[0m"
93-
unset http_proxy && unset https_proxy
94-
cp scripts/regression/gen_allure_report.py ./
95-
python gen_allure_report.py > /dev/null
96-
echo -e "\033[35m ---- Report: https://xly.bce.baidu.com/ipipe/ipipe-report/report/${AGILE_JOB_BUILD_ID}/report/ \033[0m"
106+
if [[ ${FLAGS_enable_CI} == "true" ]] || [[ ${FLAGS_enable_CE} == "true" ]];then
107+
install_requirements
108+
cd ${nlp_dir}
109+
echo ' Testing all unittest cases '
110+
export http_proxy=${proxy} && export https_proxy=${proxy}
111+
set +e
112+
timeout ${running_time} python -m pytest -v -n 8 \
113+
--dist loadgroup \
114+
--retries 1 --retry-delay 1 \
115+
--timeout 200 --durations 20 --alluredir=result \
116+
--cov paddlenlp --cov-report xml:coverage.xml > ${log_path}/unittest.log 2>&1
117+
exit_code=$?
118+
print_info $exit_code unittest
97119

120+
cd ${nlp_dir}
121+
echo -e "\033[35m ---- Genrate Allure Report \033[0m"
122+
unset http_proxy && unset https_proxy
123+
cp scripts/regression/gen_allure_report.py ./
124+
python gen_allure_report.py > /dev/null
125+
echo -e "\033[35m ---- Report: https://xly.bce.baidu.com/ipipe/ipipe-report/report/${AGILE_JOB_BUILD_ID}/report/ \033[0m"
126+
else
127+
echo -e "\033[32m Changed Not CI case, Skips \033[0m"
128+
exit_code=0
129+
fi
98130
exit $exit_code

0 commit comments

Comments
 (0)