1
+ #! /usr/bin/env bash
2
+
3
+ # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ failed_num=0
18
+ echo_list=()
19
+ approval_line=` curl -H " Authorization: token ${GITHUB_API_TOKEN} " https://api.github.com/repos/PaddlePaddle/PaddleNLP/pulls/${GIT_PR_ID} /reviews? per_page=10000`
20
+
21
+ function add_failed(){
22
+ failed_num=` expr $failed_num + 1`
23
+ echo_list=" ${echo_list[@]} $1 "
24
+ }
25
+
26
+ function check_approval(){
27
+ person_num=` echo $@ | awk ' {for (i=2;i<=NF;i++)print $i}' `
28
+ echo ${person_num}
29
+ APPROVALS=` echo ${approval_line} | python check_pr_approval.py $1 $person_num `
30
+ echo ${APPROVALS}
31
+ if [[ " ${APPROVALS} " == " FALSE" && " ${echo_line} " != " " ]]; then
32
+ add_failed " ${failed_num} . ${echo_line} "
33
+ fi
34
+ }
35
+
36
+ for file_name in ` git diff --numstat upstream/${AGILE_COMPILE_BRANCH} | awk ' {print $NF}' ` ; do
37
+ arr_file_name=(${file_name//// } )
38
+ dir1=${arr_file_name[0]}
39
+ dir2=${arr_file_name[1]}
40
+ dir3=${arr_file_name[2]}
41
+ dir4=${arr_file_name[3]}
42
+ echo " file_name:" ${file_name} , " dir1:" ${dir1} , " dir2:" ${dir2} ," dir3:" ${dir3} ," .xx:" ${file_name##* .}
43
+ if [[ ${file_name} =~ " paddlenlp/trainer/training_args.py" ]] || [[ ${file_name} =~ " paddlenlp/trainer/trainer.py" ]] || [[ ${file_name} =~ " llm/run_pretrain.py" ]] || [[ ${file_name} =~ " llm/finetune_generation.py" ]]; then
44
+ echo_line=" You must have two RD: one from(ZHUI, wawltor),one from(ForFishes,sneaxiy,zhiqiu) approval for the changes of training_args.py/trainer.py/run_pretrain.py "
45
+ check_approval 2 ZHUI wawltor ForFishes sneaxiy zhiqiu
46
+ elif [[ ${dir1} =~ " paddlenlp" ]]; then
47
+ if [[ ${dir2} =~ " transformers" ]]; then
48
+ echo_line=" You must have one RD (wawltor) approval for the changes of transformers "
49
+ check_approval 1 wawltor
50
+ elif [[ ${dir2} =~ " taskflow" ]]; then
51
+ echo_line=" You must have one RD (w5688414(Recommend),DesmonDay,wawltor) approval for the changes of taskflow"
52
+ check_approval 1 w5688414 DesmonDay wawltor
53
+ elif [[ ${dir3} =~ " trainer" ]]; then
54
+ echo_line=" You must have one RD (ZHUI(Recommend), wawltor) approval for the changes of trainer"
55
+ check_approval 1 ZHUI wawltor
56
+ elif [[ ${dir3} =~ " fast_transformer" ]] || [[ ${dir4} =~ " FasterTransformer" ]] ; then
57
+ echo_line=" You must have one RD (guoshengCS(Recommend), wawltor) approval for the changes of FT or FG"
58
+ check_approval 1 guoshengCS wawltor
59
+ elif [[ ${dir3} =~ " llama" ]] || [[ ${dir3} =~ " gpt" ]]; then
60
+ echo_line=" You must have two RD: one from(ZHUI, wawltor),one from(ForFishes,sneaxiy,zhiqiu) approval for the changes of llm/llama/auto_parallel/ "
61
+ check_approval 2 ZHUI wawltor ForFishes sneaxiy zhiqiu
62
+ fi
63
+ elif [[ ${dir1} =~ " model_zoo" ]]; then #
64
+ if [[ ${dir2} =~ " gpt-3" ]] ; then
65
+ echo_line=" You must have two RD: one from(ZHUI, wawltor),one from(ForFishes,sneaxiy,zhiqiu) approval for the changes of model_zoo/gpt-3 "
66
+ check_approval 2 ZHUI wawltor ForFishes sneaxiy zhiqiu
67
+ fi
68
+ elif [[ ${dir1} =~ " llm" ]]; then
69
+ if [[ ${dir3} =~ " auto_parallel" ]] ; then
70
+ echo_line=" You must have two RD: one from(ZHUI, wawltor),one from(ForFishes,sneaxiy,zhiqiu) approval for the changes of llm/llama/auto_parallel/ "
71
+ check_approval 2 ZHUI wawltor ForFishes sneaxiy zhiqiu
72
+ else
73
+ echo_line=" You must have one RD (wj-Mcat(Recommend), wawltor) approval for the changes of llm"
74
+ check_approval 1 wj-Mcat lugimzzz DesmonDay wawltor
75
+ fi
76
+ elif [[ ${dir1} =~ " tests" ]]; then
77
+ if [[ ${dir2} =~ " transformers" ]] ; then
78
+ echo_line=" You must have one RD (wawltor) approval for the changes of transformers "
79
+ check_approval 1 wawltor
80
+ elif [[ ${dir2} =~ " taskflow" ]] || [[ ${dir2} =~ " prompt" ]]; then
81
+ echo_line=" You must have one RD (w5688414(Recommend),, wawltor) approval for the changes of taskflow"
82
+ check_approval 1 w5688414 wawltor
83
+ elif [[ ${dir2} =~ " llm" ]] ; then
84
+ echo_line=" You must have one RD (wj-Mcat(Recommend), wawltor) approval for the changes of tests/llm/"
85
+ check_approval 1 wj-Mcat lugimzzz gongel wtmlon wawltor
86
+ elif [[ ${dir2} =~ " trainer" ]] ; then
87
+ echo_line=" You must have one RD (ZHUI(Recommend), wawltor) approval for the changes of trainer"
88
+ check_approval 1 ZHUI wawltor
89
+ elif [[ ${dir2} =~ " ops" ]] || [[ ${dir2} =~ " embedding" ]]; then
90
+ echo_line=" You must have one RD (guoshengCS(Recommend),, wawltor) approval for the changes of ops or embedding"
91
+ check_approval 1 guoshengCS wawltor
92
+ elif [[ ${dir2} =~ " model_zoo" ]] ; then
93
+ echo_line=" You must have one RD (wawltor(Recommend)) approval for the changes of model_zoo"
94
+ check_approval 1 wawltor
95
+ elif [[ ${dir2} =~ " cli" ]] || [[ ${dir2} =~ " generation" ]]; then
96
+ echo_line=" You must have one RD (wj-Mcat(Recommend), wawltor) approval for the changes of llm/generation"
97
+ check_approval 1 wj-Mcat wawltor
98
+ elif [[ ${dir2} =~ " test_tipc" ]]; then
99
+ echo_line=" You must have one RD (wj-Mcat(Recommend),lugimzzz, wawltor) approval for the changes of test_tipc"
100
+ check_approval 1 wj-Mcat lugimzzz wawltor
101
+ elif [[ ${dir2} =~ " dataaug" ]]|| [[ ${dir2} =~ " peft" ]]; then
102
+ echo_line=" You must have one RD (lugimzzz(Recommend), wawltor) approval for the changes of dataaug/peft"
103
+ check_approval 1 lugimzzz wawltor
104
+ elif [[ ${dir2} =~ " data" ]]|| [[ ${dir2} =~ " dataset" ]]; then
105
+ echo_line=" You must have one RD (KB-Ding(Recommend), wawltor) approval for the changes of data/dataset"
106
+ check_approval 1 KB-Ding wawltor
107
+ elif [[ ${dir2} =~ " layers" ]] || [[ ${dir2} =~ " metrics" ]] || [[ ${file_name} =~ " tests/llm/test_pretrain.py" ]]; then
108
+ echo_line=" You must have one RD (ZHUI(Recommend),DesmonDay,wawltor) approval for the changes of layers/metrics/tests/llm/test_pretrain.py"
109
+ check_approval 1 ZHUI DesmonDay wawltor
110
+ elif [[ ${dir2} =~ " utils" ]] ; then
111
+ echo_line=" You must have one RD (wawltor(Recommend)) approval for the changes of tests/utils"
112
+ check_approval 1 wawltor
113
+ fi
114
+ elif [[ ${dir1} =~ " pipelines" ]]; then
115
+ echo_line=" You must have one RD (w5688414(Recommend), wawltor) approval for the changes of pipelines"
116
+ check_approval 1 w5688414 junnyu wawltor
117
+ elif [[ ${dir1} =~ " ppdiffusers" ]]; then
118
+ echo_line=" You must have one RD (junnyu(Recommend), wawltor) approval for the changes of pipelines"
119
+ check_approval 1 w5688414 junnyu wawltor
120
+ else
121
+ continue
122
+ fi
123
+ done
124
+
125
+ if [ -n " ${echo_list} " ]; then
126
+ echo " **************************************************************"
127
+ echo " Please find RD for approval."
128
+ echo -e " ${echo_list[@]} "
129
+ echo " There are ${failed_num} approved errors."
130
+ echo " **************************************************************"
131
+ exit 1
132
+ else
133
+ echo " **************************************************************"
134
+ echo " CI APPROVAL PASSED."
135
+ echo " **************************************************************"
136
+ exit 0
137
+ fi
0 commit comments