Add plot transform and deprecated wrappers#1589
Merged
SAKURA-CAT merged 2 commits intomainfrom Apr 30, 2026
Merged
Conversation
Introduce a new swanlab.sdk.internal.run.transforms.plot module that re-exports echarts.metrics (confusion_matrix, roc_curve, pr_curve) as a placeholder plotting API. Expose the new plot symbol in swanlab.sdk and the top-level package (including typing stubs). Add top-level deprecated helper functions (roc_curve, pr_curve, confusion_matrix) that warn and forward calls to swanlab.echarts.* to preserve backwards compatibility. Also import typing_extensions.deprecated and warnings to support the deprecation wrappers.
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces a new plot module and deprecates the top-level roc_curve, pr_curve, and confusion_matrix functions, redirecting them to the echarts module with appropriate deprecation warnings. The feedback suggests adding stacklevel=2 to the warnings.warn calls to ensure the warning points to the user's code rather than the internal wrapper. Additionally, it is recommended to update the type stub file (__init__.pyi) to include these deprecated functions to maintain consistency and provide better IDE support.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
变更内容
swanlab.plot模块,作为自定义图表的占位入口,目前从 echarts 组件中导出confusion_matrix、roc_curve、pr_curveswanlab.roc_curve()、swanlab.pr_curve()、swanlab.confusion_matrix()添加@deprecated装饰器和弃用警告,引导用户使用swanlab.echarts.*替代__init__.pyi类型存根,添加plot导出__all__导出顺序,将echarts和plot归类到数据模块组变更文件
swanlab/__init__.py— 添加 plot 导入、deprecated 包装函数swanlab/__init__.pyi— 添加 plot 类型导出swanlab/sdk/__init__.py— 添加 plot 导入,调整导出顺序swanlab/sdk/internal/run/transforms/plot/__init__.py— 新增 plot 模块