| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
【同步】【非开发代码】代码从 develop 同步到 master Co-authored-by: yydyzr<liuyuncong1@huawei.com> Co-authored-by: gcw_61YBRfIt<chuzhenxing@huawei.com> Co-authored-by: 孔炳翔<1120200577@qq.com> Co-authored-by: zhengxinqian<qianzhengxin@huawei.com> Co-authored-by: hw_whx<wanghexiang7@huawei.com> Co-authored-by: jgong5<steven.gong@gmail.com> Co-authored-by: hw_whx<2952154980@qq.com> # message auto-generated for no-merge-commit merge: !330 merge master into master 【同步】【非开发代码】代码从 develop 同步到 master Created-by: AvadaKedavrua Commit-by: liujiawang;ascend-robot;AvadaKedavrua;lutean;Horacehxw;eveyin1;minghang_c;zwt__;tt0cool;elrond-g;jia_ya_nan;zhenyu_zhang;ChenHuiwen;wangshen001;Hudingyi;wendellX;Secluded_Ocean;jhon-117;yaohan404;jiangruitao;zhenghaojie;stormchasingg;panyj1993;cmh1056291129;yuyinkai1;sunguozhong;genius52;liu_jiaxu;HongMaoShuiGuai;zhengxinqian;weixin_43368449;jsez-li-bin;jgong5;wqh17101;w00609794;yydyzr;JieZhang679;sppedforcy;gcw_61YBRfIt;Jiong Gong;hw_whx;gongjiong;孔炳翔 Merged-by: ascend-robot Description: 代码从 develop 同步到 master,后续基于 master 演进,并支持打包 See merge request: Ascend/msmodeling!330 | 17 天前 | |
【REFACTOR】重构 CI gate 与 test_map 同步基础设施 Co-authored-by: AvadaKedavrua<anonymousdev@163.com> # message auto-generated for no-merge-commit merge: !394 merge fix into master 【REFACTOR】重构 CI gate 与 test_map 同步基础设施 Created-by: AvadaKedavrua Commit-by: liujiawang;AvadaKedavrua Merged-by: ascend-robot Description: ## 修改原因 CI gate 的 diff 分类、策略校验、PR 评论、test_map 同步等逻辑耦合在 gate_policy.py 等单体模块中,难以独立演进与单测;test_map 缺少独立同步入口;ast_utils / test_map_loader / nightly 报告链路也需要与 gate 策略对齐。本 PR 仅包含 commit 82757732b6b6beb79b7083f6046e9cd9c72005f3(refactor),不涉及 wheel/CLI/OptiX 变更。 --- ## test_map schema 重构:背景与收益 ### 背景 旧 test_map 以**产品源文件**为顶层 key,value 为 symbol → [test_nodes]: json { "tensor_cast/foo.py": { "Widget::run": ["tests/regression/.../test_x.py::test_foo"] } } 新 test_map 改为以 **pytest node id** 为顶层 key,value 为 source_file → [symbols],与 coverage.py --cov-context=test 的采集方向一致: json { "tests/regression/.../test_x.py::test_foo": { "tensor_cast/foo.py": ["Widget::run"] } } 两者存的是同一张「测试节点 ↔ (源文件, symbol)」二部图,仅主键方向相反;边数相同,语义不变。 ### 为何行数变多、体积反而更小 | 指标 | 旧 schema(source-oriented) | 新 schema(node-oriented) | |------|------------------------------|----------------------------| | JSON 行数 | ~7 万行 | ~10 万行 | | 文件/内存占用 | **8,355,104 B(~8.0 MB)** | **3,748,221 B(~3.6 MB,约 -55%)** | 行数不是体积的可靠 proxy。旧格式在每个 symbol 下重复存储完整 pytest node id(tests/regression/.../test_xxx.py::Class::test_yyy,通常 60–80 字符);同一 test 覆盖 N 个 symbol 时,该长字符串出现 N 次。新格式每个 test node id 只作为顶层 key 出现一次,数组里存的是短 canonical symbol(如 Widget::run、%),边数 E 不变但**长字符串重复次数从 O(E) 降到 O(T)**(T = 有覆盖的 test 数,T ≪ E)。 典型场景:大量 smoke/regression 用例通过 import 共享 tensor_cast/、cli/ 等模块的 module symbol %——旧格式在单个 symbol 下聚合成千上万条 test id;新格式每个 test 只记一次短 symbol,整体字节数显著下降。 ### 工程收益 1. **构建零 pivot**:build_test_map.collect_from_coverage 直接按 coverage context(test node)聚合 by_test[nid][source].add(symbol),与 nightly phase1 采集路径一致。 2. **增量 sync 更自然**:sync.apply_incremental_test_map_update 对 touched test 文件整 node 替换、对 touched product 文件按 (test_node, source_path) 合并,无需在两种索引间来回转换。 3. **删 test / 冗余检测更直接**:gate_deleted_tests、detect_redundant_cases 按 test footprint 遍历;test_map_loader 强制顶层为 tests/...::...,可拒绝误写成 source key 的脏数据。 4. **CI gate 查询无退化**:symbol → tests 反向查询通过 build_test_map_index 一次 O(N) 建索引,与旧 schema 运行时等价。 5. **存储与传输更轻**:实测文件体积约减半,OBS 下载与 json.loads 内存峰值更低。 --- ## 修改内容 ### CI gate 模块拆分 - gate_policy.py 瘦身:策略加载/校验迁入 policy.py,diff 分类迁入 classifier.py,GitCode PR 评论迁入 comments.py,test_map 查询迁入 test_map_query.py - 新增 sync.py + scripts/run_test_map_sync.sh:按目标分支 HEAD 维护权威 test_map(--once / --watch) - diff.py 精简,仅保留 git diff 与分支检出能力 - main.py / rules.py / models.py / errors.py 适配新模块边界 - tests/.ci/gate_policy.yaml 策略字段同步调整 ### 公共 helpers 增强 - _config.py:手写 env 解析改为 pydantic-settings,统一校验与错误信息 - ast_utils.py:扩展符号提取能力,支撑 test_map 粒度映射 - build_test_map.py / test_map_loader.py:重构收集与加载逻辑(node-oriented schema) - 新增 test_map_report.py:test_map 覆盖率汇总、过期豁免检测 - coverage_symbol_check.py / pytest_runner.py / test_map_config.py 对齐新数据结构 - common/_logging.py:补充 log_env_audit 环境审计日志 ### nightly 报告链路 - report_builder.py / pytest_parser.py / main.py:适配 node-oriented test_map 报告 - report_models.py / feishu_notifier.py 小幅对齐 ### symbol 校验与 exemption 漂移(新增) - **last-wins canonical symbols**:重复 def foo 仅 gate 最后一个定义;shadowed def 发非 blocking GitCode 评论 - **def _ 消歧**:无 decorator → _;有 decorator → _@<suffix> - **exemption 校验**:path::symbol 整串须为 AST canonical name;coverage omit 路径禁止写入 exemptions.sources - **exemption 漂移 blocking**:PR 删/改名 product/test 文件时,未同步更新 gate_policy.yaml → [ED] 硬阻断 + GitCode 评论 - **Expected/Got**:Config / policy / loader 类型与值错误统一格式 - **文档**:scripts/README.md 补充 build.sh、MSMODELING_WHEEL_OUTPUT_DIR;tests/README.md 补充 symbol 契约 ### 其他 - scripts/run_ci_gate.sh:入口参数对齐 - scripts/prefetch_model_configs.py:适配新 config 加载 - tests/README.md / tests/SKILL.md:文档同步 - 新增/更新回归测试:test_classifier.py、test_comments.py、test_policy.py、test_sync.py、test_test_map_query.py、test_test_map_report.py 等 --- ## 自验证 ### CI gate / test_map / nightly 回归测试 目的:确认模块拆分后行为不变,新模块有单测覆盖 步骤: 1. 在仓库根目录执行: sh uv run pytest tests/regression/scripts/helpers/ci_gate/ \ tests/regression/scripts/helpers/common/test_ast_utils.py \ tests/regression/scripts/helpers/common/test_test_map_loader.py \ tests/regression/scripts/helpers/nightly/test_report_builder.py -q 2. 检查退出码与通过数 结果: 206 passed, 7 warnings in 0.43s ### symbol 校验 / exemption 漂移回归 sh uv run pytest tests/regression/scripts/helpers/ci_gate/ \ tests/regression/scripts/helpers/common/test_ast_utils.py \ tests/regression/scripts/helpers/common/test_test_map_loader.py \ tests/regression/scripts/helpers/test_config.py -q 结果: 239 passed, 8 warnings in 1.05s ### test_map 同步入口 目的:确认 run_test_map_sync.sh 可正常拉起 sync.py 步骤: 1. 设置 MSMODELING_TEST_MAP_PATH 指向有效 test_map JSON 2. 执行 bash scripts/run_test_map_sync.sh --once 结果:脚本入口与 sync.py CLI 已随 PR 提交;完整同步需 CI/nightly 环境提供有效 test_map 文件 See merge request: Ascend/msmodeling!394 | 6 天前 | |
【REFACTOR】重构 CI gate 与 test_map 同步基础设施 Co-authored-by: AvadaKedavrua<anonymousdev@163.com> # message auto-generated for no-merge-commit merge: !394 merge fix into master 【REFACTOR】重构 CI gate 与 test_map 同步基础设施 Created-by: AvadaKedavrua Commit-by: liujiawang;AvadaKedavrua Merged-by: ascend-robot Description: ## 修改原因 CI gate 的 diff 分类、策略校验、PR 评论、test_map 同步等逻辑耦合在 gate_policy.py 等单体模块中,难以独立演进与单测;test_map 缺少独立同步入口;ast_utils / test_map_loader / nightly 报告链路也需要与 gate 策略对齐。本 PR 仅包含 commit 82757732b6b6beb79b7083f6046e9cd9c72005f3(refactor),不涉及 wheel/CLI/OptiX 变更。 --- ## test_map schema 重构:背景与收益 ### 背景 旧 test_map 以**产品源文件**为顶层 key,value 为 symbol → [test_nodes]: json { "tensor_cast/foo.py": { "Widget::run": ["tests/regression/.../test_x.py::test_foo"] } } 新 test_map 改为以 **pytest node id** 为顶层 key,value 为 source_file → [symbols],与 coverage.py --cov-context=test 的采集方向一致: json { "tests/regression/.../test_x.py::test_foo": { "tensor_cast/foo.py": ["Widget::run"] } } 两者存的是同一张「测试节点 ↔ (源文件, symbol)」二部图,仅主键方向相反;边数相同,语义不变。 ### 为何行数变多、体积反而更小 | 指标 | 旧 schema(source-oriented) | 新 schema(node-oriented) | |------|------------------------------|----------------------------| | JSON 行数 | ~7 万行 | ~10 万行 | | 文件/内存占用 | **8,355,104 B(~8.0 MB)** | **3,748,221 B(~3.6 MB,约 -55%)** | 行数不是体积的可靠 proxy。旧格式在每个 symbol 下重复存储完整 pytest node id(tests/regression/.../test_xxx.py::Class::test_yyy,通常 60–80 字符);同一 test 覆盖 N 个 symbol 时,该长字符串出现 N 次。新格式每个 test node id 只作为顶层 key 出现一次,数组里存的是短 canonical symbol(如 Widget::run、%),边数 E 不变但**长字符串重复次数从 O(E) 降到 O(T)**(T = 有覆盖的 test 数,T ≪ E)。 典型场景:大量 smoke/regression 用例通过 import 共享 tensor_cast/、cli/ 等模块的 module symbol %——旧格式在单个 symbol 下聚合成千上万条 test id;新格式每个 test 只记一次短 symbol,整体字节数显著下降。 ### 工程收益 1. **构建零 pivot**:build_test_map.collect_from_coverage 直接按 coverage context(test node)聚合 by_test[nid][source].add(symbol),与 nightly phase1 采集路径一致。 2. **增量 sync 更自然**:sync.apply_incremental_test_map_update 对 touched test 文件整 node 替换、对 touched product 文件按 (test_node, source_path) 合并,无需在两种索引间来回转换。 3. **删 test / 冗余检测更直接**:gate_deleted_tests、detect_redundant_cases 按 test footprint 遍历;test_map_loader 强制顶层为 tests/...::...,可拒绝误写成 source key 的脏数据。 4. **CI gate 查询无退化**:symbol → tests 反向查询通过 build_test_map_index 一次 O(N) 建索引,与旧 schema 运行时等价。 5. **存储与传输更轻**:实测文件体积约减半,OBS 下载与 json.loads 内存峰值更低。 --- ## 修改内容 ### CI gate 模块拆分 - gate_policy.py 瘦身:策略加载/校验迁入 policy.py,diff 分类迁入 classifier.py,GitCode PR 评论迁入 comments.py,test_map 查询迁入 test_map_query.py - 新增 sync.py + scripts/run_test_map_sync.sh:按目标分支 HEAD 维护权威 test_map(--once / --watch) - diff.py 精简,仅保留 git diff 与分支检出能力 - main.py / rules.py / models.py / errors.py 适配新模块边界 - tests/.ci/gate_policy.yaml 策略字段同步调整 ### 公共 helpers 增强 - _config.py:手写 env 解析改为 pydantic-settings,统一校验与错误信息 - ast_utils.py:扩展符号提取能力,支撑 test_map 粒度映射 - build_test_map.py / test_map_loader.py:重构收集与加载逻辑(node-oriented schema) - 新增 test_map_report.py:test_map 覆盖率汇总、过期豁免检测 - coverage_symbol_check.py / pytest_runner.py / test_map_config.py 对齐新数据结构 - common/_logging.py:补充 log_env_audit 环境审计日志 ### nightly 报告链路 - report_builder.py / pytest_parser.py / main.py:适配 node-oriented test_map 报告 - report_models.py / feishu_notifier.py 小幅对齐 ### symbol 校验与 exemption 漂移(新增) - **last-wins canonical symbols**:重复 def foo 仅 gate 最后一个定义;shadowed def 发非 blocking GitCode 评论 - **def _ 消歧**:无 decorator → _;有 decorator → _@<suffix> - **exemption 校验**:path::symbol 整串须为 AST canonical name;coverage omit 路径禁止写入 exemptions.sources - **exemption 漂移 blocking**:PR 删/改名 product/test 文件时,未同步更新 gate_policy.yaml → [ED] 硬阻断 + GitCode 评论 - **Expected/Got**:Config / policy / loader 类型与值错误统一格式 - **文档**:scripts/README.md 补充 build.sh、MSMODELING_WHEEL_OUTPUT_DIR;tests/README.md 补充 symbol 契约 ### 其他 - scripts/run_ci_gate.sh:入口参数对齐 - scripts/prefetch_model_configs.py:适配新 config 加载 - tests/README.md / tests/SKILL.md:文档同步 - 新增/更新回归测试:test_classifier.py、test_comments.py、test_policy.py、test_sync.py、test_test_map_query.py、test_test_map_report.py 等 --- ## 自验证 ### CI gate / test_map / nightly 回归测试 目的:确认模块拆分后行为不变,新模块有单测覆盖 步骤: 1. 在仓库根目录执行: sh uv run pytest tests/regression/scripts/helpers/ci_gate/ \ tests/regression/scripts/helpers/common/test_ast_utils.py \ tests/regression/scripts/helpers/common/test_test_map_loader.py \ tests/regression/scripts/helpers/nightly/test_report_builder.py -q 2. 检查退出码与通过数 结果: 206 passed, 7 warnings in 0.43s ### symbol 校验 / exemption 漂移回归 sh uv run pytest tests/regression/scripts/helpers/ci_gate/ \ tests/regression/scripts/helpers/common/test_ast_utils.py \ tests/regression/scripts/helpers/common/test_test_map_loader.py \ tests/regression/scripts/helpers/test_config.py -q 结果: 239 passed, 8 warnings in 1.05s ### test_map 同步入口 目的:确认 run_test_map_sync.sh 可正常拉起 sync.py 步骤: 1. 设置 MSMODELING_TEST_MAP_PATH 指向有效 test_map JSON 2. 执行 bash scripts/run_test_map_sync.sh --once 结果:脚本入口与 sync.py CLI 已随 PR 提交;完整同步需 CI/nightly 环境提供有效 test_map 文件 See merge request: Ascend/msmodeling!394 | 6 天前 | |
【REFACTOR】重构 CI gate 与 test_map 同步基础设施 Co-authored-by: AvadaKedavrua<anonymousdev@163.com> # message auto-generated for no-merge-commit merge: !394 merge fix into master 【REFACTOR】重构 CI gate 与 test_map 同步基础设施 Created-by: AvadaKedavrua Commit-by: liujiawang;AvadaKedavrua Merged-by: ascend-robot Description: ## 修改原因 CI gate 的 diff 分类、策略校验、PR 评论、test_map 同步等逻辑耦合在 gate_policy.py 等单体模块中,难以独立演进与单测;test_map 缺少独立同步入口;ast_utils / test_map_loader / nightly 报告链路也需要与 gate 策略对齐。本 PR 仅包含 commit 82757732b6b6beb79b7083f6046e9cd9c72005f3(refactor),不涉及 wheel/CLI/OptiX 变更。 --- ## test_map schema 重构:背景与收益 ### 背景 旧 test_map 以**产品源文件**为顶层 key,value 为 symbol → [test_nodes]: json { "tensor_cast/foo.py": { "Widget::run": ["tests/regression/.../test_x.py::test_foo"] } } 新 test_map 改为以 **pytest node id** 为顶层 key,value 为 source_file → [symbols],与 coverage.py --cov-context=test 的采集方向一致: json { "tests/regression/.../test_x.py::test_foo": { "tensor_cast/foo.py": ["Widget::run"] } } 两者存的是同一张「测试节点 ↔ (源文件, symbol)」二部图,仅主键方向相反;边数相同,语义不变。 ### 为何行数变多、体积反而更小 | 指标 | 旧 schema(source-oriented) | 新 schema(node-oriented) | |------|------------------------------|----------------------------| | JSON 行数 | ~7 万行 | ~10 万行 | | 文件/内存占用 | **8,355,104 B(~8.0 MB)** | **3,748,221 B(~3.6 MB,约 -55%)** | 行数不是体积的可靠 proxy。旧格式在每个 symbol 下重复存储完整 pytest node id(tests/regression/.../test_xxx.py::Class::test_yyy,通常 60–80 字符);同一 test 覆盖 N 个 symbol 时,该长字符串出现 N 次。新格式每个 test node id 只作为顶层 key 出现一次,数组里存的是短 canonical symbol(如 Widget::run、%),边数 E 不变但**长字符串重复次数从 O(E) 降到 O(T)**(T = 有覆盖的 test 数,T ≪ E)。 典型场景:大量 smoke/regression 用例通过 import 共享 tensor_cast/、cli/ 等模块的 module symbol %——旧格式在单个 symbol 下聚合成千上万条 test id;新格式每个 test 只记一次短 symbol,整体字节数显著下降。 ### 工程收益 1. **构建零 pivot**:build_test_map.collect_from_coverage 直接按 coverage context(test node)聚合 by_test[nid][source].add(symbol),与 nightly phase1 采集路径一致。 2. **增量 sync 更自然**:sync.apply_incremental_test_map_update 对 touched test 文件整 node 替换、对 touched product 文件按 (test_node, source_path) 合并,无需在两种索引间来回转换。 3. **删 test / 冗余检测更直接**:gate_deleted_tests、detect_redundant_cases 按 test footprint 遍历;test_map_loader 强制顶层为 tests/...::...,可拒绝误写成 source key 的脏数据。 4. **CI gate 查询无退化**:symbol → tests 反向查询通过 build_test_map_index 一次 O(N) 建索引,与旧 schema 运行时等价。 5. **存储与传输更轻**:实测文件体积约减半,OBS 下载与 json.loads 内存峰值更低。 --- ## 修改内容 ### CI gate 模块拆分 - gate_policy.py 瘦身:策略加载/校验迁入 policy.py,diff 分类迁入 classifier.py,GitCode PR 评论迁入 comments.py,test_map 查询迁入 test_map_query.py - 新增 sync.py + scripts/run_test_map_sync.sh:按目标分支 HEAD 维护权威 test_map(--once / --watch) - diff.py 精简,仅保留 git diff 与分支检出能力 - main.py / rules.py / models.py / errors.py 适配新模块边界 - tests/.ci/gate_policy.yaml 策略字段同步调整 ### 公共 helpers 增强 - _config.py:手写 env 解析改为 pydantic-settings,统一校验与错误信息 - ast_utils.py:扩展符号提取能力,支撑 test_map 粒度映射 - build_test_map.py / test_map_loader.py:重构收集与加载逻辑(node-oriented schema) - 新增 test_map_report.py:test_map 覆盖率汇总、过期豁免检测 - coverage_symbol_check.py / pytest_runner.py / test_map_config.py 对齐新数据结构 - common/_logging.py:补充 log_env_audit 环境审计日志 ### nightly 报告链路 - report_builder.py / pytest_parser.py / main.py:适配 node-oriented test_map 报告 - report_models.py / feishu_notifier.py 小幅对齐 ### symbol 校验与 exemption 漂移(新增) - **last-wins canonical symbols**:重复 def foo 仅 gate 最后一个定义;shadowed def 发非 blocking GitCode 评论 - **def _ 消歧**:无 decorator → _;有 decorator → _@<suffix> - **exemption 校验**:path::symbol 整串须为 AST canonical name;coverage omit 路径禁止写入 exemptions.sources - **exemption 漂移 blocking**:PR 删/改名 product/test 文件时,未同步更新 gate_policy.yaml → [ED] 硬阻断 + GitCode 评论 - **Expected/Got**:Config / policy / loader 类型与值错误统一格式 - **文档**:scripts/README.md 补充 build.sh、MSMODELING_WHEEL_OUTPUT_DIR;tests/README.md 补充 symbol 契约 ### 其他 - scripts/run_ci_gate.sh:入口参数对齐 - scripts/prefetch_model_configs.py:适配新 config 加载 - tests/README.md / tests/SKILL.md:文档同步 - 新增/更新回归测试:test_classifier.py、test_comments.py、test_policy.py、test_sync.py、test_test_map_query.py、test_test_map_report.py 等 --- ## 自验证 ### CI gate / test_map / nightly 回归测试 目的:确认模块拆分后行为不变,新模块有单测覆盖 步骤: 1. 在仓库根目录执行: sh uv run pytest tests/regression/scripts/helpers/ci_gate/ \ tests/regression/scripts/helpers/common/test_ast_utils.py \ tests/regression/scripts/helpers/common/test_test_map_loader.py \ tests/regression/scripts/helpers/nightly/test_report_builder.py -q 2. 检查退出码与通过数 结果: 206 passed, 7 warnings in 0.43s ### symbol 校验 / exemption 漂移回归 sh uv run pytest tests/regression/scripts/helpers/ci_gate/ \ tests/regression/scripts/helpers/common/test_ast_utils.py \ tests/regression/scripts/helpers/common/test_test_map_loader.py \ tests/regression/scripts/helpers/test_config.py -q 结果: 239 passed, 8 warnings in 1.05s ### test_map 同步入口 目的:确认 run_test_map_sync.sh 可正常拉起 sync.py 步骤: 1. 设置 MSMODELING_TEST_MAP_PATH 指向有效 test_map JSON 2. 执行 bash scripts/run_test_map_sync.sh --once 结果:脚本入口与 sync.py CLI 已随 PR 提交;完整同步需 CI/nightly 环境提供有效 test_map 文件 See merge request: Ascend/msmodeling!394 | 6 天前 | |
【FIX】加固 CI gate 选择与 coverage/nightly 策略 Co-authored-by: AvadaKedavrua<anonymousdev@163.com> # message auto-generated for no-merge-commit merge: !354 merge fix into master 【FIX】加固 CI gate 选择与 coverage/nightly 策略 Created-by: AvadaKedavrua Commit-by: liujiawang;AvadaKedavrua Merged-by: ascend-robot Description: ## 修改原因 CI gate / coverage / nightly 脚本在增量跑测、多 wave coverage 合并、test_map 绑定与 nightly 退出策略上存在边界缺陷,可能导致漏跑、覆盖率被覆盖、或 nightly 因网络阶段误报整体失败。另:ruff 重构时 report_builder 误用 Python 3.11 的 datetime.UTC,与项目 requires-python >= 3.10 不兼容。 --- ## 修改内容 - **CI gate diff 解析**:识别 delete-only diff、浅克隆 merge-base 失败、越界 source;gate_policy/scripts/helpers 变更触发全量 - **Coverage**:多 wave pytest coverage 追加合并;test_map 绑定 built_from_commit 并校验新鲜度;coverage fallback 要求 pytest test context - **Changed-test wave**:变更测试文件跑全量非 npu case,保留 regression wave marker;排除 network/nightly - **Nightly**:整体退出与 network phase 解耦;prefetch 模型 ID 走 allowlist - **Lint/兼容**:复杂度拆分、TYPE_CHECKING 导入、tomllib 回退、脚本可执行;report_builder 改回 timezone.utc(3.10 兼容) 涉及 scripts/helpers/ci_gate/、scripts/helpers/common/、scripts/helpers/nightly/、scripts/prefetch_model_configs.py、scripts/run_ci_gate.sh 及对应 regression tests。 --- ## 自验证 ### nightly report_builder Python 3.10 兼容 目的:确认 fetch_env_info 在 3.10 语义下可 import,不再依赖 datetime.UTC。 步骤: 1. 修改 scripts/helpers/nightly/report_builder.py 使用 timezone.utc 2. 以 target-version=py310 运行 ruff lint 3. 执行 import + fetch_env_info 冒烟 bash uv run python -c "from scripts.helpers.nightly.report_builder import fetch_env_info; print(fetch_env_info())" 结果:import 成功,timestamp 含 +00:00;ruff lint passed。 ### CI gate diff + nightly report_builder 回归 目的:覆盖 diff 解析与 nightly 报告辅助逻辑,防止 gate 选择与报告流程回归。 步骤: 1. 安装 ci 依赖:uv sync --frozen --group ci 2. 运行相关 regression tests bash uv run python -m pytest tests/regression/scripts/helpers/nightly/test_report_builder.py tests/regression/scripts/helpers/ci_gate/test_diff.py -q 结果:  See merge request: Ascend/msmodeling!354 | 14 天前 | |
【FIX】加固 CI gate 选择与 coverage/nightly 策略 Co-authored-by: AvadaKedavrua<anonymousdev@163.com> # message auto-generated for no-merge-commit merge: !354 merge fix into master 【FIX】加固 CI gate 选择与 coverage/nightly 策略 Created-by: AvadaKedavrua Commit-by: liujiawang;AvadaKedavrua Merged-by: ascend-robot Description: ## 修改原因 CI gate / coverage / nightly 脚本在增量跑测、多 wave coverage 合并、test_map 绑定与 nightly 退出策略上存在边界缺陷,可能导致漏跑、覆盖率被覆盖、或 nightly 因网络阶段误报整体失败。另:ruff 重构时 report_builder 误用 Python 3.11 的 datetime.UTC,与项目 requires-python >= 3.10 不兼容。 --- ## 修改内容 - **CI gate diff 解析**:识别 delete-only diff、浅克隆 merge-base 失败、越界 source;gate_policy/scripts/helpers 变更触发全量 - **Coverage**:多 wave pytest coverage 追加合并;test_map 绑定 built_from_commit 并校验新鲜度;coverage fallback 要求 pytest test context - **Changed-test wave**:变更测试文件跑全量非 npu case,保留 regression wave marker;排除 network/nightly - **Nightly**:整体退出与 network phase 解耦;prefetch 模型 ID 走 allowlist - **Lint/兼容**:复杂度拆分、TYPE_CHECKING 导入、tomllib 回退、脚本可执行;report_builder 改回 timezone.utc(3.10 兼容) 涉及 scripts/helpers/ci_gate/、scripts/helpers/common/、scripts/helpers/nightly/、scripts/prefetch_model_configs.py、scripts/run_ci_gate.sh 及对应 regression tests。 --- ## 自验证 ### nightly report_builder Python 3.10 兼容 目的:确认 fetch_env_info 在 3.10 语义下可 import,不再依赖 datetime.UTC。 步骤: 1. 修改 scripts/helpers/nightly/report_builder.py 使用 timezone.utc 2. 以 target-version=py310 运行 ruff lint 3. 执行 import + fetch_env_info 冒烟 bash uv run python -c "from scripts.helpers.nightly.report_builder import fetch_env_info; print(fetch_env_info())" 结果:import 成功,timestamp 含 +00:00;ruff lint passed。 ### CI gate diff + nightly report_builder 回归 目的:覆盖 diff 解析与 nightly 报告辅助逻辑,防止 gate 选择与报告流程回归。 步骤: 1. 安装 ci 依赖:uv sync --frozen --group ci 2. 运行相关 regression tests bash uv run python -m pytest tests/regression/scripts/helpers/nightly/test_report_builder.py tests/regression/scripts/helpers/ci_gate/test_diff.py -q 结果:  See merge request: Ascend/msmodeling!354 | 14 天前 | |
【REFACTOR】重构 CI gate 与 test_map 同步基础设施 Co-authored-by: AvadaKedavrua<anonymousdev@163.com> # message auto-generated for no-merge-commit merge: !394 merge fix into master 【REFACTOR】重构 CI gate 与 test_map 同步基础设施 Created-by: AvadaKedavrua Commit-by: liujiawang;AvadaKedavrua Merged-by: ascend-robot Description: ## 修改原因 CI gate 的 diff 分类、策略校验、PR 评论、test_map 同步等逻辑耦合在 gate_policy.py 等单体模块中,难以独立演进与单测;test_map 缺少独立同步入口;ast_utils / test_map_loader / nightly 报告链路也需要与 gate 策略对齐。本 PR 仅包含 commit 82757732b6b6beb79b7083f6046e9cd9c72005f3(refactor),不涉及 wheel/CLI/OptiX 变更。 --- ## test_map schema 重构:背景与收益 ### 背景 旧 test_map 以**产品源文件**为顶层 key,value 为 symbol → [test_nodes]: json { "tensor_cast/foo.py": { "Widget::run": ["tests/regression/.../test_x.py::test_foo"] } } 新 test_map 改为以 **pytest node id** 为顶层 key,value 为 source_file → [symbols],与 coverage.py --cov-context=test 的采集方向一致: json { "tests/regression/.../test_x.py::test_foo": { "tensor_cast/foo.py": ["Widget::run"] } } 两者存的是同一张「测试节点 ↔ (源文件, symbol)」二部图,仅主键方向相反;边数相同,语义不变。 ### 为何行数变多、体积反而更小 | 指标 | 旧 schema(source-oriented) | 新 schema(node-oriented) | |------|------------------------------|----------------------------| | JSON 行数 | ~7 万行 | ~10 万行 | | 文件/内存占用 | **8,355,104 B(~8.0 MB)** | **3,748,221 B(~3.6 MB,约 -55%)** | 行数不是体积的可靠 proxy。旧格式在每个 symbol 下重复存储完整 pytest node id(tests/regression/.../test_xxx.py::Class::test_yyy,通常 60–80 字符);同一 test 覆盖 N 个 symbol 时,该长字符串出现 N 次。新格式每个 test node id 只作为顶层 key 出现一次,数组里存的是短 canonical symbol(如 Widget::run、%),边数 E 不变但**长字符串重复次数从 O(E) 降到 O(T)**(T = 有覆盖的 test 数,T ≪ E)。 典型场景:大量 smoke/regression 用例通过 import 共享 tensor_cast/、cli/ 等模块的 module symbol %——旧格式在单个 symbol 下聚合成千上万条 test id;新格式每个 test 只记一次短 symbol,整体字节数显著下降。 ### 工程收益 1. **构建零 pivot**:build_test_map.collect_from_coverage 直接按 coverage context(test node)聚合 by_test[nid][source].add(symbol),与 nightly phase1 采集路径一致。 2. **增量 sync 更自然**:sync.apply_incremental_test_map_update 对 touched test 文件整 node 替换、对 touched product 文件按 (test_node, source_path) 合并,无需在两种索引间来回转换。 3. **删 test / 冗余检测更直接**:gate_deleted_tests、detect_redundant_cases 按 test footprint 遍历;test_map_loader 强制顶层为 tests/...::...,可拒绝误写成 source key 的脏数据。 4. **CI gate 查询无退化**:symbol → tests 反向查询通过 build_test_map_index 一次 O(N) 建索引,与旧 schema 运行时等价。 5. **存储与传输更轻**:实测文件体积约减半,OBS 下载与 json.loads 内存峰值更低。 --- ## 修改内容 ### CI gate 模块拆分 - gate_policy.py 瘦身:策略加载/校验迁入 policy.py,diff 分类迁入 classifier.py,GitCode PR 评论迁入 comments.py,test_map 查询迁入 test_map_query.py - 新增 sync.py + scripts/run_test_map_sync.sh:按目标分支 HEAD 维护权威 test_map(--once / --watch) - diff.py 精简,仅保留 git diff 与分支检出能力 - main.py / rules.py / models.py / errors.py 适配新模块边界 - tests/.ci/gate_policy.yaml 策略字段同步调整 ### 公共 helpers 增强 - _config.py:手写 env 解析改为 pydantic-settings,统一校验与错误信息 - ast_utils.py:扩展符号提取能力,支撑 test_map 粒度映射 - build_test_map.py / test_map_loader.py:重构收集与加载逻辑(node-oriented schema) - 新增 test_map_report.py:test_map 覆盖率汇总、过期豁免检测 - coverage_symbol_check.py / pytest_runner.py / test_map_config.py 对齐新数据结构 - common/_logging.py:补充 log_env_audit 环境审计日志 ### nightly 报告链路 - report_builder.py / pytest_parser.py / main.py:适配 node-oriented test_map 报告 - report_models.py / feishu_notifier.py 小幅对齐 ### symbol 校验与 exemption 漂移(新增) - **last-wins canonical symbols**:重复 def foo 仅 gate 最后一个定义;shadowed def 发非 blocking GitCode 评论 - **def _ 消歧**:无 decorator → _;有 decorator → _@<suffix> - **exemption 校验**:path::symbol 整串须为 AST canonical name;coverage omit 路径禁止写入 exemptions.sources - **exemption 漂移 blocking**:PR 删/改名 product/test 文件时,未同步更新 gate_policy.yaml → [ED] 硬阻断 + GitCode 评论 - **Expected/Got**:Config / policy / loader 类型与值错误统一格式 - **文档**:scripts/README.md 补充 build.sh、MSMODELING_WHEEL_OUTPUT_DIR;tests/README.md 补充 symbol 契约 ### 其他 - scripts/run_ci_gate.sh:入口参数对齐 - scripts/prefetch_model_configs.py:适配新 config 加载 - tests/README.md / tests/SKILL.md:文档同步 - 新增/更新回归测试:test_classifier.py、test_comments.py、test_policy.py、test_sync.py、test_test_map_query.py、test_test_map_report.py 等 --- ## 自验证 ### CI gate / test_map / nightly 回归测试 目的:确认模块拆分后行为不变,新模块有单测覆盖 步骤: 1. 在仓库根目录执行: sh uv run pytest tests/regression/scripts/helpers/ci_gate/ \ tests/regression/scripts/helpers/common/test_ast_utils.py \ tests/regression/scripts/helpers/common/test_test_map_loader.py \ tests/regression/scripts/helpers/nightly/test_report_builder.py -q 2. 检查退出码与通过数 结果: 206 passed, 7 warnings in 0.43s ### symbol 校验 / exemption 漂移回归 sh uv run pytest tests/regression/scripts/helpers/ci_gate/ \ tests/regression/scripts/helpers/common/test_ast_utils.py \ tests/regression/scripts/helpers/common/test_test_map_loader.py \ tests/regression/scripts/helpers/test_config.py -q 结果: 239 passed, 8 warnings in 1.05s ### test_map 同步入口 目的:确认 run_test_map_sync.sh 可正常拉起 sync.py 步骤: 1. 设置 MSMODELING_TEST_MAP_PATH 指向有效 test_map JSON 2. 执行 bash scripts/run_test_map_sync.sh --once 结果:脚本入口与 sync.py CLI 已随 PR 提交;完整同步需 CI/nightly 环境提供有效 test_map 文件 See merge request: Ascend/msmodeling!394 | 6 天前 | |
【REFACTOR】重构 CI gate 与 test_map 同步基础设施 Co-authored-by: AvadaKedavrua<anonymousdev@163.com> # message auto-generated for no-merge-commit merge: !394 merge fix into master 【REFACTOR】重构 CI gate 与 test_map 同步基础设施 Created-by: AvadaKedavrua Commit-by: liujiawang;AvadaKedavrua Merged-by: ascend-robot Description: ## 修改原因 CI gate 的 diff 分类、策略校验、PR 评论、test_map 同步等逻辑耦合在 gate_policy.py 等单体模块中,难以独立演进与单测;test_map 缺少独立同步入口;ast_utils / test_map_loader / nightly 报告链路也需要与 gate 策略对齐。本 PR 仅包含 commit 82757732b6b6beb79b7083f6046e9cd9c72005f3(refactor),不涉及 wheel/CLI/OptiX 变更。 --- ## test_map schema 重构:背景与收益 ### 背景 旧 test_map 以**产品源文件**为顶层 key,value 为 symbol → [test_nodes]: json { "tensor_cast/foo.py": { "Widget::run": ["tests/regression/.../test_x.py::test_foo"] } } 新 test_map 改为以 **pytest node id** 为顶层 key,value 为 source_file → [symbols],与 coverage.py --cov-context=test 的采集方向一致: json { "tests/regression/.../test_x.py::test_foo": { "tensor_cast/foo.py": ["Widget::run"] } } 两者存的是同一张「测试节点 ↔ (源文件, symbol)」二部图,仅主键方向相反;边数相同,语义不变。 ### 为何行数变多、体积反而更小 | 指标 | 旧 schema(source-oriented) | 新 schema(node-oriented) | |------|------------------------------|----------------------------| | JSON 行数 | ~7 万行 | ~10 万行 | | 文件/内存占用 | **8,355,104 B(~8.0 MB)** | **3,748,221 B(~3.6 MB,约 -55%)** | 行数不是体积的可靠 proxy。旧格式在每个 symbol 下重复存储完整 pytest node id(tests/regression/.../test_xxx.py::Class::test_yyy,通常 60–80 字符);同一 test 覆盖 N 个 symbol 时,该长字符串出现 N 次。新格式每个 test node id 只作为顶层 key 出现一次,数组里存的是短 canonical symbol(如 Widget::run、%),边数 E 不变但**长字符串重复次数从 O(E) 降到 O(T)**(T = 有覆盖的 test 数,T ≪ E)。 典型场景:大量 smoke/regression 用例通过 import 共享 tensor_cast/、cli/ 等模块的 module symbol %——旧格式在单个 symbol 下聚合成千上万条 test id;新格式每个 test 只记一次短 symbol,整体字节数显著下降。 ### 工程收益 1. **构建零 pivot**:build_test_map.collect_from_coverage 直接按 coverage context(test node)聚合 by_test[nid][source].add(symbol),与 nightly phase1 采集路径一致。 2. **增量 sync 更自然**:sync.apply_incremental_test_map_update 对 touched test 文件整 node 替换、对 touched product 文件按 (test_node, source_path) 合并,无需在两种索引间来回转换。 3. **删 test / 冗余检测更直接**:gate_deleted_tests、detect_redundant_cases 按 test footprint 遍历;test_map_loader 强制顶层为 tests/...::...,可拒绝误写成 source key 的脏数据。 4. **CI gate 查询无退化**:symbol → tests 反向查询通过 build_test_map_index 一次 O(N) 建索引,与旧 schema 运行时等价。 5. **存储与传输更轻**:实测文件体积约减半,OBS 下载与 json.loads 内存峰值更低。 --- ## 修改内容 ### CI gate 模块拆分 - gate_policy.py 瘦身:策略加载/校验迁入 policy.py,diff 分类迁入 classifier.py,GitCode PR 评论迁入 comments.py,test_map 查询迁入 test_map_query.py - 新增 sync.py + scripts/run_test_map_sync.sh:按目标分支 HEAD 维护权威 test_map(--once / --watch) - diff.py 精简,仅保留 git diff 与分支检出能力 - main.py / rules.py / models.py / errors.py 适配新模块边界 - tests/.ci/gate_policy.yaml 策略字段同步调整 ### 公共 helpers 增强 - _config.py:手写 env 解析改为 pydantic-settings,统一校验与错误信息 - ast_utils.py:扩展符号提取能力,支撑 test_map 粒度映射 - build_test_map.py / test_map_loader.py:重构收集与加载逻辑(node-oriented schema) - 新增 test_map_report.py:test_map 覆盖率汇总、过期豁免检测 - coverage_symbol_check.py / pytest_runner.py / test_map_config.py 对齐新数据结构 - common/_logging.py:补充 log_env_audit 环境审计日志 ### nightly 报告链路 - report_builder.py / pytest_parser.py / main.py:适配 node-oriented test_map 报告 - report_models.py / feishu_notifier.py 小幅对齐 ### symbol 校验与 exemption 漂移(新增) - **last-wins canonical symbols**:重复 def foo 仅 gate 最后一个定义;shadowed def 发非 blocking GitCode 评论 - **def _ 消歧**:无 decorator → _;有 decorator → _@<suffix> - **exemption 校验**:path::symbol 整串须为 AST canonical name;coverage omit 路径禁止写入 exemptions.sources - **exemption 漂移 blocking**:PR 删/改名 product/test 文件时,未同步更新 gate_policy.yaml → [ED] 硬阻断 + GitCode 评论 - **Expected/Got**:Config / policy / loader 类型与值错误统一格式 - **文档**:scripts/README.md 补充 build.sh、MSMODELING_WHEEL_OUTPUT_DIR;tests/README.md 补充 symbol 契约 ### 其他 - scripts/run_ci_gate.sh:入口参数对齐 - scripts/prefetch_model_configs.py:适配新 config 加载 - tests/README.md / tests/SKILL.md:文档同步 - 新增/更新回归测试:test_classifier.py、test_comments.py、test_policy.py、test_sync.py、test_test_map_query.py、test_test_map_report.py 等 --- ## 自验证 ### CI gate / test_map / nightly 回归测试 目的:确认模块拆分后行为不变,新模块有单测覆盖 步骤: 1. 在仓库根目录执行: sh uv run pytest tests/regression/scripts/helpers/ci_gate/ \ tests/regression/scripts/helpers/common/test_ast_utils.py \ tests/regression/scripts/helpers/common/test_test_map_loader.py \ tests/regression/scripts/helpers/nightly/test_report_builder.py -q 2. 检查退出码与通过数 结果: 206 passed, 7 warnings in 0.43s ### symbol 校验 / exemption 漂移回归 sh uv run pytest tests/regression/scripts/helpers/ci_gate/ \ tests/regression/scripts/helpers/common/test_ast_utils.py \ tests/regression/scripts/helpers/common/test_test_map_loader.py \ tests/regression/scripts/helpers/test_config.py -q 结果: 239 passed, 8 warnings in 1.05s ### test_map 同步入口 目的:确认 run_test_map_sync.sh 可正常拉起 sync.py 步骤: 1. 设置 MSMODELING_TEST_MAP_PATH 指向有效 test_map JSON 2. 执行 bash scripts/run_test_map_sync.sh --once 结果:脚本入口与 sync.py CLI 已随 PR 提交;完整同步需 CI/nightly 环境提供有效 test_map 文件 See merge request: Ascend/msmodeling!394 | 6 天前 | |
【FIX】CI gate 剔除 stale test_map node,消除 batch collect per-node 假死 Co-authored-by: liujiawang<anonymousdev@163.com> # message auto-generated for no-merge-commit merge: !408 merge fix/collect-stale-nodes into master 【FIX】CI gate 剔除 stale test_map node,消除 batch collect per-node 假死 Created-by: AvadaKedavrua Commit-by: liujiawang Merged-by: ascend-robot Description: ## 修改原因 CI gate Wave2 启动前 filter_collectable_node_ids 对数百个 regression node 做 batch collect-only。当 test_map 含少量 stale node id(测试重命名/删除后未刷新 map)时,pytest 返回 rc=4,-q 模式下 stdout 仅有 summary、无法解析 node 行,旧逻辑误判为「0 个 collectable」并触发 **O(n) per-node collect**(PR #385 实测 319 节点约 50 分钟无日志,表现为门禁卡住)。 --- ## 修改内容 - **scripts/helpers/common/pytest_runner.py** - 新增 _parse_not_found_node_ids:从 stderr 解析 ERROR: not found: <node_id> - filter_collectable_node_ids:batch rc=4 时剔除 stale id 并返回 remaining(单次 batch);rc=0 + summary stdout 时返回全部 targets;无法解析的 rc=4 直接 ConfigError - **移除** per-node fallback、_collect_test_node_ids_lenient、_stderr_reports_all_targets_missing - 增加 info 日志:丢弃 stale 数量与 sample - **scripts/helpers/ci_gate/main.py**:Wave 选测前 log Filtering N node id(s) for collectability - **测试**:更新/补充 test_pytest_runner.py 覆盖 partial stale、summary stdout、unparseable rc=4 --- ## 自验证 ### 单元 / 编排回归 目的:确认新 collect 逻辑与 CI gate 编排无回归 步骤: 1. 在仓库根目录执行: sh uv run pytest tests/regression/scripts/helpers/common/test_pytest_runner.py \ tests/regression/scripts/helpers/ci_gate/test_orchestration.py -q ### Partial stale batch(模拟 PR #385 卡住路径) 目的:验证 rc=4 + stderr 含 not found 时不再 per-node,单次 batch 内完成 步骤: 1. mock batch collect rc=4 + stderr 含 1 个 stale + 1 个 valid node 2. 调用 filter_collectable_node_ids((valid, stale), marker=...) 3. 断言仅返回 valid,且未调用 per-node lenient collect 结果:见 test_filter_collectable_node_ids_partial_stale_drops_without_per_node 通过 ### PR #385 场景说明 目的:解释根因与修复效果 步骤: 1. Wave0 194 changed tests 通过后,Wave1 对 319 regression node 调 filter_collectable_node_ids 2. 旧逻辑:11 个 stale id → batch_ids=0 → 319×~11s per-node 3. 新逻辑:stderr 解析剔除 11 stale → 返回 308 个 remaining,~1 次 batch(~10s) 结果:门禁不再在 Wave0 summary 后长时间无输出 See merge request: Ascend/msmodeling!408 | 5 天前 | |
【REFACTOR】重构 CI gate 与 test_map 同步基础设施 Co-authored-by: AvadaKedavrua<anonymousdev@163.com> # message auto-generated for no-merge-commit merge: !394 merge fix into master 【REFACTOR】重构 CI gate 与 test_map 同步基础设施 Created-by: AvadaKedavrua Commit-by: liujiawang;AvadaKedavrua Merged-by: ascend-robot Description: ## 修改原因 CI gate 的 diff 分类、策略校验、PR 评论、test_map 同步等逻辑耦合在 gate_policy.py 等单体模块中,难以独立演进与单测;test_map 缺少独立同步入口;ast_utils / test_map_loader / nightly 报告链路也需要与 gate 策略对齐。本 PR 仅包含 commit 82757732b6b6beb79b7083f6046e9cd9c72005f3(refactor),不涉及 wheel/CLI/OptiX 变更。 --- ## test_map schema 重构:背景与收益 ### 背景 旧 test_map 以**产品源文件**为顶层 key,value 为 symbol → [test_nodes]: json { "tensor_cast/foo.py": { "Widget::run": ["tests/regression/.../test_x.py::test_foo"] } } 新 test_map 改为以 **pytest node id** 为顶层 key,value 为 source_file → [symbols],与 coverage.py --cov-context=test 的采集方向一致: json { "tests/regression/.../test_x.py::test_foo": { "tensor_cast/foo.py": ["Widget::run"] } } 两者存的是同一张「测试节点 ↔ (源文件, symbol)」二部图,仅主键方向相反;边数相同,语义不变。 ### 为何行数变多、体积反而更小 | 指标 | 旧 schema(source-oriented) | 新 schema(node-oriented) | |------|------------------------------|----------------------------| | JSON 行数 | ~7 万行 | ~10 万行 | | 文件/内存占用 | **8,355,104 B(~8.0 MB)** | **3,748,221 B(~3.6 MB,约 -55%)** | 行数不是体积的可靠 proxy。旧格式在每个 symbol 下重复存储完整 pytest node id(tests/regression/.../test_xxx.py::Class::test_yyy,通常 60–80 字符);同一 test 覆盖 N 个 symbol 时,该长字符串出现 N 次。新格式每个 test node id 只作为顶层 key 出现一次,数组里存的是短 canonical symbol(如 Widget::run、%),边数 E 不变但**长字符串重复次数从 O(E) 降到 O(T)**(T = 有覆盖的 test 数,T ≪ E)。 典型场景:大量 smoke/regression 用例通过 import 共享 tensor_cast/、cli/ 等模块的 module symbol %——旧格式在单个 symbol 下聚合成千上万条 test id;新格式每个 test 只记一次短 symbol,整体字节数显著下降。 ### 工程收益 1. **构建零 pivot**:build_test_map.collect_from_coverage 直接按 coverage context(test node)聚合 by_test[nid][source].add(symbol),与 nightly phase1 采集路径一致。 2. **增量 sync 更自然**:sync.apply_incremental_test_map_update 对 touched test 文件整 node 替换、对 touched product 文件按 (test_node, source_path) 合并,无需在两种索引间来回转换。 3. **删 test / 冗余检测更直接**:gate_deleted_tests、detect_redundant_cases 按 test footprint 遍历;test_map_loader 强制顶层为 tests/...::...,可拒绝误写成 source key 的脏数据。 4. **CI gate 查询无退化**:symbol → tests 反向查询通过 build_test_map_index 一次 O(N) 建索引,与旧 schema 运行时等价。 5. **存储与传输更轻**:实测文件体积约减半,OBS 下载与 json.loads 内存峰值更低。 --- ## 修改内容 ### CI gate 模块拆分 - gate_policy.py 瘦身:策略加载/校验迁入 policy.py,diff 分类迁入 classifier.py,GitCode PR 评论迁入 comments.py,test_map 查询迁入 test_map_query.py - 新增 sync.py + scripts/run_test_map_sync.sh:按目标分支 HEAD 维护权威 test_map(--once / --watch) - diff.py 精简,仅保留 git diff 与分支检出能力 - main.py / rules.py / models.py / errors.py 适配新模块边界 - tests/.ci/gate_policy.yaml 策略字段同步调整 ### 公共 helpers 增强 - _config.py:手写 env 解析改为 pydantic-settings,统一校验与错误信息 - ast_utils.py:扩展符号提取能力,支撑 test_map 粒度映射 - build_test_map.py / test_map_loader.py:重构收集与加载逻辑(node-oriented schema) - 新增 test_map_report.py:test_map 覆盖率汇总、过期豁免检测 - coverage_symbol_check.py / pytest_runner.py / test_map_config.py 对齐新数据结构 - common/_logging.py:补充 log_env_audit 环境审计日志 ### nightly 报告链路 - report_builder.py / pytest_parser.py / main.py:适配 node-oriented test_map 报告 - report_models.py / feishu_notifier.py 小幅对齐 ### symbol 校验与 exemption 漂移(新增) - **last-wins canonical symbols**:重复 def foo 仅 gate 最后一个定义;shadowed def 发非 blocking GitCode 评论 - **def _ 消歧**:无 decorator → _;有 decorator → _@<suffix> - **exemption 校验**:path::symbol 整串须为 AST canonical name;coverage omit 路径禁止写入 exemptions.sources - **exemption 漂移 blocking**:PR 删/改名 product/test 文件时,未同步更新 gate_policy.yaml → [ED] 硬阻断 + GitCode 评论 - **Expected/Got**:Config / policy / loader 类型与值错误统一格式 - **文档**:scripts/README.md 补充 build.sh、MSMODELING_WHEEL_OUTPUT_DIR;tests/README.md 补充 symbol 契约 ### 其他 - scripts/run_ci_gate.sh:入口参数对齐 - scripts/prefetch_model_configs.py:适配新 config 加载 - tests/README.md / tests/SKILL.md:文档同步 - 新增/更新回归测试:test_classifier.py、test_comments.py、test_policy.py、test_sync.py、test_test_map_query.py、test_test_map_report.py 等 --- ## 自验证 ### CI gate / test_map / nightly 回归测试 目的:确认模块拆分后行为不变,新模块有单测覆盖 步骤: 1. 在仓库根目录执行: sh uv run pytest tests/regression/scripts/helpers/ci_gate/ \ tests/regression/scripts/helpers/common/test_ast_utils.py \ tests/regression/scripts/helpers/common/test_test_map_loader.py \ tests/regression/scripts/helpers/nightly/test_report_builder.py -q 2. 检查退出码与通过数 结果: 206 passed, 7 warnings in 0.43s ### symbol 校验 / exemption 漂移回归 sh uv run pytest tests/regression/scripts/helpers/ci_gate/ \ tests/regression/scripts/helpers/common/test_ast_utils.py \ tests/regression/scripts/helpers/common/test_test_map_loader.py \ tests/regression/scripts/helpers/test_config.py -q 结果: 239 passed, 8 warnings in 1.05s ### test_map 同步入口 目的:确认 run_test_map_sync.sh 可正常拉起 sync.py 步骤: 1. 设置 MSMODELING_TEST_MAP_PATH 指向有效 test_map JSON 2. 执行 bash scripts/run_test_map_sync.sh --once 结果:脚本入口与 sync.py CLI 已随 PR 提交;完整同步需 CI/nightly 环境提供有效 test_map 文件 See merge request: Ascend/msmodeling!394 | 6 天前 | |
【REFACTOR】重构 CI gate 与 test_map 同步基础设施 Co-authored-by: AvadaKedavrua<anonymousdev@163.com> # message auto-generated for no-merge-commit merge: !394 merge fix into master 【REFACTOR】重构 CI gate 与 test_map 同步基础设施 Created-by: AvadaKedavrua Commit-by: liujiawang;AvadaKedavrua Merged-by: ascend-robot Description: ## 修改原因 CI gate 的 diff 分类、策略校验、PR 评论、test_map 同步等逻辑耦合在 gate_policy.py 等单体模块中,难以独立演进与单测;test_map 缺少独立同步入口;ast_utils / test_map_loader / nightly 报告链路也需要与 gate 策略对齐。本 PR 仅包含 commit 82757732b6b6beb79b7083f6046e9cd9c72005f3(refactor),不涉及 wheel/CLI/OptiX 变更。 --- ## test_map schema 重构:背景与收益 ### 背景 旧 test_map 以**产品源文件**为顶层 key,value 为 symbol → [test_nodes]: json { "tensor_cast/foo.py": { "Widget::run": ["tests/regression/.../test_x.py::test_foo"] } } 新 test_map 改为以 **pytest node id** 为顶层 key,value 为 source_file → [symbols],与 coverage.py --cov-context=test 的采集方向一致: json { "tests/regression/.../test_x.py::test_foo": { "tensor_cast/foo.py": ["Widget::run"] } } 两者存的是同一张「测试节点 ↔ (源文件, symbol)」二部图,仅主键方向相反;边数相同,语义不变。 ### 为何行数变多、体积反而更小 | 指标 | 旧 schema(source-oriented) | 新 schema(node-oriented) | |------|------------------------------|----------------------------| | JSON 行数 | ~7 万行 | ~10 万行 | | 文件/内存占用 | **8,355,104 B(~8.0 MB)** | **3,748,221 B(~3.6 MB,约 -55%)** | 行数不是体积的可靠 proxy。旧格式在每个 symbol 下重复存储完整 pytest node id(tests/regression/.../test_xxx.py::Class::test_yyy,通常 60–80 字符);同一 test 覆盖 N 个 symbol 时,该长字符串出现 N 次。新格式每个 test node id 只作为顶层 key 出现一次,数组里存的是短 canonical symbol(如 Widget::run、%),边数 E 不变但**长字符串重复次数从 O(E) 降到 O(T)**(T = 有覆盖的 test 数,T ≪ E)。 典型场景:大量 smoke/regression 用例通过 import 共享 tensor_cast/、cli/ 等模块的 module symbol %——旧格式在单个 symbol 下聚合成千上万条 test id;新格式每个 test 只记一次短 symbol,整体字节数显著下降。 ### 工程收益 1. **构建零 pivot**:build_test_map.collect_from_coverage 直接按 coverage context(test node)聚合 by_test[nid][source].add(symbol),与 nightly phase1 采集路径一致。 2. **增量 sync 更自然**:sync.apply_incremental_test_map_update 对 touched test 文件整 node 替换、对 touched product 文件按 (test_node, source_path) 合并,无需在两种索引间来回转换。 3. **删 test / 冗余检测更直接**:gate_deleted_tests、detect_redundant_cases 按 test footprint 遍历;test_map_loader 强制顶层为 tests/...::...,可拒绝误写成 source key 的脏数据。 4. **CI gate 查询无退化**:symbol → tests 反向查询通过 build_test_map_index 一次 O(N) 建索引,与旧 schema 运行时等价。 5. **存储与传输更轻**:实测文件体积约减半,OBS 下载与 json.loads 内存峰值更低。 --- ## 修改内容 ### CI gate 模块拆分 - gate_policy.py 瘦身:策略加载/校验迁入 policy.py,diff 分类迁入 classifier.py,GitCode PR 评论迁入 comments.py,test_map 查询迁入 test_map_query.py - 新增 sync.py + scripts/run_test_map_sync.sh:按目标分支 HEAD 维护权威 test_map(--once / --watch) - diff.py 精简,仅保留 git diff 与分支检出能力 - main.py / rules.py / models.py / errors.py 适配新模块边界 - tests/.ci/gate_policy.yaml 策略字段同步调整 ### 公共 helpers 增强 - _config.py:手写 env 解析改为 pydantic-settings,统一校验与错误信息 - ast_utils.py:扩展符号提取能力,支撑 test_map 粒度映射 - build_test_map.py / test_map_loader.py:重构收集与加载逻辑(node-oriented schema) - 新增 test_map_report.py:test_map 覆盖率汇总、过期豁免检测 - coverage_symbol_check.py / pytest_runner.py / test_map_config.py 对齐新数据结构 - common/_logging.py:补充 log_env_audit 环境审计日志 ### nightly 报告链路 - report_builder.py / pytest_parser.py / main.py:适配 node-oriented test_map 报告 - report_models.py / feishu_notifier.py 小幅对齐 ### symbol 校验与 exemption 漂移(新增) - **last-wins canonical symbols**:重复 def foo 仅 gate 最后一个定义;shadowed def 发非 blocking GitCode 评论 - **def _ 消歧**:无 decorator → _;有 decorator → _@<suffix> - **exemption 校验**:path::symbol 整串须为 AST canonical name;coverage omit 路径禁止写入 exemptions.sources - **exemption 漂移 blocking**:PR 删/改名 product/test 文件时,未同步更新 gate_policy.yaml → [ED] 硬阻断 + GitCode 评论 - **Expected/Got**:Config / policy / loader 类型与值错误统一格式 - **文档**:scripts/README.md 补充 build.sh、MSMODELING_WHEEL_OUTPUT_DIR;tests/README.md 补充 symbol 契约 ### 其他 - scripts/run_ci_gate.sh:入口参数对齐 - scripts/prefetch_model_configs.py:适配新 config 加载 - tests/README.md / tests/SKILL.md:文档同步 - 新增/更新回归测试:test_classifier.py、test_comments.py、test_policy.py、test_sync.py、test_test_map_query.py、test_test_map_report.py 等 --- ## 自验证 ### CI gate / test_map / nightly 回归测试 目的:确认模块拆分后行为不变,新模块有单测覆盖 步骤: 1. 在仓库根目录执行: sh uv run pytest tests/regression/scripts/helpers/ci_gate/ \ tests/regression/scripts/helpers/common/test_ast_utils.py \ tests/regression/scripts/helpers/common/test_test_map_loader.py \ tests/regression/scripts/helpers/nightly/test_report_builder.py -q 2. 检查退出码与通过数 结果: 206 passed, 7 warnings in 0.43s ### symbol 校验 / exemption 漂移回归 sh uv run pytest tests/regression/scripts/helpers/ci_gate/ \ tests/regression/scripts/helpers/common/test_ast_utils.py \ tests/regression/scripts/helpers/common/test_test_map_loader.py \ tests/regression/scripts/helpers/test_config.py -q 结果: 239 passed, 8 warnings in 1.05s ### test_map 同步入口 目的:确认 run_test_map_sync.sh 可正常拉起 sync.py 步骤: 1. 设置 MSMODELING_TEST_MAP_PATH 指向有效 test_map JSON 2. 执行 bash scripts/run_test_map_sync.sh --once 结果:脚本入口与 sync.py CLI 已随 PR 提交;完整同步需 CI/nightly 环境提供有效 test_map 文件 See merge request: Ascend/msmodeling!394 | 6 天前 | |
【REFACTOR】重构 CI gate 与 test_map 同步基础设施 Co-authored-by: AvadaKedavrua<anonymousdev@163.com> # message auto-generated for no-merge-commit merge: !394 merge fix into master 【REFACTOR】重构 CI gate 与 test_map 同步基础设施 Created-by: AvadaKedavrua Commit-by: liujiawang;AvadaKedavrua Merged-by: ascend-robot Description: ## 修改原因 CI gate 的 diff 分类、策略校验、PR 评论、test_map 同步等逻辑耦合在 gate_policy.py 等单体模块中,难以独立演进与单测;test_map 缺少独立同步入口;ast_utils / test_map_loader / nightly 报告链路也需要与 gate 策略对齐。本 PR 仅包含 commit 82757732b6b6beb79b7083f6046e9cd9c72005f3(refactor),不涉及 wheel/CLI/OptiX 变更。 --- ## test_map schema 重构:背景与收益 ### 背景 旧 test_map 以**产品源文件**为顶层 key,value 为 symbol → [test_nodes]: json { "tensor_cast/foo.py": { "Widget::run": ["tests/regression/.../test_x.py::test_foo"] } } 新 test_map 改为以 **pytest node id** 为顶层 key,value 为 source_file → [symbols],与 coverage.py --cov-context=test 的采集方向一致: json { "tests/regression/.../test_x.py::test_foo": { "tensor_cast/foo.py": ["Widget::run"] } } 两者存的是同一张「测试节点 ↔ (源文件, symbol)」二部图,仅主键方向相反;边数相同,语义不变。 ### 为何行数变多、体积反而更小 | 指标 | 旧 schema(source-oriented) | 新 schema(node-oriented) | |------|------------------------------|----------------------------| | JSON 行数 | ~7 万行 | ~10 万行 | | 文件/内存占用 | **8,355,104 B(~8.0 MB)** | **3,748,221 B(~3.6 MB,约 -55%)** | 行数不是体积的可靠 proxy。旧格式在每个 symbol 下重复存储完整 pytest node id(tests/regression/.../test_xxx.py::Class::test_yyy,通常 60–80 字符);同一 test 覆盖 N 个 symbol 时,该长字符串出现 N 次。新格式每个 test node id 只作为顶层 key 出现一次,数组里存的是短 canonical symbol(如 Widget::run、%),边数 E 不变但**长字符串重复次数从 O(E) 降到 O(T)**(T = 有覆盖的 test 数,T ≪ E)。 典型场景:大量 smoke/regression 用例通过 import 共享 tensor_cast/、cli/ 等模块的 module symbol %——旧格式在单个 symbol 下聚合成千上万条 test id;新格式每个 test 只记一次短 symbol,整体字节数显著下降。 ### 工程收益 1. **构建零 pivot**:build_test_map.collect_from_coverage 直接按 coverage context(test node)聚合 by_test[nid][source].add(symbol),与 nightly phase1 采集路径一致。 2. **增量 sync 更自然**:sync.apply_incremental_test_map_update 对 touched test 文件整 node 替换、对 touched product 文件按 (test_node, source_path) 合并,无需在两种索引间来回转换。 3. **删 test / 冗余检测更直接**:gate_deleted_tests、detect_redundant_cases 按 test footprint 遍历;test_map_loader 强制顶层为 tests/...::...,可拒绝误写成 source key 的脏数据。 4. **CI gate 查询无退化**:symbol → tests 反向查询通过 build_test_map_index 一次 O(N) 建索引,与旧 schema 运行时等价。 5. **存储与传输更轻**:实测文件体积约减半,OBS 下载与 json.loads 内存峰值更低。 --- ## 修改内容 ### CI gate 模块拆分 - gate_policy.py 瘦身:策略加载/校验迁入 policy.py,diff 分类迁入 classifier.py,GitCode PR 评论迁入 comments.py,test_map 查询迁入 test_map_query.py - 新增 sync.py + scripts/run_test_map_sync.sh:按目标分支 HEAD 维护权威 test_map(--once / --watch) - diff.py 精简,仅保留 git diff 与分支检出能力 - main.py / rules.py / models.py / errors.py 适配新模块边界 - tests/.ci/gate_policy.yaml 策略字段同步调整 ### 公共 helpers 增强 - _config.py:手写 env 解析改为 pydantic-settings,统一校验与错误信息 - ast_utils.py:扩展符号提取能力,支撑 test_map 粒度映射 - build_test_map.py / test_map_loader.py:重构收集与加载逻辑(node-oriented schema) - 新增 test_map_report.py:test_map 覆盖率汇总、过期豁免检测 - coverage_symbol_check.py / pytest_runner.py / test_map_config.py 对齐新数据结构 - common/_logging.py:补充 log_env_audit 环境审计日志 ### nightly 报告链路 - report_builder.py / pytest_parser.py / main.py:适配 node-oriented test_map 报告 - report_models.py / feishu_notifier.py 小幅对齐 ### symbol 校验与 exemption 漂移(新增) - **last-wins canonical symbols**:重复 def foo 仅 gate 最后一个定义;shadowed def 发非 blocking GitCode 评论 - **def _ 消歧**:无 decorator → _;有 decorator → _@<suffix> - **exemption 校验**:path::symbol 整串须为 AST canonical name;coverage omit 路径禁止写入 exemptions.sources - **exemption 漂移 blocking**:PR 删/改名 product/test 文件时,未同步更新 gate_policy.yaml → [ED] 硬阻断 + GitCode 评论 - **Expected/Got**:Config / policy / loader 类型与值错误统一格式 - **文档**:scripts/README.md 补充 build.sh、MSMODELING_WHEEL_OUTPUT_DIR;tests/README.md 补充 symbol 契约 ### 其他 - scripts/run_ci_gate.sh:入口参数对齐 - scripts/prefetch_model_configs.py:适配新 config 加载 - tests/README.md / tests/SKILL.md:文档同步 - 新增/更新回归测试:test_classifier.py、test_comments.py、test_policy.py、test_sync.py、test_test_map_query.py、test_test_map_report.py 等 --- ## 自验证 ### CI gate / test_map / nightly 回归测试 目的:确认模块拆分后行为不变,新模块有单测覆盖 步骤: 1. 在仓库根目录执行: sh uv run pytest tests/regression/scripts/helpers/ci_gate/ \ tests/regression/scripts/helpers/common/test_ast_utils.py \ tests/regression/scripts/helpers/common/test_test_map_loader.py \ tests/regression/scripts/helpers/nightly/test_report_builder.py -q 2. 检查退出码与通过数 结果: 206 passed, 7 warnings in 0.43s ### symbol 校验 / exemption 漂移回归 sh uv run pytest tests/regression/scripts/helpers/ci_gate/ \ tests/regression/scripts/helpers/common/test_ast_utils.py \ tests/regression/scripts/helpers/common/test_test_map_loader.py \ tests/regression/scripts/helpers/test_config.py -q 结果: 239 passed, 8 warnings in 1.05s ### test_map 同步入口 目的:确认 run_test_map_sync.sh 可正常拉起 sync.py 步骤: 1. 设置 MSMODELING_TEST_MAP_PATH 指向有效 test_map JSON 2. 执行 bash scripts/run_test_map_sync.sh --once 结果:脚本入口与 sync.py CLI 已随 PR 提交;完整同步需 CI/nightly 环境提供有效 test_map 文件 See merge request: Ascend/msmodeling!394 | 6 天前 |
| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
| 17 天前 | ||
| 6 天前 | ||
| 6 天前 | ||
| 6 天前 | ||
| 14 天前 | ||
| 14 天前 | ||
| 6 天前 | ||
| 6 天前 | ||
| 5 天前 | ||
| 6 天前 | ||
| 6 天前 | ||
| 6 天前 |