[tools]: Add sync script and CI check for Miles server args sync#595
[tools]: Add sync script and CI check for Miles server args sync#595Ratish1 wants to merge 2 commits intoradixark:mainfrom
Conversation
Summary of ChangesHello @Ratish1, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the maintainability and accuracy of Miles server argument documentation by introducing an automated synchronization and validation system. It ensures that the documentation consistently reflects the current state of argument definitions in the codebase, thereby reducing manual effort and preventing documentation drift. The integration into the CI pipeline provides continuous verification, making it easier for developers to keep documentation up-to-date. Highlights
Changelog
Ignored Files
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a valuable script for synchronizing and validating the command-line argument documentation, which is a great step towards ensuring documentation accuracy. The script is well-designed, using ast parsing for reliability and providing both a validation (--check) and an update (--write) mode. My review focuses on a couple of areas for improvement: enhancing robustness by specifying exception types and increasing conciseness by leveraging regular expressions for string manipulation. Overall, this is a solid contribution that improves project maintainability.
| def _escape_unescaped_pipes(text: str) -> str: | ||
| out: list[str] = [] | ||
| escaped = False | ||
| for ch in text: | ||
| if escaped: | ||
| out.append(ch) | ||
| escaped = False | ||
| continue | ||
| if ch == "\\": | ||
| out.append(ch) | ||
| escaped = True | ||
| continue | ||
| if ch == "|": | ||
| out.append("\\|") | ||
| else: | ||
| out.append(ch) | ||
| return "".join(out) |
There was a problem hiding this comment.
The manual iteration to escape unescaped pipe characters is correct, but it can be significantly simplified by using a regular expression with a negative lookbehind. This makes the code more concise, idiomatic, and often easier to understand for developers familiar with regex.
| def _escape_unescaped_pipes(text: str) -> str: | |
| out: list[str] = [] | |
| escaped = False | |
| for ch in text: | |
| if escaped: | |
| out.append(ch) | |
| escaped = False | |
| continue | |
| if ch == "\\": | |
| out.append(ch) | |
| escaped = True | |
| continue | |
| if ch == "|": | |
| out.append("\\|") | |
| else: | |
| out.append(ch) | |
| return "".join(out) | |
| def _escape_unescaped_pipes(text: str) -> str: | |
| # Use a negative lookbehind to find '|' not preceded by '\'. | |
| return re.sub(r"(?<!\\)\|", r"\\|", text) |
Summary
This is part 2 of the PR that implements the sync script requested in #578 and adds a l CPU CI check.
Added
tools/sync_param_docs.py.github/workflows/param-docs-sync-check.ymlScript behavior
tools/sync_param_docs.pysupports:--check: validation-only, fails when docs and args are out of sync--write: syncs managed docs descriptions from codeScope rules
miles/utils/arguments.pyvia:parser.add_argument("--...")reset_arg(parser, "--...", ...)python train.py --helpoutput.arguments.pyfrom docs.Bi-directional consistency checks
--checkvalidates both directions:args -> docs: every managed code flag is documented and up to datedocs -> args: every managed docs flag exists in managed code scopeCI
Added a CPU-only workflow:
.github/workflows/param-docs-sync-check.ymlpython tools/sync_param_docs.py --checkdocs/en/advanced/miles_server_args.mdchangesmiles/utils/arguments.pychangesVerification
Before manual sync (expected fail)
Using pre-sync snapshots:
--checkfails with stale descriptions / missing help entries.After manual sync (expected pass)
--checkpasses with zero stale/missing/duplicate issues.Write mode check locally
--writeupdated 1 row