Skip to content

Commit f6fb3f5

Browse files
committed
修改CI
1 parent 888fd94 commit f6fb3f5

File tree

1 file changed

+25
-54
lines changed

1 file changed

+25
-54
lines changed

ci_scripts/hooks/pre-doc-compile.sh

Lines changed: 25 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -100,89 +100,60 @@ copy_cached_file() {
100100
fi
101101
}
102102

103-
# Download API mapping files
104-
echo "INFO: Downloading API alias mapping file"
105-
if ! download_file "${API_ALIAS_MAPPING_URL}" "${TOOLS_DIR}/api_alias_mapping.json"; then
106-
echo "INFO: API alias mapping download failed. Checking for cached file..."
103+
# Function to handle download failure
104+
handle_download_failure() {
105+
local filename=$1
106+
echo "INFO: Download or Execute $filename failed. Checking for cached file..."
107107
if check_cached_file; then
108-
if ! copy_cached_file; then
108+
if copy_cached_file; then
109+
echo "INFO: Successfully copied cached file. Exiting."
110+
exit 0
111+
else
109112
echo "ERROR: Failed to copy cached file to target"
110113
exit 1
111114
fi
112115
else
113-
echo "ERROR: API alias mapping download failed and no cached file available"
116+
echo "ERROR: Download failed and no cached file available"
114117
exit 1
115118
fi
119+
}
120+
121+
# Download API alias mapping file
122+
echo "INFO: Downloading API alias mapping file"
123+
if ! download_file "${API_ALIAS_MAPPING_URL}" "${TOOLS_DIR}/api_alias_mapping.json"; then
124+
handle_download_failure "API alias mapping"
116125
fi
117126

127+
# Download API mapping file
118128
echo "INFO: Downloading API mapping file"
119129
if ! download_file "${API_MAPPING_URL}" "${TOOLS_DIR}/api_mapping.json"; then
120-
echo "INFO: API mapping download failed. Checking for cached file..."
121-
if check_cached_file; then
122-
if ! copy_cached_file; then
123-
echo "ERROR: Failed to copy cached file to target"
124-
exit 1
125-
fi
126-
else
127-
echo "ERROR: API mapping download failed and no cached file available"
128-
exit 1
129-
fi
130+
handle_download_failure "API mapping"
130131
fi
131132

133+
# Download global variable file
132134
echo "INFO: Downloading global variable file"
133135
if ! download_file "${GLOBAL_VAR_URL}" "${TOOLS_DIR}/global_var.py"; then
134-
echo "INFO: Global variable download failed. Checking for cached file..."
135-
if check_cached_file; then
136-
if ! copy_cached_file; then
137-
echo "ERROR: Failed to copy cached file to target"
138-
exit 1
139-
fi
140-
else
141-
echo "ERROR: Global variable download failed and no cached file available"
142-
exit 1
143-
fi
136+
handle_download_failure "Global variable"
144137
fi
145138

139+
# Download attribute mapping file
146140
echo "INFO: Downloading attribute mapping file"
147141
if ! download_file "${ATTRIBUTE_MAPPING_URL}" "${TOOLS_DIR}/attribute_mapping.json"; then
148-
echo "INFO: Attribute mapping download failed. Checking for cached file..."
149-
if check_cached_file; then
150-
if ! copy_cached_file; then
151-
echo "ERROR: Failed to copy cached file to target"
152-
exit 1
153-
fi
154-
else
155-
echo "ERROR: Attribute mapping download failed and no cached file available"
156-
exit 1
157-
fi
158-
fi
159-
160-
# Check if all files exist before proceeding
161-
if [ ! -f "${TOOLS_DIR}/api_alias_mapping.json" ] || \
162-
[ ! -f "${TOOLS_DIR}/api_mapping.json" ] || \
163-
[ ! -f "${TOOLS_DIR}/global_var.py" ] || \
164-
[ ! -f "${TOOLS_DIR}/attribute_mapping.json" ]; then
165-
echo "ERROR: One or more API mapping files are missing after download"
166-
echo "Missing files:"
167-
if [ ! -f "${TOOLS_DIR}/api_alias_mapping.json" ]; then echo " - api_alias_mapping.json"; fi
168-
if [ ! -f "${TOOLS_DIR}/api_mapping.json" ]; then echo " - api_mapping.json"; fi
169-
if [ ! -f "${TOOLS_DIR}/global_var.py" ]; then echo " - global_var.py"; fi
170-
if [ ! -f "${TOOLS_DIR}/attribute_mapping.json" ]; then echo " - attribute_mapping.json"; fi
171-
exit 1
142+
handle_download_failure "Attribute mapping"
172143
fi
173144

145+
# If we get here, all files were downloaded successfully
174146
echo "INFO: All API mapping files successfully downloaded"
175147

148+
# Run the remaining scripts
176149
echo "INFO: Running get_api_difference_info.py"
177150
if ! python "${APIMAPPING_ROOT}/tools/get_api_difference_info.py"; then
178-
echo "ERROR: get_api_difference_info.py failed. Please check the script."
179-
exit 1
151+
handle_download_failure "get_api_difference_info.py"
180152
fi
181153

182154
echo "INFO: Running generate_pytorch_api_mapping.py"
183155
if ! python "${APIMAPPING_ROOT}/tools/generate_pytorch_api_mapping.py"; then
184-
echo "ERROR: generate_pytorch_api_mapping.py failed. Please check the script."
185-
exit 1
156+
handle_download_failure "generate_pytorch_api_mapping.py"
186157
fi
187158

188159
# Create backup of generated file

0 commit comments

Comments
 (0)