Skip to content

Commit 11a456f

Browse files
committed
Update ci to be compatible with paddle framework
1 parent dcaa805 commit 11a456f

File tree

2 files changed

+68
-17
lines changed

2 files changed

+68
-17
lines changed

graph_net/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
import graph_net.torch as torch

tools/ci/check_validate.sh

Lines changed: 68 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,51 @@ export PYTHONPATH=${GRAPH_NET_EXTRACT_WORKSPACE}:$PYTHONPATH
1313

1414
[ -z "$CUDA_VISIBLE_DEVICES" ] && CUDA_VISIBLE_DEVICES="0"
1515

16-
function prepare_env() {
16+
function prepare_torch_env() {
1717
git config --global --add safe.directory "*"
1818
num_changed_samples=$(git diff --name-only develop | grep -E "samples/(.*\.py|.*\.json)" | wc -l)
19-
if [ ${num_changed_samples} -eq 0 ]; then
19+
num_changed_paddle_samples=$(git diff --name-only develop | grep -E "samples/paddle/(.*\.py|.*\.json)" | wc -l)
20+
num_changed_torch_samples=$((num_changed_samples - num_changed_paddle_samples))
21+
if [ ${num_changed_torch_samples} -ne 0 ]; then
22+
LOG "[INFO] Device Id: ${CUDA_VISIBLE_DEVICES}"
23+
# Update pip
24+
LOG "[INFO] Update pip ..."
25+
env http_proxy="" https_proxy="" pip install -U pip > /dev/null
26+
[ $? -ne 0 ] && LOG "[FATAL] Update pip failed!" && exit -1
27+
# install torch
28+
pip install torch==2.6.0 --index-url https://download.pytorch.org/whl/cu118 > /dev/null
29+
[ $? -ne 0 ] && LOG "[FATAL] Install torch2.6.0 failed!" && exit -1
30+
else
2031
python ${GRAPH_NET_EXTRACT_WORKSPACE}/tools/count_sample.py
21-
LOG "[INFO] This pull request doesn't change any samples, skip the CI."
22-
exit 0
32+
LOG "[INFO] This pull request doesn't change any torch samples, skip the CI."
2333
fi
34+
}
2435

25-
LOG "[INFO] Device Id: ${CUDA_VISIBLE_DEVICES}"
26-
# Update pip
27-
LOG "[INFO] Update pip ..."
28-
env http_proxy="" https_proxy="" pip install -U pip > /dev/null
29-
[ $? -ne 0 ] && LOG "[FATAL] Update pip failed!" && exit -1
30-
# install torch
31-
pip install torch==2.7.0 --index-url https://download.pytorch.org/whl/cu118
36+
function prepare_paddle_env() {
37+
git config --global --add safe.directory "*"
38+
num_changed_paddle_samples=$(git diff --name-only develop | grep -E "samples/paddle/(.*\.py|.*\.json)" | wc -l)
39+
if [ ${num_changed_paddle_samples} -ne 0 ]; then
40+
LOG "[INFO] Device Id: ${CUDA_VISIBLE_DEVICES}"
41+
# Update pip
42+
LOG "[INFO] Update pip ..."
43+
env http_proxy="" https_proxy="" pip install -U pip > /dev/null
44+
[ $? -ne 0 ] && LOG "[FATAL] Update pip failed!" && exit -1
45+
# install paddle
46+
pip uninstall torch==2.7.0 --yes
47+
LOG "[INFO] Install paddlepaddle-develop ..."
48+
python -m pip install --pre paddlepaddle-gpu -i https://www.paddlepaddle.org.cn/packages/nightly/cu118/ > /dev/null
49+
[ $? -ne 0 ] && LOG "[FATAL] Install paddlepaddle-develop failed!" && exit -1
50+
python -c "import paddle; print('[PaddlePaddle Commit]', paddle.version.commit)"
51+
else
52+
python ${GRAPH_NET_EXTRACT_WORKSPACE}/tools/count_sample.py
53+
LOG "[INFO] This pull request doesn't change any paddle samples, skip the CI."
54+
fi
3255
}
3356

34-
function check_validation() {
35-
LOG "[INFO] Start run validate for changed samples ..."
57+
function check_torch_validation() {
58+
LOG "[INFO] Start run validate for changed torch samples ..."
3659
MODIFIED_MODEL_PATHS=()
37-
for file in $(git diff --name-only develop | grep -E "samples/(.*\.py|.*\.json)")
60+
for file in $(git diff --name-only develop | grep -E "samples/(.*\.py|.*\.json)" | grep -v "samples/paddle/")
3861
do
3962
LOG "[INFO] Found ${file} modified."
4063
model_path=$(dirname ${file})
@@ -56,6 +79,31 @@ function check_validation() {
5679
fi
5780
}
5881

82+
function check_paddle_validation() {
83+
LOG "[INFO] Start run validate for changed paddle samples ..."
84+
MODIFIED_MODEL_PATHS=()
85+
for file in $(git diff --name-only develop | grep -E "samples/paddle/(.*\.py|.*\.json)")
86+
do
87+
LOG "[INFO] Found ${file} modified."
88+
model_path=$(dirname ${file})
89+
MODIFIED_MODEL_PATHS[${#MODIFIED_MODEL_PATHS[@]}]=$model_path
90+
done
91+
MODIFIED_MODEL_PATHS=($(echo ${MODIFIED_MODEL_PATHS[@]} | tr ' ' '\n' | sort | uniq))
92+
LOG "[INFO] Validation of these models will run: ${MODIFIED_MODEL_PATHS[@]}"
93+
fail_name=()
94+
for model_path in ${MODIFIED_MODEL_PATHS[@]}
95+
do
96+
python -m graph_net.paddle.validate --model-path ${GRAPH_NET_EXTRACT_WORKSPACE}/${model_path} --graph-net-samples-path ${GRAPH_NET_EXTRACT_WORKSPACE}/samples >&2
97+
[ $? -ne 0 ] && fail_name[${#fail_name[@]}]="${model_path}"
98+
done
99+
if [ ${#fail_name[@]} -ne 0 ]
100+
then
101+
LOG "[FATAL] Failed tests: ${fail_name[@]}"
102+
echo ${fail_name[@]}
103+
exit -1
104+
fi
105+
}
106+
59107
function summary_problems() {
60108
local check_validation_code=$1
61109
local check_validation_info=$2
@@ -70,8 +118,12 @@ function summary_problems() {
70118
}
71119

72120
function main() {
73-
prepare_env
74-
check_validation_info=$(check_validation)
121+
prepare_torch_env
122+
check_validation_info=$(check_torch_validation)
123+
check_validation_code=$?
124+
summary_problems $check_validation_code "$check_validation_info"
125+
prepare_paddle_env
126+
check_validation_info=$(check_paddle_validation)
75127
check_validation_code=$?
76128
summary_problems $check_validation_code "$check_validation_info"
77129
python ${GRAPH_NET_EXTRACT_WORKSPACE}/tools/count_sample.py

0 commit comments

Comments
 (0)