@@ -8,6 +8,9 @@ DOCROOT=${FLUIDDOCDIR}/docs
88APIMAPPING_ROOT=${DOCROOT} /guides/model_convert/convert_from_pytorch
99TOOLS_DIR=${APIMAPPING_ROOT} /tools
1010
11+ TARGET_FILE=${APIMAPPING_ROOT} /pytorch_api_mapping_cn.md
12+ CACHED_FILE=${APIMAPPING_ROOT} /cached_pytorch_api_mapping_cn.md
13+
1114# Create tools directory if not exists
1215if [ ! -d " ${TOOLS_DIR} " ]; then
1316 echo " INFO: Creating tools directory at ${TOOLS_DIR} "
4750
4851# Handle failure: copy cached file and exit
4952handle_failure () {
50- local cached_file=" ${APIMAPPING_ROOT} /cached_pytorch_api_mapping_cn.md"
51- local target_file=" ${APIMAPPING_ROOT} /pytorch_api_mapping_cn.md"
52-
53- if [ -f " $cached_file " ]; then
54- echo " INFO: Copying cached file to target: $cached_file -> $target_file "
55- cp " $cached_file " " $target_file "
56- echo " INFO: Successfully copied cached file to $target_file "
53+ if [ -f " $CACHED_FILE " ]; then
54+ echo " INFO: Copying cached file to target: $CACHED_FILE -> $TARGET_FILE "
55+ cp " $CACHED_FILE " " $TARGET_FILE "
56+ echo " INFO: Successfully copied cached file to $TARGET_FILE "
5757 exit 0
5858 else
59- echo " ERROR: Cached file not found at $cached_file "
59+ echo " ERROR: Cached file not found at $CACHED_FILE "
6060 exit 1
6161 fi
6262}
@@ -80,7 +80,7 @@ download_file() {
8080 return 0
8181 else
8282 echo " WARNING: Failed to download ${filename} from ${url} (attempt $retry_count )"
83- sleep 2 # Wait for 2 seconds before next retry
83+ sleep 3 # Wait for 2 seconds before next retry
8484 fi
8585 done
8686
@@ -99,48 +99,45 @@ echo "INFO: All API mapping files successfully downloaded"
9999# Run the remaining scripts with failure handling
100100echo " INFO: Running get_api_difference_info.py"
101101if ! python " ${APIMAPPING_ROOT} /tools/get_api_difference_info.py" ; then
102+ echo " ERROR: Failed to run get_api_difference_info.py"
102103 handle_failure
103104fi
104105
105106echo " INFO: Running generate_pytorch_api_mapping.py"
106107if ! python " ${APIMAPPING_ROOT} /tools/generate_pytorch_api_mapping.py" ; then
108+ echo " ERROR: Failed to run generate_pytorch_api_mapping.py"
107109 handle_failure
108110fi
109111
110112# Create backup of generated file
111- BACKUP_FILE=" ${APIMAPPING_ROOT} /cached_pytorch_api_mapping_cn.md"
112- GENERATED_FILE=" ${APIMAPPING_ROOT} /pytorch_api_mapping_cn.md"
113-
114- if [ -f " $GENERATED_FILE " ]; then
115- echo " INFO: Generated API mapping file successfully created at $GENERATED_FILE "
116- echo " INFO: Creating backup file: $BACKUP_FILE "
117- cp " $GENERATED_FILE " " $BACKUP_FILE "
118- echo " INFO: Successfully created backup file at $BACKUP_FILE "
113+ if [ -f " $TARGET_FILE " ]; then
114+ echo " INFO: Target API mapping file found successfully at $TARGET_FILE "
115+ echo " INFO: Copying target file to cached: $TARGET_FILE -> $CACHED_FILE "
116+ cp " $TARGET_FILE " " $CACHED_FILE "
117+ echo " INFO: Successfully created cached file at $CACHED_FILE "
119118else
120- echo " ERROR: Generated API mapping file not found at $GENERATED_FILE "
119+ echo " ERROR: Target API mapping file not found at $TARGET_FILE "
121120 handle_failure
122121fi
123122
124- python " ${APIMAPPING_ROOT} /tools/validate_api_difference_format.py"
125123
126- # 获取上一条命令的退出状态码
127- exit_code=$?
128124
129- # 根据退出状态码决定后续操作
130- if [ $exit_code -eq 0 ] ; then
131- echo " API DIFFERENCE FORMAT VALIDATE SUCCESS! "
132- # 在这里继续添加您需要执行的命令
125+ echo " INFO: Running validate_api_difference_format.py "
126+ python " ${APIMAPPING_ROOT} /tools/validate_api_difference_format.py "
127+ if [ $? -eq 0 ] ; then
128+ echo " INFO: API DIFFERENCE FORMAT VALIDATE SUCCESS! "
133129else
134- echo " ERROR: API DIFFERENCE FORMAT VALIDATE FAILURE! error code: $exit_code " >&2
130+ echo " ERROR: API DIFFERENCE FORMAT VALIDATE FAILURE!"
135131 exit 1
136132fi
137133
138- python " ${APIMAPPING_ROOT} /tools/validate_pytorch_api_mapping.py" --skip-url-check
139- exit_code=$?
140134
141- if [ $exit_code -eq 0 ]; then
142- echo " PYTORCH API MAPPING VALIDATE SUCCESS!"
135+ echo " INFO: Running validate_pytorch_api_mapping.py"
136+ python " ${APIMAPPING_ROOT} /tools/validate_pytorch_api_mapping.py" --skip-url-check --file " ${TARGET_FILE} "
137+ if [ $? -eq 0 ]; then
138+ echo " INFO: PYTORCH API MAPPING VALIDATE SUCCESS!"
139+ exit 0
143140else
144- echo " ERROR: PYTORCH API MAPPING VALIDATE FAILURE! error code: $exit_code " >&2
141+ echo " ERROR: PYTORCH API MAPPING VALIDATE FAILURE!"
145142 exit 1
146143fi
0 commit comments