Skip to content

Commit 23c111e

Browse files
committed
test=document_fix coverage failed
1 parent 40c7f74 commit 23c111e

File tree

5 files changed

+81
-31
lines changed

5 files changed

+81
-31
lines changed

.github/workflows/_Coverage.yml

+11-5
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ jobs:
218218
needs: build
219219
if: needs.build.outputs.can-skip != 'true'
220220
runs-on:
221-
group: BD_BJ_v100
221+
group: BD_BJ-V100
222222
steps:
223223
- name: Download paddle.tar.gz and update test branch
224224
run: |
@@ -315,15 +315,13 @@ jobs:
315315
fi
316316
'
317317
318-
- name: Check coverage data
318+
- name: Generate coverage information
319319
run: |
320320
docker exec -t ${{ env.container_name }} /bin/bash -c '
321321
source ~/.bashrc
322322
unset GREP_OPTIONS
323323
source ${{ github.workspace }}/../../../proxy
324324
source ${ci_scripts}/utils.sh; check_coverage
325-
COVERAGE_EXIT_CODE=$?
326-
echo "COVERAGE_EXIT_CODE=${COVERAGE_EXIT_CODE}" >> ${{ github.env }}
327325
'
328326
329327
- name: Upload coverage report
@@ -333,12 +331,20 @@ jobs:
333331

334332
- name: Determine whether the coverage rate reaches 90%
335333
run: |
334+
docker exec -t ${{ env.container_name }} /bin/bash -c '
335+
source ~/.bashrc
336+
unset GREP_OPTIONS
337+
source ${{ github.workspace }}/../../../proxy
338+
source ${ci_scripts}/utils.sh
339+
bash $ci_scripts/coverage_judge.sh
340+
COVERAGE_EXIT_CODE=$?
336341
if [ "${{ env.COVERAGE_EXIT_CODE }}" -ne 0 ]; then
337-
echo "Coverage check failed, unit test has passed, please do not rerun, check whether the code is fully executed and recommit."
342+
echo "Coverage check failed, unit tests have all passed, please do not rerun, check whether the code has been fully executed and recommit."
338343
exit ${{ env.COVERAGE_EXIT_CODE }}
339344
else
340345
echo "Coverage passed"
341346
fi
347+
'
342348
343349
- name: Terminate and delete the container
344350
if: always()

ci/coverage_info.sh

-26
Original file line numberDiff line numberDiff line change
@@ -218,29 +218,3 @@ python ${PADDLE_ROOT}/ci/coverage_diff.py python-coverage-diff.info python-git-d
218218
mv -f python-coverage-diff.tmp python-coverage-diff.info
219219

220220
cp python-coverage-diff.info coverage_files
221-
222-
# assert coverage lines
223-
224-
echo "Assert Diff Coverage"
225-
226-
python ${PADDLE_ROOT}/tools/coverage/coverage_lines.py coverage-diff.info 0.9 || COVERAGE_LINES_ASSERT=1
227-
228-
echo "Assert Python Diff Coverage"
229-
230-
if [ ${WITH_XPU:-OFF} == "ON" ]; then
231-
echo "XPU has no python coverage!"
232-
else
233-
if [[ "${NO_PYTHON_COVERAGE_DATA}" != "1" ]];then
234-
python ${PADDLE_ROOT}/tools/coverage/coverage_lines.py python-coverage-diff.info 0.9 || PYTHON_COVERAGE_LINES_ASSERT=1
235-
fi
236-
fi
237-
238-
if [ "$COVERAGE_LINES_ASSERT" = "1" ] || [ "$PYTHON_COVERAGE_LINES_ASSERT" = "1" ]; then
239-
echo "exit 9" > /tmp/paddle_coverage.result
240-
python ${PADDLE_ROOT}/tools/get_pr_title.py skip_coverage_check && NOT_CHECK_COVERAGE_PR=1
241-
if [[ "${NOT_CHECK_COVERAGE_PR}" = "1" ]];then
242-
echo "Skip coverage check in the PR-CI-Coverage pipeline."
243-
exit 0
244-
fi
245-
exit 9
246-
fi

ci/coverage_judge.sh

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Copyright (c) 2025 PaddlePaddle Authors. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# assert coverage lines
16+
17+
echo "Assert Diff Coverage"
18+
cd ${PADDLE_ROOT}/build
19+
20+
python ${PADDLE_ROOT}/tools/coverage/coverage_lines.py coverage-diff.info 0.9 || COVERAGE_LINES_ASSERT=1
21+
22+
echo "Assert Python Diff Coverage"
23+
24+
if [ ${WITH_XPU:-OFF} == "ON" ]; then
25+
echo "XPU has no python coverage!"
26+
else
27+
if [[ "${NO_PYTHON_COVERAGE_DATA}" != "1" ]];then
28+
python ${PADDLE_ROOT}/tools/coverage/coverage_lines.py python-coverage-diff.info 0.9 || PYTHON_COVERAGE_LINES_ASSERT=1
29+
fi
30+
fi
31+
32+
if [ "$COVERAGE_LINES_ASSERT" = "1" ] || [ "$PYTHON_COVERAGE_LINES_ASSERT" = "1" ]; then
33+
echo "exit 9" > /tmp/paddle_coverage.result
34+
python ${PADDLE_ROOT}/tools/get_pr_title.py skip_coverage_check && NOT_CHECK_COVERAGE_PR=1
35+
if [[ "${NOT_CHECK_COVERAGE_PR}" = "1" ]];then
36+
echo "Skip coverage check in the PR-CI-Coverage pipeline."
37+
exit 0
38+
fi
39+
exit 9
40+
fi

paddle/fluid/framework/attribute.cc

+28
Original file line numberDiff line numberDiff line change
@@ -318,4 +318,32 @@ void CanonicalizeScalarAttrs(const proto::OpProto& op_proto,
318318
}
319319
}
320320
}
321+
322+
void CanonicalizeScalarAttrs_copy(const proto::OpProto& op_proto,
323+
AttributeMap* attrs) {
324+
PADDLE_ENFORCE_NOT_NULL(
325+
attrs, common::errors::InvalidArgument("attrs can not be nullptr"));
326+
for (auto& attr : op_proto.attrs()) {
327+
proto::AttrType attr_type = attr.type();
328+
const std::string& attr_name = attr.name();
329+
auto it = attrs->find(attr_name);
330+
if (it == attrs->end()) {
331+
continue;
332+
}
333+
proto::AttrType actual_attr_type = AttrTypeID(it->second);
334+
if (actual_attr_type == attr_type) {
335+
continue;
336+
}
337+
if (actual_attr_type == proto::AttrType::VAR ||
338+
actual_attr_type == proto::AttrType::VARS) {
339+
continue; // VAR& VARS are not proper attribute
340+
}
341+
if (attr_type == proto::AttrType::SCALAR) {
342+
it->second = Attribute(MakeScalarFromAttribute(it->second));
343+
} else if (attr_type == proto::AttrType::SCALARS) {
344+
it->second = Attribute(MakeScalarsFromAttribute(it->second));
345+
}
346+
}
347+
}
348+
321349
} // namespace paddle::framework

paddle/fluid/framework/attribute.h

+2
Original file line numberDiff line numberDiff line change
@@ -357,5 +357,7 @@ TEST_API std::vector<paddle::experimental::Scalar> MakeScalarsFromAttribute(
357357
const Attribute& v);
358358
void CanonicalizeScalarAttrs(const proto::OpProto& op_proto,
359359
AttributeMap* attrs);
360+
void CanonicalizeScalarAttrs_copy(const proto::OpProto& op_proto,
361+
AttributeMap* attrs);
360362
} // namespace framework
361363
} // namespace paddle

0 commit comments

Comments
 (0)