Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a new tool tools/maca_env_snapshot.py to collect reproducible MACA validation environment snapshots, along with its corresponding unit tests. The feedback suggests improving the script's robustness by adding a timeout and exception handling to the subprocess execution to prevent hanging, and ensuring that parent directories are created before writing the output file to avoid potential FileNotFoundError exceptions.
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.
| completed = subprocess.run([path, *args], text=True, capture_output=True) | ||
| return { | ||
| "path": path, | ||
| "available": True, | ||
| "returncode": completed.returncode, | ||
| "version": (completed.stdout or completed.stderr).strip().splitlines()[:5], | ||
| } |
There was a problem hiding this comment.
在调用 subprocess.run 执行外部命令(如 mxcc 或 cmake_maca)时,如果工具由于驱动、授权或其他原因挂起,可能会导致整个环境快照收集流程无限期阻塞。建议为 subprocess.run 添加 timeout 参数,并捕获可能的异常(如 subprocess.TimeoutExpired 或 subprocess.SubprocessError),以提高脚本的健壮性。
try:
completed = subprocess.run([path, *args], text=True, capture_output=True, timeout=5)
return {
"path": path,
"available": True,
"returncode": completed.returncode,
"version": (completed.stdout or completed.stderr).strip().splitlines()[:5],
}
except (subprocess.SubprocessError, OSError) as e:
return {
"path": path,
"available": True,
"returncode": -1,
"version": [f"Error: {e}"],
}| if args.output: | ||
| args.output.write_text(text + "\n", encoding="utf-8") |
There was a problem hiding this comment.
如果指定的输出路径(args.output)包含不存在的父目录,直接调用 write_text 会抛出 FileNotFoundError 异常。建议在写入前自动创建父目录,以提升用户体验和脚本的容错能力。
| if args.output: | |
| args.output.write_text(text + "\n", encoding="utf-8") | |
| if args.output: | |
| args.output.parent.mkdir(parents=True, exist_ok=True) | |
| args.output.write_text(text + "\n", encoding="utf-8") |
这次改动补上了算子库环境快照,主要是为了解决算子库构建和诊断流程里相关信息不够集中、人工整理成本较高的问题,让日常排查、验证和结果归档更直接。
实现上补充了对应工具或脚本逻辑,补上了对应测试,同时尽量保持现有用法不变,避免影响已有流程。
这一分支已经在沐曦算力环境完成实际验证,相关检查均已通过,现提交合入。