Fix argument parsing to support ml images as well#123
Conversation
Also migrated a unit test to Python3
Summary of ChangesHello @Deependra-Patel, 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 enhances the argument parsing utility to support machine learning (ML) specific image versions, such as 'ml-ubuntu'. It refines the regular expression patterns used for image version identification and improves the string manipulation logic for image path inference. Additionally, the associated unit tests have been updated to align with Python 3 standards and to validate the new ML image parsing capabilities, ensuring the robustness of the argument parsing system. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
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 support for ML image names in argument parsing, which is a valuable addition. The changes to the regular expressions in args_parser.py and the logic in args_inferer.py are correct and well-implemented to handle the new image name formats.
A significant part of this PR is the migration of tests/test_args_parser.py to be Python 3 compatible and the substantial refactoring of the tests. Moving from string-based comparisons of Namespace objects to direct object comparison is a major improvement in test quality, making them more robust and readable. The cleanup of the test helper _make_expected_result is particularly noteworthy.
I have one suggestion to improve test coverage for one of the modified regular expressions to ensure all new formats are validated. Otherwise, the changes are excellent.
| # Old style images: 1.2.3 | ||
| # New style images: 1.2.3-deb8, 1.2.3-debian9, 1.2.3-RC10-debian9 | ||
| _VERSION_REGEX = re.compile(r"^\d+\.\d+\.\d+(-RC\d+)?(-[a-z]+\d+)?$") | ||
| _VERSION_REGEX = re.compile(r"^\d+\.\d+\.\d+(-RC\d+)?(-[a-z\-]+\d+)?$") |
There was a problem hiding this comment.
This change to _VERSION_REGEX correctly adds support for hyphens in the suffix of a full version string (e.g., 1.2.3-ml-debian9). However, this specific format is not covered in the updated test suite. To ensure this change is properly validated, please consider adding a test case for a version string that includes a hyphenated prefix like ml-.
Also migrated a unit test to Python3
TESTED=Unit test is now passing. Created a custom image with ml base image.