Skip to content

Conversation

@LittleHeroZZZX
Copy link
Contributor

@LittleHeroZZZX LittleHeroZZZX commented Feb 9, 2026

增强 URL parser 的稳定性

  • 增加网络重试机制
  • 增加异常处理,当无法获取 url 时返回空值

Copilot AI review requested due to automatic review settings February 9, 2026 07:29
@paddle-bot
Copy link

paddle-bot bot commented Feb 9, 2026

感谢你贡献飞桨文档,文档预览构建中,Docs-New 跑完后即可预览,预览链接:http://preview-pr-7734.paddle-docs-preview.paddlepaddle.org.cn/documentation/docs/zh/api/index_cn.html
预览工具的更多说明,请参考:飞桨文档预览工具

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

该 PR 修改了模型转换文档工具链中的 API URL 解析器,通过对 sphobjinvInventory 做一层包装,在创建前后增加日志输出,意在辅助排查 objects.inv 解析/加载相关问题。

Changes:

  • sphobjinv.inventory.Inventory 重命名导入为 BaseInventory
  • 新增同名包装类 Inventory(BaseInventory),在构造前后打印 logger.info 日志

from sphobjinv.inventory import Inventory as BaseInventory


class Inventory(BaseInventory):
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里新定义的 Inventory 类会遮蔽 sphobjinv.inventory.Inventory 的原始含义,后续读代码/排查问题时容易混淆(尤其在 traceback/类型提示中)。建议把该包装类改成更明确的名字(例如 LoggedInventory/DebugInventory),并在本文件内相应替换调用点;或仅在需要时用局部函数/上下文包装而不是同名类覆盖。

Suggested change
class Inventory(BaseInventory):
class LoggedInventory(BaseInventory):

Copilot uses AI. Check for mistakes.
Comment on lines 12 to 15
def __init__(self, *args, **kwargs) -> None:
logger.info(f"Creating {self.__class__.__name__}")
super().__init__(*args, **kwargs)
logger.info(f"Created {self.__class__.__name__}")
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inventory.__init__ 里使用 logger.info 打印创建/创建完成会显著增加文档构建或工具运行时的日志噪声(该解析器会在 get_parser 中被多次初始化)。更合适的做法是改用 logger.debug,或用环境变量/命令行开关控制是否输出这类调试日志,避免污染 CI 日志。

Copilot uses AI. Check for mistakes.
@@ -5,7 +5,14 @@
from urllib.parse import urljoin

from loguru import logger
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个logger也删了吧,直接print,减少下载量

Add retry mechanism with exponential backoff to the Inventory class constructor to handle transient network failures when loading API documentation inventories. The class now retries up to 3 times with a 1-second delay between attempts, logging warnings for retries and raising a ConnectionError after all attempts fail.

Wrap the get_url function in a try-except block to catch and log any exceptions during URL resolution, returning an empty string on error instead of crashing. This improves the robustness of the API documentation tooling against intermittent network issues and unexpected parsing errors.
- Remove loguru dependency from pre-doc-compile.sh installation
- Replace loguru logger with Python's standard logging.getLogger in api_url_parser.py and api_utils.py
- Update logging calls to use standard Python string formatting syntax
- Maintain existing functionality while switching to built-in logging module
@LittleHeroZZZX LittleHeroZZZX changed the title 【NO】test ci Add retry support and exception tolerance for url parser Feb 10, 2026
@zhwesky2010 zhwesky2010 merged commit 8c9eb34 into PaddlePaddle:develop Feb 10, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants