增加算子库校验基准configs#37
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a new linting script, tools/lint_benchmark_configs.py, along with its corresponding unit tests, to validate that benchmark configuration JSON files and runner Python scripts are correctly paired and that the JSON files are valid. The review feedback suggests improving the robustness of the script's JSON parsing logic by catching (OSError, ValueError) instead of only json.JSONDecodeError, which prevents potential script crashes due to unreadable files or encoding issues.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| try: | ||
| json.loads(path.read_text(encoding="utf-8")) | ||
| except json.JSONDecodeError as exc: | ||
| errors.append(f"invalid JSON in {path.relative_to(root).as_posix()}: {exc}") |
There was a problem hiding this comment.
在读取和解析 JSON 文件时,仅捕获 json.JSONDecodeError 可能会导致其他异常(例如文件编码不正确导致的 UnicodeDecodeError,或者权限问题导致的 OSError)未被捕获,从而导致整个校验脚本崩溃。建议捕获 (OSError, ValueError) 以提高脚本的健壮性。
| try: | |
| json.loads(path.read_text(encoding="utf-8")) | |
| except json.JSONDecodeError as exc: | |
| errors.append(f"invalid JSON in {path.relative_to(root).as_posix()}: {exc}") | |
| try: | |
| json.loads(path.read_text(encoding="utf-8")) | |
| except (OSError, ValueError) as exc: | |
| errors.append(f"invalid JSON or unreadable file in {path.relative_to(root).as_posix()}: {exc}") |
这次改动补上了算子库校验基准configs,主要是为了解决算子库构建和诊断流程里相关信息不够集中、人工整理成本较高的问题,让日常排查、验证和结果归档更直接。
实现上补充了对应工具或脚本逻辑,补上了对应测试,同时尽量保持现有用法不变,避免影响已有流程。
这一分支已经在沐曦算力环境完成实际验证,相关检查均已通过,现提交合入。