Skip to content

Commit 22a5cb5

Browse files
committed
Merge branch 'develop' into feature/my-cool-stuff
2 parents 3bc75a4 + 998ad18 commit 22a5cb5

File tree

1,281 files changed

+3392
-6067
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,281 files changed

+3392
-6067
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# Paddle API Docs
2-
docs/api/paddle @jzhang533 @sunzhongkai588 @mattheliu @Echo-Nie
2+
docs/api/paddle @jzhang533 @sunzhongkai588 @mattheliu @Echo-Nie @ooooo-create

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
# virtualenv
77
venv/
88
ENV/
9+
.venv/
910

1011
# Compiled Python files
1112
__pycache__/

.lycheeignore

Lines changed: 0 additions & 4 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ English | [简体中文](./README_cn.md) | [日本語](./README_ja.md)
55

66
Source files for contents presented at [PaddlePaddle documentation](https://www.paddlepaddle.org.cn/documentation/docs/zh/guides/index_cn.html).
77

8-
Note: English version API docs are generaly docstrings in [PaddlePaddle/Paddle](https://github.com/PaddlePaddle/Paddle), documents for [other PaddlePaddle projects](https://www.paddlepaddle.org.cn/overview) are being managed in their respective ways.
8+
Note: English version API docs are generally docstrings in [PaddlePaddle/Paddle](https://github.com/PaddlePaddle/Paddle), documents for [other PaddlePaddle projects](https://www.paddlepaddle.org.cn/overview) are being managed in their respective ways.
99

1010
## Codebase structure
1111

_typos.toml

Lines changed: 2 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ extend-ignore-re = [
1818
CANN = "CANN"
1919
Clas = "Clas"
2020
arange = "arange"
21+
unsupport = "unsupport"
22+
Nervana = "Nervana"
2123

2224
# These words need to be fixed
2325
Accuray = "Accuray"
@@ -26,30 +28,12 @@ Archetecture = "Archetecture"
2628
Asynchoronous = "Asynchoronous"
2729
Attrbute = "Attrbute"
2830
Attribtue = "Attribtue"
29-
Bounary = "Bounary"
30-
Classfication = "Classfication"
31-
Comparision = "Comparision"
32-
Contructing = "Contructing"
3331
Creenshot = "Creenshot"
34-
DELCARE = "DELCARE"
35-
Dateset = "Dateset"
36-
Discription = "Discription"
37-
Distrbuted = "Distrbuted"
38-
Driect = "Driect"
3932
Embeddding = "Embeddding"
4033
Embeding = "Embeding"
4134
Engish = "Engish"
42-
Fasle = "Fasle"
43-
Flase = "Flase"
44-
Generater = "Generater"
45-
Gloabal = "Gloabal"
46-
Imporvement = "Imporvement"
47-
Interfce = "Interfce"
48-
Kernal = "Kernal"
4935
Learing = "Learing"
5036
Moible = "Moible"
51-
Nervana = "Nervana"
52-
Numberic = "Numberic"
5337
Operaton = "Operaton"
5438
Optimizaing = "Optimizaing"
5539
Optimzier = "Optimzier"
@@ -69,41 +53,10 @@ Similarily = "Similarily"
6953
Simle = "Simle"
7054
Sovler = "Sovler"
7155
Successed = "Successed"
72-
Tansformer = "Tansformer"
73-
Tenosr = "Tenosr"
74-
Traning = "Traning"
75-
Transfomed = "Transfomed"
76-
Tthe = "Tthe"
77-
Ture = "Ture"
78-
Useage = "Useage"
79-
Varialble = "Varialble"
80-
Varible = "Varible"
81-
Varient = "Varient"
82-
Wether = "Wether"
8356
accordding = "accordding"
8457
accoustic = "accoustic"
8558
accpetance = "accpetance"
86-
accracy = "accracy"
87-
acutal = "acutal"
88-
apporach = "apporach"
89-
apporaches = "apporaches"
90-
arguements = "arguements"
91-
arguemnts = "arguemnts"
92-
assgin = "assgin"
93-
assginment = "assginment"
94-
auxilary = "auxilary"
95-
avaiable = "avaiable"
96-
baisc = "baisc"
97-
basci = "basci"
98-
beacuse = "beacuse"
99-
bechmark = "bechmark"
100-
benckmark = "benckmark"
101-
boradcast = "boradcast"
102-
brodcast = "brodcast"
103-
caculate = "caculate"
10459
cantains = "cantains"
105-
choosen = "choosen"
106-
classfication = "classfication"
10760
classfy = "classfy"
10861
cliping = "cliping"
10962
colunms = "colunms"
@@ -152,21 +105,8 @@ foward = "foward"
152105
functinal = "functinal"
153106
fundemental = "fundemental"
154107
funtion = "funtion"
155-
gard = "gard"
156-
generaly = "generaly"
157-
gloabl = "gloabl"
158-
heigh = "heigh"
159108
ilter = "ilter"
160-
imge = "imge"
161-
implememted = "implememted"
162-
indeces = "indeces"
163-
indentical = "indentical"
164-
indicies = "indicies"
165-
indx = "indx"
166-
infered = "infered"
167109
inferface = "inferface"
168-
infor = "infor"
169-
ingore = "ingore"
170110
instert = "instert"
171111
instrinsics = "instrinsics"
172112
interchangable = "interchangable"
@@ -192,9 +132,6 @@ metrices = "metrices"
192132
muliply = "muliply"
193133
mulitplying = "mulitplying"
194134
mutbale = "mutbale"
195-
neeeded = "neeeded"
196-
nessesary = "nessesary"
197-
numberic = "numberic"
198135
occurence = "occurence"
199136
opeartor = "opeartor"
200137
opeartors = "opeartors"
@@ -246,31 +183,9 @@ sucess = "sucess"
246183
sucessor = "sucessor"
247184
sucessors = "sucessors"
248185
szie = "szie"
249-
tempory = "tempory"
250-
tenosr = "tenosr"
251-
thier = "thier"
252-
traget = "traget"
253186
traing = "traing"
254187
trainning = "trainning"
255-
traning = "traning"
256188
transfered = "transfered"
257189
trasformed = "trasformed"
258190
treshold = "treshold"
259191
trian = "trian"
260-
unqiue = "unqiue"
261-
unsupport = "unsupport"
262-
updte = "updte"
263-
utill = "utill"
264-
varialbes = "varialbes"
265-
varibale = "varibale"
266-
varibales = "varibales"
267-
varience = "varience"
268-
varient = "varient"
269-
visting = "visting"
270-
warpped = "warpped"
271-
wether = "wether"
272-
wiht = "wiht"
273-
wirte = "wirte"
274-
workign = "workign"
275-
wraper = "wraper"
276-
writter = "writter"

ci_scripts/check_api_label_cn.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def run_cn_api_label_checking(rootdir, files):
7777
for file in files:
7878
if should_test(file) and not check_api_label(rootdir, file):
7979
logger.error(
80-
f"The first line in {rootdir}/{file} is not avaiable, please re-check it!"
80+
f"The first line in {rootdir}/{file} is not available, please re-check it!"
8181
)
8282
sys.exit(1)
8383
valid_api_labels = find_all_api_labels_in_dir(rootdir)

ci_scripts/ci_start.sh

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,6 @@ if [ "${BUILD_DOC}" = "true" ] && [ -x /usr/local/bin/sphinx-build ] ; then
5757
git reset --hard && git clean -dfx
5858
cd ${DIR_PATH}
5959

60-
if [ -n "${BOS_CREDENTIAL_AK}" ] && [ -n "${BOS_CREDENTIAL_SK}" ] ; then
61-
echo "Ak = ${BOS_CREDENTIAL_AK}" >> ${BCECMD_CONFIG}/credentials
62-
echo "Sk = ${BOS_CREDENTIAL_SK}" >> ${BCECMD_CONFIG}/credentials
63-
fi
6460
if [ $xdebug_setted ] ; then
6561
set -x
6662
fi
@@ -70,14 +66,12 @@ if [ "${BUILD_DOC}" = "true" ] && [ -x /usr/local/bin/sphinx-build ] ; then
7066
if [ "${UPLOAD_DOC}" = "true" ] ; then
7167
PREVIEW_JOB_NAME="preview-pr-${GIT_PR_ID}"
7268
BOSBUCKET=${BOSBUCKET:=paddle-site-web-dev}
73-
${BCECMD} --conf-path ${BCECMD_CONFIG} bos sync "${OUTPUTDIR}/en/${VERSIONSTR}" "bos:/${BOSBUCKET}/documentation/en/${PREVIEW_JOB_NAME}" \
74-
--delete --yes --exclude "${OUTPUTDIR}/en/${VERSIONSTR}/_sources/"
75-
${BCECMD} --conf-path ${BCECMD_CONFIG} bos sync "${OUTPUTDIR}/en/${VERSIONSTR}" "bos:/${BOSBUCKET}/documentation/en/${PREVIEW_JOB_NAME}" \
76-
--delete --yes --exclude "${OUTPUTDIR}/en/${VERSIONSTR}/_sources/"
77-
${BCECMD} --conf-path ${BCECMD_CONFIG} bos sync "${OUTPUTDIR}/zh/${VERSIONSTR}" "bos:/${BOSBUCKET}/documentation/zh/${PREVIEW_JOB_NAME}" \
78-
--delete --yes --exclude "${OUTPUTDIR}/zh/${VERSIONSTR}/_sources/"
79-
${BCECMD} --conf-path ${BCECMD_CONFIG} bos sync "${OUTPUTDIR}/zh/${VERSIONSTR}" "bos:/${BOSBUCKET}/documentation/zh/${PREVIEW_JOB_NAME}" \
80-
--delete --yes --exclude "${OUTPUTDIR}/zh/${VERSIONSTR}/_sources/"
69+
wget -q --no-proxy https://xly-devops.bj.bcebos.com/home/bos_dir.tar --no-check-certificate
70+
tar xf bos_dir.tar
71+
python3 -m pip install bce-python-sdk==0.8.74
72+
# use bos_der.tar: The first parameter is to upload the directory, the second parameter is to upload the BOS directory, and the third parameter is to exclude the directory
73+
python3 BosClient.py ${OUTPUTDIR}/en/${VERSIONSTR} ${BOSBUCKET}/documentation/en/${PREVIEW_JOB_NAME} ${OUTPUTDIR}/en/${VERSIONSTR}/_sources/
74+
python3 BosClient.py ${OUTPUTDIR}/zh/${VERSIONSTR} ${BOSBUCKET}/documentation/zh/${PREVIEW_JOB_NAME} ${OUTPUTDIR}/zh/${VERSIONSTR}/_sources/
8175
# print preview url
8276
PREVIEW_URL_PROMPT="ipipe_log_param_preview_url: http://${PREVIEW_JOB_NAME}.${PREVIEW_SITE:-preview.paddlepaddle.org}/documentation/docs/zh/api/index_cn.html"
8377
fi

ci_scripts/hooks/pre-doc-compile.sh

Lines changed: 89 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,55 +5,118 @@ SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )"
55

66
FLUIDDOCDIR=${FLUIDDOCDIR:=/FluidDoc}
77
DOCROOT=${FLUIDDOCDIR}/docs
8-
9-
10-
## 1. 获取API映射文件
118
APIMAPPING_ROOT=${DOCROOT}/guides/model_convert/convert_from_pytorch
129
TOOLS_DIR=${APIMAPPING_ROOT}/tools
1310

14-
# 确保tools目录存在
15-
mkdir -p ${TOOLS_DIR}
11+
# Create tools directory if not exists
12+
if [ ! -d "${TOOLS_DIR}" ]; then
13+
echo "INFO: Creating tools directory at ${TOOLS_DIR}"
14+
mkdir -p "${TOOLS_DIR}"
15+
if [ $? -ne 0 ]; then
16+
echo "ERROR: Failed to create directory ${TOOLS_DIR}"
17+
exit 1
18+
fi
19+
else
20+
echo "INFO: Tools directory ${TOOLS_DIR} already exists"
21+
fi
1622

17-
#下载的文件URL
23+
# Define API mapping files URLs
1824
API_ALIAS_MAPPING_URL="https://raw.githubusercontent.com/PaddlePaddle/PaConvert/master/paconvert/api_alias_mapping.json"
1925
API_MAPPING_URL="https://raw.githubusercontent.com/PaddlePaddle/PaConvert/master/paconvert/api_mapping.json"
2026
GLOBAL_VAR_URL="https://raw.githubusercontent.com/PaddlePaddle/PaConvert/master/paconvert/global_var.py"
2127
ATTRIBUTE_MAPPING_URL="https://raw.githubusercontent.com/PaddlePaddle/PaConvert/master/paconvert/attribute_mapping.json"
2228

23-
# 下载文件
29+
# Check for proxy settings
2430
PROXY=""
2531
if [ -n "$https_proxy" ]; then
2632
PROXY="$https_proxy"
33+
echo "INFO: Using proxy"
2734
elif [ -n "$http_proxy" ]; then
2835
PROXY="$http_proxy"
36+
echo "INFO: Using proxy"
37+
else
38+
echo "INFO: No proxy detected, downloading directly."
2939
fi
3040

31-
# 构建 curl 代理参数
32-
CURL_PROXY_ARGS=""
41+
# Build curl proxy arguments
3342
if [ -n "$PROXY" ]; then
34-
CURL_PROXY_ARGS="--proxy $PROXY"
43+
CURL_PROXY_ARGS="--proxy ${PROXY}"
3544
else
36-
echo "No proxy detected, downloading directly."
45+
CURL_PROXY_ARGS=""
3746
fi
3847

39-
# 执行下载
40-
curl $CURL_PROXY_ARGS -o "${TOOLS_DIR}/api_alias_mapping.json" -s "${API_ALIAS_MAPPING_URL}"
41-
curl $CURL_PROXY_ARGS -o "${TOOLS_DIR}/api_mapping.json" -s "${API_MAPPING_URL}"
42-
curl $CURL_PROXY_ARGS -o "${TOOLS_DIR}/global_var.py" -s "${GLOBAL_VAR_URL}"
43-
curl $CURL_PROXY_ARGS -o "${TOOLS_DIR}/attribute_mapping.json" -s "${ATTRIBUTE_MAPPING_URL}"
48+
# Handle failure: copy cached file and exit
49+
handle_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"
57+
exit 0
58+
else
59+
echo "ERROR: Cached file not found at $cached_file"
60+
exit 1
61+
fi
62+
}
63+
64+
# Download file with retry and failure handling
65+
download_file() {
66+
local url=$1
67+
local dest=$2
68+
local filename=$(basename "$dest")
69+
local max_retries=3
70+
local retry_count=0
71+
72+
echo "INFO: Starting download of ${filename} from ${url}"
4473

45-
# 检查下载是否成功
46-
if [ $? -ne 0 ]; then
47-
echo "Error: Failed to download API mapping files"
48-
exit 1
74+
while [ $retry_count -lt $max_retries ]; do
75+
retry_count=$((retry_count + 1))
76+
echo "INFO: Attempt $retry_count of $max_retries to download ${filename}"
77+
78+
if curl $CURL_PROXY_ARGS -o "${dest}" -s "${url}" > /dev/null 2>&1; then
79+
echo "SUCCESS: Successfully downloaded ${filename} to ${dest}"
80+
return 0
81+
else
82+
echo "WARNING: Failed to download ${filename} from ${url} (attempt $retry_count)"
83+
sleep 2 # Wait for 2 seconds before next retry
84+
fi
85+
done
86+
87+
echo "ERROR: Failed to download ${filename} after $max_retries attempts"
88+
handle_failure
89+
}
90+
91+
# Download all API mapping files
92+
download_file "${API_ALIAS_MAPPING_URL}" "${TOOLS_DIR}/api_alias_mapping.json"
93+
download_file "${API_MAPPING_URL}" "${TOOLS_DIR}/api_mapping.json"
94+
download_file "${GLOBAL_VAR_URL}" "${TOOLS_DIR}/global_var.py"
95+
download_file "${ATTRIBUTE_MAPPING_URL}" "${TOOLS_DIR}/attribute_mapping.json"
96+
97+
echo "INFO: All API mapping files successfully downloaded"
98+
99+
# Run the remaining scripts with failure handling
100+
echo "INFO: Running get_api_difference_info.py"
101+
if ! python "${APIMAPPING_ROOT}/tools/get_api_difference_info.py"; then
102+
handle_failure
49103
fi
50104

51-
## 3. Apply PyTorch-PaddlePaddle mapping using the new API mapping files
52-
python ${APIMAPPING_ROOT}/tools/get_api_difference_info.py
53-
python ${APIMAPPING_ROOT}/tools/generate_pytorch_api_mapping.py
105+
echo "INFO: Running generate_pytorch_api_mapping.py"
106+
if ! python "${APIMAPPING_ROOT}/tools/generate_pytorch_api_mapping.py"; then
107+
handle_failure
108+
fi
54109

110+
# 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"
55113

56-
if [ $? -ne 0 ]; then
57-
echo "Error: API mapping generate script failed, please check changes in ${APIMAPPING_ROOT}"
58-
exit 1
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"
119+
else
120+
echo "ERROR: Generated API mapping file not found at $GENERATED_FILE"
121+
handle_failure
59122
fi

docs/api/gen_alias_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def generator_alias_api(self):
166166

167167
if __name__ == "__main__":
168168
if len(sys.argv) != 2:
169-
print("Useage:")
169+
print("Usage:")
170170
print("python3 gen_alias_api.py path-to-paddle-root")
171171
sys.exit(1)
172172
else:

0 commit comments

Comments
 (0)