-
Notifications
You must be signed in to change notification settings - Fork 871
[CI] 完善ci脚本,优化映射文档生成代码 #7556
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
zhwesky2010
merged 6 commits into
PaddlePaddle:develop
from
hd9568:generate_api_difference_1016
Oct 17, 2025
Merged
[CI] 完善ci脚本,优化映射文档生成代码 #7556
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4ba1181
第二类自动生成(未完成),完善ci脚本
hd9568 888fd94
添加一列映射分类,精简分类简介
hd9568 f6fb3f5
修改CI
hd9568 6ffb109
更新映射文档分类简介,添加第二类api示例
hd9568 2a7f452
Merge remote-tracking branch 'upstream/develop' into generate_api_dif…
hd9568 d91168d
优化CI和示例写法
hd9568 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,26 +20,20 @@ else | |
| echo "INFO: Tools directory ${TOOLS_DIR} already exists" | ||
| fi | ||
|
|
||
| # Define API mapping files URLs | ||
| # Define API mapping files URLs (only main URLs, no backups) | ||
| API_ALIAS_MAPPING_URL="https://raw.githubusercontent.com/PaddlePaddle/PaConvert/master/paconvert/api_alias_mapping.json" | ||
| API_MAPPING_URL="https://raw.githubusercontent.com/PaddlePaddle/PaConvert/master/paconvert/api_mapping.json" | ||
| GLOBAL_VAR_URL="https://raw.githubusercontent.com/PaddlePaddle/PaConvert/master/paconvert/global_var.py" | ||
| ATTRIBUTE_MAPPING_URL="https://raw.githubusercontent.com/PaddlePaddle/PaConvert/master/paconvert/attribute_mapping.json" | ||
|
|
||
| # Define backup URLs | ||
| BACKUP_API_ALIAS_MAPPING_URL="https://paddle-paconvert.bj.bcebos.com/api_alias_mapping.json" | ||
| BACKUP_API_MAPPING_URL="https://paddle-paconvert.bj.bcebos.com/api_mapping.json" | ||
| BACKUP_GLOBAL_VAR_URL="https://paddle-paconvert.bj.bcebos.com/global_var.py" | ||
| BACKUP_ATTRIBUTE_MAPPING_URL="https://paddle-paconvert.bj.bcebos.com/attribute_mapping.json" | ||
|
|
||
| # Check for proxy settings | ||
| PROXY="" | ||
| if [ -n "$https_proxy" ]; then | ||
| PROXY="$https_proxy" | ||
| echo "INFO: find proxy" | ||
| echo "INFO: Using proxy" | ||
| elif [ -n "$http_proxy" ]; then | ||
| PROXY="$http_proxy" | ||
| echo "INFO: find proxy" | ||
| echo "INFO: Using proxy" | ||
| else | ||
| echo "INFO: No proxy detected, downloading directly." | ||
| fi | ||
|
|
@@ -56,7 +50,7 @@ download_file() { | |
| local url=$1 | ||
| local dest=$2 | ||
| local filename=$(basename "$dest") | ||
| local max_retries=5 | ||
| local max_retries=3 | ||
| local retry_count=0 | ||
|
|
||
| echo "INFO: Starting download of ${filename} from ${url}" | ||
|
|
@@ -78,39 +72,87 @@ download_file() { | |
| return 1 | ||
| } | ||
|
|
||
| # Download each file with detailed logging | ||
| # Check if cached file exists | ||
| check_cached_file() { | ||
| local cached_file="${APIMAPPING_ROOT}/cached_pytorch_api_mapping_cn.md" | ||
| if [ -f "$cached_file" ]; then | ||
| echo "INFO: Cached file found at $cached_file" | ||
| return 0 | ||
| else | ||
| echo "INFO: No cached file found at $cached_file" | ||
| return 1 | ||
| fi | ||
| } | ||
|
|
||
| # Copy cached file to target if download fails | ||
| copy_cached_file() { | ||
| local cached_file="${APIMAPPING_ROOT}/cached_pytorch_api_mapping_cn.md" | ||
| local target_file="${APIMAPPING_ROOT}/pytorch_api_mapping_cn.md" | ||
|
|
||
| if [ -f "$cached_file" ]; then | ||
| echo "INFO: Copying cached file to target: $cached_file -> $target_file" | ||
| cp "$cached_file" "$target_file" | ||
| echo "INFO: Successfully copied cached file to $target_file" | ||
| return 0 | ||
| else | ||
| echo "ERROR: Cached file not found at $cached_file" | ||
| return 1 | ||
| fi | ||
| } | ||
|
|
||
| # Download API mapping files | ||
| echo "INFO: Downloading API alias mapping file" | ||
| if ! download_file "${API_ALIAS_MAPPING_URL}" "${TOOLS_DIR}/api_alias_mapping.json"; then | ||
| echo "INFO: Trying backup URL for API alias mapping file" | ||
| if ! download_file "${BACKUP_API_ALIAS_MAPPING_URL}" "${TOOLS_DIR}/api_alias_mapping.json"; then | ||
| echo "ERROR: API alias mapping download failed (both main and backup URLs). Exiting." | ||
| echo "INFO: API alias mapping download failed. Checking for cached file..." | ||
| if check_cached_file; then | ||
| if ! copy_cached_file; then | ||
|
||
| echo "ERROR: Failed to copy cached file to target" | ||
| exit 1 | ||
| fi | ||
| else | ||
| echo "ERROR: API alias mapping download failed and no cached file available" | ||
| exit 1 | ||
| fi | ||
| fi | ||
|
|
||
| echo "INFO: Downloading API mapping file" | ||
| if ! download_file "${API_MAPPING_URL}" "${TOOLS_DIR}/api_mapping.json"; then | ||
| echo "INFO: Trying backup URL for API mapping file" | ||
| if ! download_file "${BACKUP_API_MAPPING_URL}" "${TOOLS_DIR}/api_mapping.json"; then | ||
| echo "ERROR: API mapping download failed (both main and backup URLs). Exiting." | ||
| echo "INFO: API mapping download failed. Checking for cached file..." | ||
| if check_cached_file; then | ||
| if ! copy_cached_file; then | ||
| echo "ERROR: Failed to copy cached file to target" | ||
| exit 1 | ||
| fi | ||
| else | ||
| echo "ERROR: API mapping download failed and no cached file available" | ||
| exit 1 | ||
| fi | ||
| fi | ||
|
|
||
| echo "INFO: Downloading global variable file" | ||
| if ! download_file "${GLOBAL_VAR_URL}" "${TOOLS_DIR}/global_var.py"; then | ||
| echo "INFO: Trying backup URL for global variable file" | ||
| if ! download_file "${BACKUP_GLOBAL_VAR_URL}" "${TOOLS_DIR}/global_var.py"; then | ||
| echo "ERROR: Global variable download failed (both main and backup URLs). Exiting." | ||
| echo "INFO: Global variable download failed. Checking for cached file..." | ||
| if check_cached_file; then | ||
| if ! copy_cached_file; then | ||
| echo "ERROR: Failed to copy cached file to target" | ||
| exit 1 | ||
| fi | ||
| else | ||
| echo "ERROR: Global variable download failed and no cached file available" | ||
| exit 1 | ||
| fi | ||
| fi | ||
|
|
||
| echo "INFO: Downloading attribute mapping file" | ||
| if ! download_file "${ATTRIBUTE_MAPPING_URL}" "${TOOLS_DIR}/attribute_mapping.json"; then | ||
| echo "INFO: Trying backup URL for attribute mapping file" | ||
| if ! download_file "${BACKUP_ATTRIBUTE_MAPPING_URL}" "${TOOLS_DIR}/attribute_mapping.json"; then | ||
| echo "ERROR: Attribute mapping download failed (both main and backup URLs). Exiting." | ||
| echo "INFO: Attribute mapping download failed. Checking for cached file..." | ||
| if check_cached_file; then | ||
| if ! copy_cached_file; then | ||
| echo "ERROR: Failed to copy cached file to target" | ||
| exit 1 | ||
| fi | ||
| else | ||
| echo "ERROR: Attribute mapping download failed and no cached file available" | ||
| exit 1 | ||
| fi | ||
| fi | ||
|
|
@@ -142,3 +184,17 @@ if ! python "${APIMAPPING_ROOT}/tools/generate_pytorch_api_mapping.py"; then | |
| echo "ERROR: generate_pytorch_api_mapping.py failed. Please check the script." | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Create backup of generated file | ||
| BACKUP_FILE="${APIMAPPING_ROOT}/cached_pytorch_api_mapping_cn.md" | ||
| GENERATED_FILE="${APIMAPPING_ROOT}/pytorch_api_mapping_cn.md" | ||
|
|
||
| if [ -f "$GENERATED_FILE" ]; then | ||
| echo "INFO: Generated API mapping file successfully created at $GENERATED_FILE" | ||
| echo "INFO: Creating backup file: $BACKUP_FILE" | ||
| cp "$GENERATED_FILE" "$BACKUP_FILE" | ||
| echo "INFO: Successfully created backup file at $BACKUP_FILE" | ||
| else | ||
| echo "ERROR: Generated API mapping file not found at $GENERATED_FILE" | ||
| exit 1 | ||
| fi | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里的逻辑需要优化一下,如果有1个没下载成功。则复制cache,同时后面也不需要再下载文件,也不需要再跑 api_alias_mapping判断、get_api_difference_info、generate_pytorch_api_mapping这些冗余逻辑。
也就是要么走 自动生成generate_pytorch_api_mapping整体的逻辑、要么复制cache。两者二选一。