Skip to content

增加监控导出说明文档参数audit#11

Open
ghangz wants to merge 2 commits into
MetaX-MACA:mainfrom
ghangz:mengz/mxexporter-readme-flag-audit
Open

增加监控导出说明文档参数audit#11
ghangz wants to merge 2 commits into
MetaX-MACA:mainfrom
ghangz:mengz/mxexporter-readme-flag-audit

Conversation

@ghangz

@ghangz ghangz commented Jun 10, 2026

Copy link
Copy Markdown

这次改动补上了监控导出说明文档参数audit,主要是为了解决监控导出与部署排查流程里相关信息不够集中、人工整理成本较高的问题,让日常排查、验证和结果归档更直接。

实现上补充了对应工具或脚本逻辑,补上了对应测试,同时尽量保持现有用法不变,避免影响已有流程。

这一分支已经在沐曦算力环境完成实际验证,相关检查均已通过,现提交合入。

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new audit tool readme_flag_audit.py and its corresponding unit tests to verify that CLI flags in the codebase match those documented in the README.md. The review feedback identifies a bug in the regular expression used to parse flags from the README, which incorrectly matches hyphenated words (e.g., mx-exporter as -exporter) and causes false positives. It is recommended to update the regex to avoid these false positives and to add test cases covering hyphenated words to prevent regressions.

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.

Comment thread tools/readme_flag_audit.py Outdated
from pathlib import Path


FLAG_RE = re.compile(r"-{1,2}[A-Za-z0-9-]+")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

当前的正则表达式 -{1,2}[A-Za-z0-9-]+ 会匹配任何包含连字符的单词的后半部分。例如,在 README.md 中存在的 mx-exporter 会被匹配出 -exporterpod-resources 会被匹配出 -resourcesdefault-counters 会被匹配出 -counters。这会导致 flags_only_in_readme 中包含大量错误的“仅在 README 中存在的参数”假阳性结果。\n\n建议将正则表达式修改为仅匹配以空格开头或位于行首的命令行参数,例如使用非捕获分组 (?:^|\\s) 结合捕获分组来精确提取参数。

Suggested change
FLAG_RE = re.compile(r"-{1,2}[A-Za-z0-9-]+")
FLAG_RE = re.compile(r"(?:^|\s)(-{1,2}[A-Za-z0-9-]+)")

Comment thread tests/test_readme_flag_audit.py Outdated
Comment on lines +21 to +25
(root / "README.md").write_text("python3 -m mx_exporter -p 8000\n", encoding="utf-8")

report = build(root)

self.assertIn("--interval", report["flags_missing_from_readme"])

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

为了防止未来引入类似的回归问题,建议在测试中加入包含连字符单词(如 mx-exporter)的场景,并断言这些单词不会被错误地识别为命令行参数。

            (root / "README.md").write_text("python3 -m mx-exporter -p 8000\n", encoding="utf-8")\n\n            report = build(root)\n\n        self.assertIn("--interval", report["flags_missing_from_readme"])\n        self.assertNotIn("-exporter", report["flags_only_in_readme"])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant