Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Monitor print usage and skip code examples #54210

Merged
merged 11 commits into from
Jun 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions paddle/scripts/paddle_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 22 additions & 0 deletions tools/check_api_approvals.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 "**************************************************************"
Expand Down
6 changes: 0 additions & 6 deletions tools/check_file_diff_approvals.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down