Skip to content

[refactor]收敛 model_postprocessors 重复实现,废弃模块改为再导出 - #706

Open
SJTUyh wants to merge 1 commit into
AISBench:masterfrom
SJTUyh:refactor/model-postprocessors-shim
Open

SJTUyh wants to merge 1 commit into
AISBench:masterfrom
SJTUyh:refactor/model-postprocessors-shim

Conversation

@SJTUyh

@SJTUyh SJTUyh commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

PR Type / PR类型

  • Feature(功能新增)
  • Bugfix(Bug 修复)
  • Docs(文档更新)
  • CI/CD(持续集成/持续部署)
  • Refactor(代码重构)
  • Perf(性能优化)
  • Dependency(依赖项更新)
  • Test-Cases(测试用例更新)
  • Other(其他)

Related Issue | 关联 Issue
Fixes #704

🔍 Motivation / 变更动机

ais_bench/benchmark/utils/model_postprocessors.py 已在文件头声明废弃,但仍完整复制了一份 extract_non_reasoning_content,并以同一个 key extract-non-reasoning-content 注册到 TEXT_POSTPROCESSORS。由于 Registry.register_module 默认 force=True,最终生效的实现取决于导入顺序;一旦只修改其中一份,通过旧路径配置的任务会静默使用另一份实现。本 PR 将废弃模块收敛为薄兼容层。

📝 Modification / 修改内容

  • ais_bench/benchmark/utils/model_postprocessors.py:删除 65 行重复实现与重复注册,改为从 ais_bench/benchmark/utils/postprocess/model_postprocessors.py 再导出 extract_non_reasoning_content,并保留原有的废弃告警。
  • tests/UT/utils/test_model_postprocessors.py:新增断言,旧/新路径导出同一函数对象;reload 旧模块后,TEXT_POSTPROCESSORS 中 extract-non-reasoning-content 仍指向新模块实现。
  • 公开导入路径、函数行为、参数默认值、docstring、日志内容与注册 key 均保持不变。

📐 Associated Test Results / 关联测试结果

本地环境:Windows,Python 3.11.4,commit ce9ad9c。

  • python -m pytest tests/UT/utils/test_model_postprocessors.py -q -k "not registered" → 10 passed, 1 deselected(含新增用例)。
  • python -m pytest tests/UT/utils/test_model_postprocessors.py -q → 10 passed, 1 failed;失败项 test_extract_non_reasoning_content_registered 在本机 torch c10.dll 初始化失败(WinError 1114),改动前基线同样失败,与本次改动无关,以 Linux CI 结果为准。
  • python -m compileall -q ais_bench/benchmark/utils/model_postprocessors.py → 通过。
  • 独立脚本校验:旧/新路径函数为同一对象;先导入新模块或先导入旧模块两种顺序下,注册表均指向新模块实现。
  • ruff check 对本次新增代码无告警;文件内仍有 3 项改动前已存在的告警(第 1/3 行 import 排序与未使用的 patch/Mock)。

⚠️ BC-breaking (Optional) / 向后不兼容变更(可选)

不适用。旧导入路径保留,from ais_bench.benchmark.utils.model_postprocessors import extract_non_reasoning_content 仍可用;导入旧模块会连带导入新模块并注册其其余 postprocessor,属预期副作用,不改变 extract-non-reasoning-content 的解析结果。

⚠️ Performance degradation (Optional) / 性能下降(可选)

不适用。纯重构,不涉及评测流程、数据集或结果格式,不新增依赖。

🌟 Use cases (Optional) / 使用案例(可选)

不适用。

✅ Checklist / 检查列表

Before PR:

  • Pre-commit or other linting tools are used to fix the potential lint issues. / 使用预提交或其他 linting 工具来修复潜在的 lint 问题。
  • Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. / 修复的 Bug 已完全由单元测试覆盖,导致 Bug 的情况应在单元测试中添加。
  • The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. / 此拉取请求中的修改已完全由单元测试覆盖。如果不是,请添加更多单元测试以确保正确性。
  • All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. / 所有相关文档(API 文档、文档字符串、示例教程)已更新以反映这些更改。

After PR:

  • If the modification has potential influence on downstream or other related projects, this PR should be tested with those projects. / 如果此拉取请求对下游或其他相关项目有潜在影响,应在那些项目中测试此 PR。
  • CLA has been signed and all committers have signed the CLA in this PR. / CLA 已签署,且本 PR 中的所有提交者均已签署 CLA。

👥 Collaboration Info / 协作信息

  • Suggested Reviewers / 建议审核人: 待维护者指派
  • Relevant Module Owners / 相关模块负责人: utils 模块维护者
  • Other Collaboration Notes / 其他协作说明:CLA 需由提交者本人签署,Agent 不代签;lint 项保留未勾选,因文件仍有改动前已存在的 ruff 告警;test_extract_non_reasoning_content_registered 在 Windows 本地的失败为 torch DLL 环境问题,请以 Linux CI 结果为准。

旧模块 ais_bench/benchmark/utils/model_postprocessors.py 改为薄兼容层,仅从新路径 ais_bench/benchmark/utils/postprocess/model_postprocessors.py 再导出 extract_non_reasoning_content,删除重复的 65 行实现与重复注册。

公开导入路径、函数行为、参数默认值、docstring、日志内容与注册 key 均保持不变;导入旧模块会连带注册新模块中的其余 postprocessor,属预期副作用。

新增单元测试:断言旧/新路径导出同一函数对象,并在 reload 旧模块后校验 TEXT_POSTPROCESSORS 中 extract-non-reasoning-content 仍指向新模块实现。

Signed-off-by: SJTUyh <[email protected]>
@github-actions github-actions Bot added the no_review PR 未包含任何检视意见,合入前必须包含检视意见 label Nov 23, 2026
@github-actions

Copy link
Copy Markdown

🚫 PR 合入质量检查未通过,PR 已被禁止合入。

未通过项:no_review

  • 无检视意见:请至少邀请一位 reviewer 提交检视意见(Approve / Request changes / Comment 均可)。

请按上述提示整改后,重新推送(push)或评论本 PR 即可触发再次检查。

@SJTUyh SJTUyh changed the title [refactor]?? model_postprocessors ????,????????? [refactor]收敛 model_postprocessors 重复实现,废弃模块改为再导出 Nov 23, 2026

This branch was successfully deployed

No deployments
smoke-test-approval — ce9ad9c2 Deployed Nov 23, 2026 by SJTUyh via run_smoke_test_cases #927
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no_review PR 未包含任何检视意见,合入前必须包含检视意见 refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: 收敛 model_postprocessors 重复实现,废弃模块改为再导出

1 participant