-
Notifications
You must be signed in to change notification settings - Fork 593
bugfix: fix regex in update wheel index script #2009
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Summary of ChangesHello @yzh119, 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 addresses a critical bug in the Highlights
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
|
WalkthroughThe wheel filename parsing regexes in Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
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 correctly fixes an issue with the regular expression used for parsing wheel filenames, extending it to support release candidates and post-releases as per PEP 440. The change successfully addresses the problem described. I've added one suggestion to further improve the robustness of the version parsing and the maintainability of the code by extracting the duplicated regex pattern and making it more specific. Overall, this is a good fix.
| match = re.match(r"flashinfer_python-([0-9.]+(?:\.dev\d+)?)-", wheel_name) | ||
| # Supports PEP 440: base_version[{a|b|rc}N][.postN][.devN] | ||
| match = re.match( | ||
| r"flashinfer_python-([0-9.]+(?:(?:a|b|rc)\d+)?(?:\.post\d+)?(?:\.dev\d+)?)-", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This regex is an improvement, but the base version part [0-9.]+ is too permissive and could match invalid version strings like 1..2 or . which might lead to incorrect behavior.
For improved robustness and maintainability, I suggest two changes:
- More specific base version regex: Use
[0-9]+(?:\.[0-9]+)*to strictly match dot-separated numbers. - DRY principle: Extract the repeated version pattern into a variable to avoid duplication and make future changes easier.
Here's how you could apply this within the get_package_info function:
# At the top of the function:
pep440_version_part = r"[0-9]+(?:\.[0-9]+)*(?:(?:a|b|rc)\d+)?(?:\.post\d+)?(?:\.dev\d+)?"
# Then, for each package:
match = re.match(f"flashinfer_python-({pep440_version_part})-", wheel_name)
# ... and so on for the other packages.This would make the parsing more reliable and the code easier to maintain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (3)
scripts/update_whl_index.py (3)
34-38: Regex correctly implements PEP 440 pre-release and post-release support.The pattern now correctly matches release candidates (e.g.,
0.5.0rc1) and post releases (e.g.,1.2.3.post1) as intended. The ordering follows PEP 440 specification.Optional: Consider stricter base version pattern.
The base version pattern
[0-9.]+is permissive and could theoretically match invalid versions like1..2or.1.2. For more robust validation, consider:- r"flashinfer_python-([0-9.]+(?:(?:a|b|rc)\d+)?(?:\.post\d+)?(?:\.dev\d+)?)-", + r"flashinfer_python-(\d+(?:\.\d+)*(?:(?:a|b|rc)\d+)?(?:\.post\d+)?(?:\.dev\d+)?)-",This ensures at least one digit followed by zero or more
.digitgroups.
48-52: Regex correctly implements PEP 440 support.Consistent with the flashinfer_python pattern, this now correctly handles release candidates and post releases.
Optional: Consider stricter base version pattern.
Same as the previous pattern, consider using
\d+(?:\.\d+)*for more robust base version validation:- r"flashinfer_cubin-([0-9.]+(?:(?:a|b|rc)\d+)?(?:\.post\d+)?(?:\.dev\d+)?)-", + r"flashinfer_cubin-(\d+(?:\.\d+)*(?:(?:a|b|rc)\d+)?(?:\.post\d+)?(?:\.dev\d+)?)-",
62-66: Regex correctly implements PEP 440 support with CUDA suffix.The pattern appropriately enforces the CUDA suffix requirement (
+cu\d+) while supporting pre-release and post-release segments. The captured version includes the CUDA suffix, which is correctly handled sinceget_cuda_version()is called separately on line 69.Optional: Consider stricter base version pattern.
For consistency and robustness, apply the same improvement to the base version pattern:
- r"flashinfer_jit_cache-([0-9.]+(?:(?:a|b|rc)\d+)?(?:\.post\d+)?(?:\.dev\d+)?\+cu\d+)-", + r"flashinfer_jit_cache-(\d+(?:\.\d+)*(?:(?:a|b|rc)\d+)?(?:\.post\d+)?(?:\.dev\d+)?\+cu\d+)-",
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
scripts/update_whl_index.py(3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Deploy Docs
bkryu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Double checked with Perplexity 😄 :
Previous regex pattern is suitable for simple versioning schemes with optional dev releases.
Proposed regex pattern is compatible with PEP 440 versioning, capturing most standard Python package release formats, including pre- and post-releases as well as dev snapshots. It is strictly more general and is recommended if your input can include alpha, beta, release candidate, post, or development suffixes recognized by Python packaging tools.
📌 Description
The regex cannot recognize release candidates (
v0.5.0rc1) or post releases (v1.2.3.post1): https://github.com/flashinfer-ai/flashinfer/actions/runs/18929490991/job/54049304551This PR fixes the issue.
🔍 Related Issues
https://github.com/flashinfer-ai/flashinfer/actions/runs/18929490991/job/54049304551
🚀 Pull Request Checklist
Thank you for contributing to FlashInfer! Before we review your pull request, please make sure the following items are complete.
✅ Pre-commit Checks
pre-commitby runningpip install pre-commit(or used your preferred method).pre-commit install.pre-commit run --all-filesand fixed any reported issues.🧪 Tests
unittest, etc.).Reviewer Notes
Summary by CodeRabbit