Repository navigation
Open
Labels
Description
💻 需求背景、当前现状、期望实现的功能内容、具体的设计方案、以及测试方案
需求背景
ais_bench/benchmark/utils/model_postprocessors.py 已在文件头提示废弃,并指向新路径 ais_bench/benchmark/utils/postprocess/model_postprocessors.py,但实现没有真正收敛:两个模块各自完整复制了一份 extract_non_reasoning_content(旧模块第 12-76 行,新模块第 34-98 行),并且都用同一个 key extract-non-reasoning-content 注册到 TEXT_POSTPROCESSORS。
当前现状
- 重复实现:两份 65 行实现(含 docstring)完全一致,任一逻辑修正都必须同步改两处。
- 重复注册:
ais_bench/benchmark/registry.py:68-73的register_module默认force=True,同名 key 由后导入者覆盖先导入者。旧路径仍被plugin_examples/config_example/perf_example.py:7、plugin_examples/README.md:77、smoke_tests/test-case/run_other_commands/common_commands/custom_py_config_dir/ais_bench_configs/models/vllm_api/custom_py_config_dir.py:2以及tests/UT/utils/test_model_postprocessors.py:23引用,因此最终生效的函数对象取决于导入顺序。 - 当前两份实现一致,问题不会立刻暴露;一旦只修改其中一份(例如调整 token 匹配或日志),通过旧路径配置的任务会静默使用另一份实现。
期望实现的功能内容
- 废弃模块保持公开 API 不变,仍可
from ais_bench.benchmark.utils.model_postprocessors import extract_non_reasoning_content,并保留废弃警告。 - 删除旧模块中的函数副本与重复注册,改为从新模块再导出同一函数对象,使
extract-non-reasoning-content在注册表中只有一个来源。 - 不改变函数行为、参数、默认值、docstring、日志内容与注册 key。
具体的设计方案
文件:ais_bench/benchmark/utils/model_postprocessors.py(当前 76 行),改为薄兼容层,例如:
"""Deprecated compatibility shim; use ais_bench.benchmark.utils.postprocess.model_postprocessors."""
from ais_bench.benchmark.utils.logging import AISLogger
from ais_bench.benchmark.utils.postprocess.model_postprocessors import ( # noqa: F401
extract_non_reasoning_content,
)
logger = AISLogger()
logger.warning(
"ais_bench.benchmark.utils.model_postprocessors is deprecated, "
"please use ais_bench.benchmark.utils.postprocess.model_postprocessors instead."
)- 新模块
ais_bench/benchmark/utils/postprocess/model_postprocessors.py不做修改。 - 副作用说明:导入旧模块会连带导入新模块,因此
keep-reasoning-content与extract-non-reasoning-content-raw也会被注册;两者本来就由官方路径提供,不改变extract-non-reasoning-content的解析结果。 - 旧模块不再需要
import re与TEXT_POSTPROCESSORS导入。
测试方案
- 复用现有单测:
python -m pytest tests/UT/utils/test_model_postprocessors.py -q,其中test_deprecated_module_exports_current_api与注册断言可直接覆盖兼容层的导出与注册。 - 新增断言:旧路径与新路径导出的函数是同一对象,即
mp.extract_non_reasoning_content is postprocess_extract_non_reasoning_content。 - 新增顺序无关性用例:先导入新模块再导入旧模块,断言
TEXT_POSTPROCESSORS.get('extract-non-reasoning-content')仍指向新模块函数。 - 编译检查:
python -m compileall ais_bench/benchmark/utils/model_postprocessors.py。 - 手工核对引用方无需改动即可导入:
plugin_examples/config_example/perf_example.py与 smoke 用例中的custom_py_config_dir.py。
替代方案
- 保留两份实现仅加注释提醒同步:无法阻止导入顺序覆盖注册表,问题依旧存在。
- 直接删除旧模块:会破坏
plugin_examples、smoke 用例与现有单测中的导入,属于不兼容变更。 - 将实现下沉到中性模块后两边各自导入:仍会在两个模块各注册一次同名 key,除非废弃模块只做再导出;与首选方案相比多一个文件,收益不变。
补充说明
- 核对基线:仓库 commit
da7ece4430e723e390b46b915a6122c886b06929(与知识库索引 sha 一致)。 - 结构核对:对两个函数的 decorator 与 body 做 AST 对比,结果完全一致(含 docstring),参数与默认值一致。
- 该改动为纯重构,不涉及评测流程、数据集或结果格式,不新增依赖。
本 Issue 由 Agent「trae-local」生成,经 @SJTUyh 审核后以本人身份创建。
Activity
github-actions commentedon Nov 23, 2026
🌟欢迎给AISBench benchmark测评工具提issue,我们会尽快处理您的诉求~
github-actions commentedon Nov 23, 2026
🤖 基于AI机器人的issue内容完整性检查结果:
问题内容检查结果
检查状态
FAIL
详细检查
👉 如果想重新检查,在评论区@issue_checker即可。
【强烈推荐❤️🔥】确保issue描述完整后,可以试着将issue交给
回答,deepwiki包含了和工具相关的所有知识库