check_api_approvals.sh 7.9 KB
Newer Older
1
#!/bin/bash
T
tianshuo78520a 已提交
2

S
seemingwang 已提交
3 4 5 6 7 8 9 10 11 12 13 14 15 16
# Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
# 
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# 
#     http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

T
tianshuo78520a 已提交
17

18 19 20 21 22
if [ -z ${BRANCH} ]; then
    BRANCH="develop"
fi

PADDLE_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}")/../" && pwd )"
23
approval_line=`curl -H "Authorization: token ${GITHUB_API_TOKEN}" https://api.github.com/repos/PaddlePaddle/Paddle/pulls/${GIT_PR_ID}/reviews?per_page=10000`
24 25
failed_num=0
echo_list=()
26 27 28 29

function check_approval(){
    person_num=`echo $@|awk '{for (i=2;i<=NF;i++)print $i}'`
    APPROVALS=`echo ${approval_line}|python ${PADDLE_ROOT}/tools/check_pr_approval.py $1 $person_num`
T
tianshuo78520a 已提交
30
    if [[ "${APPROVALS}" == "FALSE" && "${echo_line}" != "" ]]; then
31
        add_failed "${failed_num}. ${echo_line}"
32 33 34 35
    fi
}

function add_failed(){
36
    failed_num=`expr $failed_num + 1`
37
    echo_list="${echo_list[@]}$1"
38
}
39 40


R
Ren Wei (任卫) 已提交
41
api_params_diff=`python ${PADDLE_ROOT}/tools/check_api_compatible.py ${PADDLE_ROOT}/paddle/fluid/API_DEV.spec  ${PADDLE_ROOT}/paddle/fluid/API_PR.spec` 
T
tianshuo78520a 已提交
42
api_spec_diff=`python ${PADDLE_ROOT}/tools/diff_api.py ${PADDLE_ROOT}/paddle/fluid/API_DEV.spec.api  ${PADDLE_ROOT}/paddle/fluid/API_PR.spec.api` 
R
Ren Wei (任卫) 已提交
43
if [ "$api_spec_diff" != "" -o "${api_params_diff}" != "" ]; then
44
    echo_line="You must have one RD (XiaoguangHu01, jeff41404, lanxianghit or qingqing01) approval for API change.\n"
45
    echo_line="${echo_line} and one TPM approval for API change: \n"
46
    echo_line="${echo_line} jzhang533/ZhangJun, momozi1996/MoYan, dingjiaweiww/DingJiaWei, Ligoml/LiMengLiu for general APIs.\n"
47
    echo_line="${echo_line} liuTINA0907/LiuShuangQiao for distributed related APIs.\n"
C
Chen Long 已提交
48
    echo_line="${echo_line} leiqing1/LeiQing for inference related APIs.\n"
49

50
    check_approval 1 46782768 8555991 47554610 7845005
51
    check_approval 1 29231 79295425 23093488 39876205 65896652 54695910
T
tianshuo78520a 已提交
52 53 54
fi

api_doc_spec_diff=`python ${PADDLE_ROOT}/tools/diff_api.py ${PADDLE_ROOT}/paddle/fluid/API_DEV.spec.doc  ${PADDLE_ROOT}/paddle/fluid/API_PR.spec.doc` 
55
if [ "$api_doc_spec_diff" != "" ]; then
56
    echo_line="You must have  one TPM approval for API documents change: \n"
57
    echo_line="${echo_line} jzhang533/ZhangJun, momozi1996/MoYan, dingjiaweiww/DingJiaWei, Ligoml/LiMengLiu for general API docs.\n"
58
    echo_line="${echo_line} liuTINA0907/LiuShuangQiao for distributed related API docs.\n"
C
Chen Long 已提交
59
    echo_line="${echo_line} leiqing1/LeiQing for inference related API docs.\n"
60

61
    check_approval 1 29231 79295425 23093488 39876205 65896652 54695910
Z
Zeng Jinle 已提交
62 63
fi

64 65 66
api_src_spec_diff=`python ${PADDLE_ROOT}/tools/check_api_source_without_core_ops.py ${PADDLE_ROOT}/paddle/fluid/API_DEV.source.md5  ${PADDLE_ROOT}/paddle/fluid/API_PR.source.md5` 
if [ "$api_src_spec_diff" != "" ]; then
    echo_line="APIs without core.ops: \n${api_src_spec_diff}\n"
67
    echo_line="${echo_line}You must have one RD (JiabinYang (Recommend) or wanghuancoder, phlrain) approval for the api change for the opreator-related api without '_C_ops'.\n"
68
    echo_line="${echo_line}For more details, please click [https://github.com/PaddlePaddle/Paddle/wiki/paddle_api_development_manual.md]\n"
69
    check_approval 1 JiabinYang wanghuancoder phlrain
70 71
fi

72 73
op_type_spec_diff=`python ${PADDLE_ROOT}/tools/check_op_register_type.py ${PADDLE_ROOT}/paddle/fluid/OP_TYPE_DEV.spec  ${PADDLE_ROOT}/paddle/fluid/OP_TYPE_PR.spec`
if [ "$op_type_spec_diff" != "" ]; then
74 75
    echo_line="You must have one RD (Aurelius84 (Recommend) or zhhsplendid)approval for the data_type registration of new operator. More data_type of new operator should be registered in your PR. Please make sure that both float/double (or int/int64_t) have been registered.\n For more details, please click [https://github.com/PaddlePaddle/Paddle/wiki/Data-types-of-generic-Op-must-be-fully-registered].\n"
    check_approval 1 9301846 7913861
76
fi
T
tianshuo78520a 已提交
77

78 79 80 81 82 83
op_kernel_dtype_spec_diff=`python ${PADDLE_ROOT}/tools/check_op_kernel_same_dtypes.py ${PADDLE_ROOT}/paddle/fluid/OP_KERNEL_DTYPE_DEV.spec  ${PADDLE_ROOT}/paddle/fluid/OP_KERNEL_DTYPE_PR.spec`
if [ "$op_kernel_dtype_spec_diff" != "" ]; then
    echo_line="You have added or modified Op Kernel, resulting in inconsistent data types supported by the forward and backward kernels of the same op, such modifications are not allowed in principle. If it is a mismatch, please request one RD (lanxianghit (Recommend) or chenwhql) review and approve. Including the following kernels:\n${op_kernel_dtype_spec_diff}\n"
    check_approval 1 47554610 22561442
fi

84
op_desc_diff=`python ${PADDLE_ROOT}/tools/check_op_desc.py ${PADDLE_ROOT}/paddle/fluid/OP_DESC_DEV.spec  ${PADDLE_ROOT}/paddle/fluid/OP_DESC_PR.spec`
85 86
inference_approve=`echo "$op_desc_diff" | grep "need inference to review" -`
slim_approve=`echo "$op_desc_diff" | grep "need slim to review" -`
87
if [ "$op_desc_diff" != "" ]; then
88 89
    echo_line="You must have one RD (inference[ qingqing01(Recommend), cyj1986 ] or slim[ wanghaoshuang(Recommend), qingqing01 ] or train[ chenwhql(Recommend), phlrain ]) approval for the changes of Inputs/Output/Attrs of OPs. The changes of OPs will cause that the new version inference fails to load model trained by the old version. Please modify your code. \n For more details, please click [https://github.com/PaddlePaddle/Paddle/wiki/OP-Input-Output-Attribute-Compatibility-Modification].\n${op_desc_diff}\n"
    check_approval 1 39645414 7534971 7845005 22561442 43953930
90 91 92 93 94 95 96 97 98 99
fi

if [ "$slim_approve" != "" ]; then
    echo_line="You must have one RD (wanghaoshuang(Recommend), qingqing01) approval for the changes of `quant` Inputs/Output/Attrs of OPs. \n For more details, please click [https://github.com/PaddlePaddle/Paddle/wiki/OP-Input-Output-Attribute-Compatibility-Modification].\n${slim_approve}\n"
    check_approval 1 7534971 7845005
fi

if [ "$inference_approve" != "" ]; then
    echo_line="You must have one RD (Superjomn(Recommend), Shixiaowei02, cyj1986) approval for the changes of `def` Inputs/Output/Attrs of OPs. \n For more details, please click [https://github.com/PaddlePaddle/Paddle/wiki/OP-Input-Output-Attribute-Compatibility-Modification].\n${inference_approve}\n"
    check_approval 1 39645414 328693 39303645
100 101
fi

Z
Zeng Jinle 已提交
102 103 104 105
DEV_OP_USE_DEFAULT_GRAD_MAKER_SPEC=${PADDLE_ROOT}/paddle/fluid/op_use_default_grad_maker_DEV.spec
PR_OP_USE_DEFAULT_GRAD_MAKER_SPEC=${PADDLE_ROOT}/paddle/fluid/op_use_default_grad_maker_PR.spec
ADDED_OP_USE_DEFAULT_GRAD_MAKER=`python ${PADDLE_ROOT}/tools/diff_use_default_grad_op_maker.py ${DEV_OP_USE_DEFAULT_GRAD_MAKER_SPEC} ${PR_OP_USE_DEFAULT_GRAD_MAKER_SPEC}` 
if [ "${ADDED_OP_USE_DEFAULT_GRAD_MAKER}" != "" ]; then
T
Tao Luo 已提交
106 107
  echo_line="You must have one RD (zhiqiu (Recommend) or zhhsplendid) approval because you use DefaultGradOpMaker for ${ADDED_OP_USE_DEFAULT_GRAD_MAKER}, which manages the grad_op memory optimization.\n" 
  check_approval 1 6888866 7913861
Z
Zeng Jinle 已提交
108 109
fi

R
Ren Wei (任卫) 已提交
110

111
if [ -n "${echo_list}" ];then
112
  echo "**************************************************************"
T
tianshuo78520a 已提交
113
  echo "Please find RD for approval first, and then find TPM for approval."
114
  echo -e "${echo_list[@]}"
115
  echo "There are ${failed_num} approved errors."
116
  echo "**************************************************************"
Z
Zeng Jinle 已提交
117

118 119 120
  # L40 L48 L62 has fetch the result out, but there are splitted.
  if [ "${api_spec_diff}" != "" -o "${api_doc_spec_diff}" != "" ] ; then
    python ${PADDLE_ROOT}/tools/diff_api.py ${PADDLE_ROOT}/paddle/fluid/API_DEV.spec  ${PADDLE_ROOT}/paddle/fluid/API_PR.spec
121
  fi
R
Ren Wei (任卫) 已提交
122 123 124
  if [ "${api_params_diff}" != "" ] ; then
    echo "api_params_diff: ${api_params_diff}"
  fi 
125 126 127
  if [ "${op_type_spec_diff}" != "" ] ; then
    echo "op_type_spec_diff: ${op_type_spec_diff}"
  fi 
Z
zhangchunle 已提交
128
  exit 6
129
fi