已合并
【msserviceprofiler】服务化调优支持--help和--version选项 #441
hewenbo创建于 22 天前
【msserviceprofiler】服务化调优支持--help和--version选项 #441
已合并
hewenbo创建于 22 天前
已删除 :master合入到Ascend/msserviceprofilermaster
hewenbo成员
22 天前

PR 合入模板

1. 修改描述

  • **修改原因:【msserviceprofiler】服务化调优支持--help和--version选项
  • **修改内容:【msserviceprofiler】服务化调优支持--help和--version选项

2. 功能验证


3. 代码检视

  • 要求:
    • 合入代码大于 200 行,需三人以上会议检视。
    • 检视密度≥2个/100行。
    • 检视缺陷密度达不到要求的需给出说明。
    • 大于 1000 行代码原则上不允许合入,需进行备案。

4. 安全自检

典型安全编码问题


5. 变更知会

  • 资料修改:
  • 变更通知(消息知会 + 邮件知会):

6. 冒烟修改

  • PR 来源:

likedislike
Pull Request已成功合入, 合并人@ascend-robot
(感谢 hewenbo 的贡献)
atomgit-bot
atomgit-bot成员
22 天前 评论:

变更摘要

该 PR 为 msserviceprofiler 服务化调优工具新增统一的 --help--version-V)支持,将原先分散在入口模块中的参数解析逻辑收敛到新增的 ms_service_profiler/cli.py 模块。核心通过 create_parser() 创建带 VersionAction 的根解析器,is_root_cli_request() 判断是否为顶层帮助/版本请求,run_parser() 统一执行解析与分发;同时提供格式化的版本信息(包版本、Git 提交、构建日期、依赖版本)和统一样式的根帮助文本。

主要改动

  • 新增 ms_service_profiler/cli.py 模块:集中实现 create_parseris_root_cli_requestrun_parserget_version_text 等核心函数,并新增 RootHelpParser(定制顶层帮助输出)与 VersionAction(处理 -V/--version 并以退出码 0 结束)。
  • 重构两个入口文件__main__.pyms_service_profiler/__main__.py 均改为调用 create_parser()run_parser(),在 is_root_cli_request() 命中时直接执行根请求并返回,避免后续加载子命令。
  • 新增 parse 子命令与插件回退逻辑:顶层入口显式 import parse 并注册 parse.arg_parsems_service_profiler/__main__.py_load_entries() 在无插件入口时回退到内置的 analyzecompareparsesplit 四个命令。
  • 版本信息与依赖展示get_version_text() 输出 MindStudio 格式版本信息,包含通过 _get_package_version_get_git_commit_get_build_date_format_dependencies 获取的包版本、Git 短提交、构建日期及 Pandas/NumPy/OpenTelemetry/PyYAML 等依赖版本。
  • 新增单元测试 test/ut/python/test_ms_service_profiler/test_cli.py:覆盖 --help 输出统一章节、--version 的 MindStudio 格式与多行输出,以及无参数调用 run_parser 时输出根帮助文本的场景。
likedislike
atomgit-bot
atomgit-bot成员
22 天前 评论:

代码审查

Closing Summary

已逐一审查全部 4 个变更文件,结论如下:

文件 审查结论
__main__.py 发现 1 个 P2 问题(静态 ROOT_HELP 遗漏 optimizer/advisor/source_to_train 子命令)
ms_service_profiler/__main__.py 无问题(_load_entries 的 fallback 属于健壮性改进;entry_points().select() 为既有用法)
ms_service_profiler/cli.py 无独立问题(ROOT_HELP 内容缺陷已随根入口一并报告;subprocess.run 为固定命令列表、无注入风险;_read_pyproject_version 的脆弱解析触发条件过于牵强,不予上报)
test/ut/python/test_ms_service_profiler/test_cli.py 无问题(各断言与实现行为一致)

问题计数:P0 = 0,P1 = 0,P2 = 1,P3 = 0。

整体风险判断:本次改动引入 --help/--version 支持,主体逻辑(create_parser/is_root_cli_request/run_parser 及其测试)实现正确、无注入或崩溃风险。唯一实质问题是组合式 msserviceprofiler 入口的 --help/无参数帮助输出因复用 profiler 单包的静态文本而遗漏 3 个真实子命令,属于用户可见的帮助信息回归,建议在合入前补齐。

类型 数量
🔴 阻塞 0
🟡 建议 1

💬 仅评论

likedislike
ascend-robotascend-robot成员
22 天前 添加了label:ascend-cla/yes
ascend-robot
ascend-robot成员
22 天前 评论:

Thanks for your pull-request.
The full list of commands accepted by me can be found at here
You can get sig-info at here


PR Approval Progress

Congratulations! All modules have met the lgtm and approve requirements.

Module Approval Details

module lgtm status approve status
repo-Ascend/msserviceprofiler 刘鹏程, mei-feiyao (2/2) 刘鹏程 (1/1)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)

CLA Signature Pass

hewenbo, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
此处折叠了89条消息 查看更多
ascend-robotascend-robot成员
19 天前 添加了label:approvedlgtm
ascend-robot
ascend-robot成员
19 天前 评论:

The MR can not be merged, because of CodeReview discussion not resolved

If you want to solve this problem, you can click here to do it in the FAQs.

likedislike
Hhewenbo成员
19 天前 解决了最后一个问题
ascend-robotascend-robot成员
19 天前 合入了pull request
ascend-robot
ascend-robot成员
19 天前 评论:

Pull Request 已合并或已关闭。

If you want to solve this problem, you can click here to do it in the FAQs.

likedislike