未验证 提交 3f02b19c 编写于 作者: T tianshuo78520a 提交者: GitHub

Monitor print usage and skip code examples (#54210)

上级 1075d35d
......@@ -3124,20 +3124,20 @@ function build_document_preview() {
# origin name: example
function exec_samplecode_test() {
if [ -d "${PADDLE_ROOT}/build/pr_whl" ];then
pip install ${PADDLE_ROOT}/build/pr_whl/*.whl --force-reinstall
pip install ${PADDLE_ROOT}/build/pr_whl/*.whl
else
echo "WARNING: PR wheel is not found. Use develop wheel !!!"
pip install ${PADDLE_ROOT}/build/python/dist/*.whl --force-reinstall
pip install ${PADDLE_ROOT}/build/python/dist/*.whl
fi
python -c "import paddle;print(paddle.__version__);paddle.version.show()"
cd ${PADDLE_ROOT}/tools
if [ "$1" = "cpu" ] ; then
python sampcd_processor.py cpu; example_error=$?
python sampcd_processor.py --debug cpu; example_error=$?
elif [ "$1" = "gpu" ] ; then
SAMPLE_CODE_EXEC_THREADS=${SAMPLE_CODE_EXEC_THREADS:-2}
python sampcd_processor.py --threads=${SAMPLE_CODE_EXEC_THREADS} gpu; example_error=$?
python sampcd_processor.py --threads=${SAMPLE_CODE_EXEC_THREADS} --debug gpu; example_error=$?
fi
if [ "$example_error" != "0" ];then
echo "Code instance execution failed" >&2
......
......@@ -116,6 +116,28 @@ if [ "${ADDED_OP_USE_DEFAULT_GRAD_MAKER}" != "" ]; then
check_approval 1 6888866 7913861
fi
OUTPUT_LOG=`git diff -U0 upstream/$BRANCH | grep "^+" | grep -Ew "print|printf|fprintf|std::cout" || true`
if [ "$OUTPUT_LOG" != "" ];then
git diff -U0 upstream/$BRANCH |grep "^+" | grep -Ew "print|printf|fprintf|std::cout"|sed 's#[ ][ ]##g'|sed 's#+##g' >/tmp/print.txt
samplecode=`find tools/samplecode_temp -type f || true`
sample_status=0
if [ "$samplecode" != "" ];then
cat `find tools/samplecode_temp -type f` >/tmp/samplecode.txt
sed -i s#\"#\'#g /tmp/samplecode.txt
while read line
do
code_in=`grep "$line" /tmp/samplecode.txt || true`
if [ "$code_in" == "" ];then
sample_status=1
fi
done</tmp/print.txt
fi
if [ "$sample_status" == 1 ] || [ "$samplecode" == "" ] ;then
echo_line="print or std::cout is not recommended for direct use, please use logging or VLOG. If it is necessary to use, please contact tianshuo78520a (Recommend) or zhangbo9674 review and approve.\n"
check_approval 1 tianshuo78520a zhangbo9674
fi
fi
if [ -n "${echo_list}" ];then
echo "**************************************************************"
......
......@@ -341,12 +341,6 @@ if [ "${INVALID_UNITTEST_ASSERT_CHECK}" != "" ] && [ "${GIT_PR_ID}" != "" ]; the
check_approval 1 16605440 6836917
fi
OUTPUT_LOG=`echo "$ALL_ADDED_LINES" | grep -Ew "print|printf|fprintf|std::cout" || true`
if [ "$OUTPUT_LOG" != "" ];then
echo_line="print or std::cout is not recommended for direct use, please use loggin or glog. If it is necessary to use, please contact tianshuo78520a (Recommend) or zhangbo9674 review and approve.\n"
check_approval 1 tianshuo78520a zhangbo9674
fi
HAS_MODIFIED_PHI_FILES=`git diff --name-only upstream/$BRANCH | grep "paddle/phi/" || true`
PHI_INCLUDE_FLUID_FILES=""
for CHANGE_FILE in ${HAS_MODIFIED_PHI_FILES}; do
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册