@@ -13,6 +13,21 @@ export PYTHONPATH=${GRAPH_NET_EXTRACT_WORKSPACE}:$PYTHONPATH
1313
1414[ -z " $CUDA_VISIBLE_DEVICES " ] && CUDA_VISIBLE_DEVICES=" 0"
1515
16+ function check_paths_without_spaces() {
17+ LOG " [INFO] Checking for spaces in modified file paths..."
18+ git config --global --add safe.directory " *"
19+ mapfile -t MODIFIED_FILES < <( git diff --name-only develop | grep -E " \bsamples\b/|\bpaddle_samples\b/" )
20+
21+ for file in " ${MODIFIED_FILES[@]} " ; do
22+ if [[ " ${file} " == * " " * ]]; then
23+ LOG " [FATAL] File path contains spaces, which is not allowed. Please rename the file or directory."
24+ LOG " [FATAL] Offending path: '${file} '"
25+ exit 1
26+ fi
27+ done
28+ LOG " [INFO] No spaces found in file paths. Continuing..."
29+ }
30+
1631function prepare_torch_env() {
1732 git config --global --add safe.directory " *"
1833 num_changed_samples=$( git diff --name-only develop | grep -E " \bsamples\b/(.*\.py|.*\.json)" | wc -l)
@@ -62,18 +77,27 @@ function check_torch_validation() {
6277 MODIFIED_MODEL_PATHS[${# MODIFIED_MODEL_PATHS[@]} ]=$model_path
6378 done
6479 MODIFIED_MODEL_PATHS=($( echo ${MODIFIED_MODEL_PATHS[@]} | tr ' ' ' \n' | sort | uniq) )
65- LOG " [INFO] Validation of these models will run: ${MODIFIED_MODEL_PATHS[@]} "
80+ local total_models=${# MODIFIED_MODEL_PATHS[@]}
81+ if [ ${total_models} -eq 0 ]; then
82+ LOG " [INFO] No changed torch sample models detected. Skip torch validation."
83+ return 0
84+ fi
85+ LOG " [INFO] Validation will run on ${total_models} torch model path(s):"
86+ printf " - %s\n" " ${MODIFIED_MODEL_PATHS[@]} " >&2
6687 fail_name=()
6788 for model_path in ${MODIFIED_MODEL_PATHS[@]}
6889 do
6990 python -m graph_net.torch.validate --model-path ${GRAPH_NET_EXTRACT_WORKSPACE} /${model_path} --graph-net-samples-path ${GRAPH_NET_EXTRACT_WORKSPACE} /samples >&2
7091 [ $? -ne 0 ] && fail_name[${# fail_name[@]} ]=" ${model_path} "
7192 done
72- if [ ${# fail_name[@]} -ne 0 ]
73- then
74- LOG " [FATAL] Failed tests: ${fail_name[@]} "
75- echo ${fail_name[@]}
93+ local failed_cnt=${# fail_name[@]}
94+ if [ ${failed_cnt} -ne 0 ]; then
95+ LOG " [FATAL] Failed tests (${failed_cnt} /${total_models} ):"
96+ printf " - %s\n" " ${fail_name[@]} " >&2
97+ printf " %s\n" " ${fail_name[@]} "
7698 exit -1
99+ else
100+ LOG " [INFO] All torch sample validations passed (0 failures / ${total_models} total)."
77101 fi
78102}
79103
@@ -87,18 +111,27 @@ function check_paddle_validation() {
87111 MODIFIED_MODEL_PATHS[${# MODIFIED_MODEL_PATHS[@]} ]=$model_path
88112 done
89113 MODIFIED_MODEL_PATHS=($( echo ${MODIFIED_MODEL_PATHS[@]} | tr ' ' ' \n' | sort | uniq) )
90- LOG " [INFO] Validation of these models will run: ${MODIFIED_MODEL_PATHS[@]} "
114+ local total_models=${# MODIFIED_MODEL_PATHS[@]}
115+ if [ ${total_models} -eq 0 ]; then
116+ LOG " [INFO] No changed paddle sample models detected. Skip paddle validation."
117+ return 0
118+ fi
119+ LOG " [INFO] Validation will run on ${total_models} paddle model path(s):"
120+ printf " - %s\n" " ${MODIFIED_MODEL_PATHS[@]} " >&2
91121 fail_name=()
92122 for model_path in ${MODIFIED_MODEL_PATHS[@]}
93123 do
94124 python -m graph_net.paddle.validate --model-path ${GRAPH_NET_EXTRACT_WORKSPACE} /${model_path} --graph-net-samples-path ${GRAPH_NET_EXTRACT_WORKSPACE} /samples >&2
95125 [ $? -ne 0 ] && fail_name[${# fail_name[@]} ]=" ${model_path} "
96126 done
97- if [ ${# fail_name[@]} -ne 0 ]
98- then
99- LOG " [FATAL] Failed tests: ${fail_name[@]} "
100- echo ${fail_name[@]}
127+ local failed_cnt=${# fail_name[@]}
128+ if [ ${failed_cnt} -ne 0 ]; then
129+ LOG " [FATAL] Failed tests (${failed_cnt} /${total_models} ):"
130+ printf " - %s\n" " ${fail_name[@]} " >&2
131+ printf " %s\n" " ${fail_name[@]} "
101132 exit -1
133+ else
134+ LOG " [INFO] All paddle sample validations passed (0 failures / ${total_models} total)."
102135 fi
103136}
104137
@@ -109,13 +142,17 @@ function summary_problems() {
109142 then
110143 LOG " [FATAL] ============================================"
111144 LOG " [FATAL] Summary problems:"
112- LOG " [FATAL] === API test error - Please fix the failed API tests accroding to fatal log:"
113- LOG " [FATAL] $check_validation_info "
145+ local failed_list=($check_validation_info )
146+ local failed_count=${# failed_list[@]}
147+ LOG " [FATAL] === API test error (${failed_count} failure(s)) - Please fix the failed API tests according to fatal log:"
148+ LOG " [FATAL] Failed model path(s):"
149+ printf " - %s\n" " ${failed_list[@]} " >&2
114150 exit $check_validation_code
115151 fi
116152}
117153
118154function main() {
155+ check_paths_without_spaces
119156 prepare_torch_env
120157 check_validation_info=$( check_torch_validation)
121158 check_validation_code=$?
0 commit comments