已合并
feat: support attributes1~attributes9 extension columns, merged into attributes with last-wins override semantics #89
FishPotatoChen创建于 11 天前
feat: support attributes1~attributes9 extension columns, merged into attributes with last-wins override semantics #89
已合并
FishPotatoChen创建于 11 天前
FishPotatoChen
11 天前

当前PR是否有AI参与:

[x] 否
[ ] 是
__1. AI Agent 平台:
__2. AI 模型:
__3. Prompt上下文 :

PR功能描述 / 为什么需要这个合入**:

当前 CSV 用例中的 attributes 列仅支持一个字段承载所有算子属性。当算子属性较多(如几十个 key)时,将所有属性挤在一个单元格中可读性差、编辑困难,且 CSV 单列承载大量 JSON 容易出错。

本 PR 新增 attributes1 ~ attributes9 共 9 个扩展列,允许将算子属性拆分到多个列中写入。在用例 validate() 阶段,扩展列按 attributes(即attributes0) -> attributes1 -> ... -> attributes9 的顺序依次 merge 到 attributes 中,发生 key 冲突时后续列覆盖前列(last-wins 语义)。若用例为无效行则跳过合并。

改动范围

  • testcase_base.pyTestcaseBase.validate() 中插入 _merge_extended_attributes() 调用,实现合并逻辑
  • testcase_op.py / testcase_aclnn.py / testcase_e2e.py:三种测试模式的 Testcase 类均声明 attributes1~attributes9 字段(complete_headers__slots__/__init__、类型头定义),新增字段均为可选的 dict 类型,默认值 {}
  • 向后兼容:不填扩展列时行为完全不变

该PR关联的issue

https://gitcode.com/cann/ops-test-kit/issues/73

希望检视人员了解:

  • 扩展列合并遵循 last-wins 覆盖语义,无冲突报错。如果用户需要严格校验重复 key,可在后续迭代中增加告警机制。
  • _merge_extended_attributes() 仅在 cases.is_valid=True 时执行,无效行保持原始 attributes 不变。
  • 扩展列的属性继承自 base_attrtestcase_aclnn.pytestcase_e2e.py 通过 TensorApiTestcaseBase 继承),因此 base_attr 中设置的属性也会被扩展列覆盖。

测试

  • 新增 tests/test_extended_attributes.py,对 Kernel / ACLNN / E2E 三种模式的 Testcase 类进行参数化测试,覆盖以下场景:
    • attributes + attributes1 ~ attributes9 列在 complete_headers 中声明(test_headers_declared
    • 基本合并:attributes1 追加到 attributestest_merge_basic
    • 覆盖基础属性:扩展列覆盖 attributes 中的同名 key(test_merge_override_with_base
    • 扩展列间覆盖:attributes2 覆盖 attributes1 中的 key(test_override_across_extended_columns
    • 跨列链式覆盖:attributes9 覆盖 attributes5 覆盖 attributes1test_override_chain_last_wins
    • 多列无冲突合并(test_multi_column_merge
    • 无扩展列时保持原始 attributes 不变(test_no_extension_leaves_attributes
    • attributes 为 None 时,扩展列直接成为 attributestest_merge_when_attributes_none
    • 无效行跳过合并(test_skip_when_invalid
    • validate() 自动调用合并逻辑(test_validate_invokes_merge

文档更新

类型标签

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 FishPotatoChen 的贡献)
FishPotatoChenFishPotatoChen
11 天前 创建了 pull request,commit b48d17f5
atomgit-bot
atomgit-bot
11 天前 评论:

变更摘要

此 PR 为 CSV 用例新增 attributes1~attributes9 共 9 个扩展属性列,允许将算子属性拆分到多个列中写入,提升可读性和编辑体验。在 TestcaseBase.validate() 阶段通过新增的 _merge_extended_attributes() 方法按 attributesattributes1 → … → attributes9 顺序合并,key 冲突时后续列覆盖前列(last-wins 语义),无效行跳过合并。三种测试模式类(TestcaseOpTestcaseAclnnTestcaseE2e)均声明了扩展字段,类型为可选 dict,默认值为 None{},向后兼容。

主要改动

  • TestcaseBase._merge_extended_attributes() 新增合并逻辑:在 testcase_base.pyvalidate() 中调用该新方法,遍历 attributes1~attributes9 并用 dict.update() 依次合并到 attributes,实现后续列覆盖前列的 last-wins 语义;若 is_valid=False 则直接返回,不执行合并。
  • TestcaseOp 声明扩展列:在 __slots__complete_headersattr_property_headers__init__ 中新增 attributes1~attributes9 字段,类型均为 Optional[dict],默认 None,并通过 **{f"attributes{i}": ...} 字典解包方式在 attr_property_headers 中统一注册为 FIELD_TYPES.DICT 类型。
  • TestcaseAclnn 声明扩展列:在 complete_headersattr_property_headers__init__ 中新增 attributes1~attributes9,注册方式与 TestcaseOp 一致,扩展列继承自 TensorApiTestcaseBasebase_attr 属性体系。
  • TestcaseE2e 声明扩展列:在 __slots__attr_headers__init__ 中新增 attributes1~attributes9,初始化默认值为 None,同样采用字典解包方式注册类型定义。
  • 新增测试文件 tests/test_extended_attributes.py:对三种 Testcase 类进行参数化测试,覆盖扩展列声明检查、基本合并、覆盖基础属性、跨扩展列覆盖、链式覆盖、多列无冲突合并、无扩展列保持原值、attributesNone 时的合并、无效行跳过以及 validate() 自动触发合并共 10 个场景。
likedislike
atomgit-bot
atomgit-bot
11 天前 评论:

代码审查

✅ 未发现问题

likedislike
CANN-robotCANN-robot成员
11 天前 添加了label:cann-cla/yes
CANN-robot
CANN-robot成员
11 天前 评论:

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.
For more, you also can visit HICANN.


PR Approval Progress

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

Module Approval Details

module lgtm status approve status
repo-cann/ops-test-kit 陈琦, 王瑞 (2/2) 王瑞, 陈琦 (2/1)

💡 Tip:

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

CLA Signature Pass

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

likedislike
此处折叠了62条消息 查看更多
RuiWang_成员
3 天前 评论:

/lgtm
/approve

likedislike
CANN-robotCANN-robot成员
3 天前 添加了label:approved
chenqi317成员
3 天前 评论:

/lgtm
/approve

likedislike
CANN-robotCANN-robot成员
3 天前 添加了label:lgtm
CANN-robotCANN-robot成员
3 天前 合入了pull request