Skip to content

Commit 3f5dcfd

Browse files
committed
feat(core): add breaking changes warning and logging utility
Adds a warning message that displays when using early versions of the AgentRun Python SDK, informing users about potential breaking changes and recommending dependency pinning. Also imports necessary os and logger utilities for the warning implementation. The warning includes both English and Chinese messages and can be disabled via DISABLE_BREAKING_CHANGES_WARNING environment variable. This change enhances user experience by providing clear guidance on version management and helps prevent compatibility issues in production environments. 添加破坏性更改警告和日志工具 添加一个警告消息,在使用 AgentRun Python SDK 的早期版本时显示, 告知用户有关潜在的破坏性更改并推荐依赖版本固定。 同时导入必要的 os 和 logger 工具用于警告实现。 该警告包含英文和中文消息,并可通过 DISABLE_BREAKING_CHANGES_WARNING 环境变量禁用。 此更改通过提供清晰的版本管理指导来增强用户体验, 并帮助防止生产环境中的兼容性问题。 BREAKING CHANGE: adds breaking changes warning that displays on SDK startup A warning message will now appear when importing the module, which may affect automated systems that expect clean output. Users can disable this warning by setting DISABLE_BREAKING_CHANGES_WARNING=1 environment variable. 破坏性更改:在 SDK 启动时添加破坏性更改警告 现在在导入模块时会出现警告消息,这可能会影响期望干净输出的自动化系统。 用户可以通过设置 DISABLE_BREAKING_CHANGES_WARNING=1 环境变量来禁用此警告。 Change-Id: Ieebfcc0dcf6faaf4aaffd20279f0794053b9cf7d Signed-off-by: OhYee <oyohyee@oyohyee.com>
1 parent bbd6b87 commit 3f5dcfd

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

agentrun/__init__.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@
1616
- Integration: 框架集成 / Framework integration
1717
"""
1818

19+
import os
1920
from typing import TYPE_CHECKING
2021

2122
__version__ = "0.0.16"
2223

24+
2325
# Agent Runtime
2426
from agentrun.agent_runtime import (
2527
AgentRuntime,
@@ -114,6 +116,7 @@
114116
ResourceAlreadyExistError,
115117
ResourceNotExistError,
116118
)
119+
from agentrun.utils.log import logger
117120
from agentrun.utils.model import Status
118121

119122
# Server - 延迟导入以避免可选依赖问题
@@ -360,3 +363,23 @@ def __getattr__(name: str):
360363
raise
361364

362365
raise AttributeError(f"module '{__name__}' has no attribute '{name}'")
366+
367+
368+
if not os.getenv("DISABLE_BREAKING_CHANGES_WARNING"):
369+
logger.warning(
370+
f"当前您正在使用 AgentRun Python SDK 版本 {__version__}。"
371+
"早期版本通常包含许多新功能,这些功能\033[1;33m 可能引入不兼容的变更"
372+
" \033[0m。为避免潜在问题,我们强烈建议\033[1;32m 将依赖锁定为此版本"
373+
" \033[0m。\nYou are currently using AgentRun Python SDK version"
374+
f" {__version__}. Early versions often include many new features,"
375+
" which\033[1;33m may introduce breaking changes\033[0m. To avoid"
376+
" potential issues, we strongly recommend \033[1;32mpinning the"
377+
" dependency to this version\033[0m.\n\033[2;3m pip install"
378+
f" 'agentrun-sdk=={__version__}' \033[0m\n\n增加\033[2;3m"
379+
" DISABLE_BREAKING_CHANGES_WARNING=1"
380+
" \033[0m到您的环境变量以关闭此警告。\nAdd\033[2;3m"
381+
" DISABLE_BREAKING_CHANGES_WARNING=1 \033[0mto your environment"
382+
" variables to disable this warning.\n\nReleases:\033[2;3m"
383+
" https://github.com/Serverless-Devs/agentrun-sdk-python/releases"
384+
" \033[0m"
385+
)

0 commit comments

Comments
 (0)