-
Notifications
You must be signed in to change notification settings - Fork 520
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
style: enable TorchFix in pre-commit #4230
Conversation
Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
📝 Walkthrough📝 WalkthroughWalkthroughThe changes involve significant modifications to the Changes
Sequence Diagram(s)sequenceDiagram
participant Developer
participant Pre-Commit
participant Flake8
participant Ruff
participant LicenseInserter
Developer->>Pre-Commit: Commit code
Pre-Commit->>Flake8: Run flake8 checks
Flake8-->>Pre-Commit: Return linting results
Pre-Commit->>Ruff: Run ruff checks
Ruff-->>Pre-Commit: Return ruff results
Pre-Commit->>LicenseInserter: Insert license headers
LicenseInserter-->>Pre-Commit: Confirm license insertion
Pre-Commit-->>Developer: Provide results
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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
🧹 Outside diff range and nitpick comments (2)
.pre-commit-config.yaml (2)
41-48
: LGTM: Excellent addition of flake8 with TorchFixThe inclusion of flake8 with TorchFix is a great improvement:
- It directly addresses the PR objective of enabling TorchFix.
- The use of flake8-pyproject allows for centralized configuration in pyproject.toml.
- Pinning the version (7.1.1) ensures reproducibility.
Consider adding a comment explaining the purpose of each additional dependency, especially torchfix, to improve maintainability:
additional_dependencies: - torchfix==0.6.0 # Assists with PyTorch-related code fixes - flake8-pyproject==1.2.3 # Allows flake8 configuration in pyproject.toml
Line range hint
37-40
: LGTM: Good addition of ruff-formatThe inclusion of the ruff-format hook is a valuable addition:
- It enhances code formatting consistency across the project.
- The exclusion of 3rdparty files prevents modifying external code.
- Supporting multiple file types ensures comprehensive coverage.
For consistency with the ruff hook above, consider moving the
types_or
specification to theruff-format
hook:- id: ruff-format exclude: ^source/3rdparty types_or: [python, pyi, jupyter]This makes the configuration for both hooks more parallel and easier to maintain.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
- .pre-commit-config.yaml (1 hunks)
- pyproject.toml (1 hunks)
🧰 Additional context used
🔇 Additional comments (4)
.pre-commit-config.yaml (2)
Line range hint
9-15
: LGTM: Improved file size limit enforcementThe changes to the
check-added-large-files
hook are beneficial:
- Setting a 1024 KB limit helps maintain a manageable repository size.
- The exclusion of specific .pbtxt files allows for necessary exceptions.
This update aligns well with best practices for repository management.
Line range hint
1-180
: Overall assessment: Excellent improvements to pre-commit configurationThe changes to
.pre-commit-config.yaml
significantly enhance the project's code quality checks:
- The addition of flake8 with TorchFix directly addresses the PR's main objective.
- The inclusion of ruff-format improves code formatting consistency.
- Updates to existing hooks, like
check-added-large-files
, improve repository management.These changes collectively contribute to better code quality, consistency, and maintainability. The configuration is well-structured and aligns with best practices for pre-commit hook setup.
pyproject.toml (2)
Line range hint
1-428
: Changes align well with PR objectivesThe addition of the
[tool.flake8]
section with TorchFix rules (TOR0, TOR1, TOR2) directly addresses the PR objective of enabling TorchFix in pre-commit. The changes are minimal and focused, which is commendable as it reduces the risk of unintended side effects.
422-428
: LGTM. Consider adding rule descriptions and verifying rule completeness.The addition of the
[tool.flake8]
section with TorchFix rules aligns well with the PR objective. Good job on enabling these rules.To improve clarity and maintainability:
Consider adding comments to briefly explain what each selected rule (TOR0, TOR1, TOR2) checks for. This will help future contributors understand the purpose of these rules without needing to look them up externally.
Verify if these three rules cover all the necessary TorchFix checks for your project. If there are other relevant TorchFix rules, consider including them as well.
To verify the completeness of TorchFix rules, you can run:
Compare the output with the rules currently selected in the configuration.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## devel #4230 +/- ##
==========================================
- Coverage 84.58% 84.57% -0.01%
==========================================
Files 547 547
Lines 51327 51327
Branches 3047 3047
==========================================
- Hits 43413 43410 -3
Misses 6967 6967
- Partials 947 950 +3 ☔ View full report in Codecov by Sentry. |
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: 1
🧹 Outside diff range and nitpick comments (1)
.pre-commit-config.yaml (1)
46-48
: Pin the flake8-pyproject version more strictly.The dependency
flake8-pyproject==1.2.3
is pinned, but consider using~=1.2.3
to allow patch updates while preventing breaking changes.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
- .pre-commit-config.yaml (1 hunks)
🧰 Additional context used
🔇 Additional comments (1)
.pre-commit-config.yaml (1)
41-48
: Verify compatibility with ruff.Since both ruff and flake8+torchfix are enabled, ensure they don't conflict:
- Ruff already includes many flake8 rules
- Consider using ruff's PyTorch-specific rules instead, if available
Let's check ruff's configuration:
Enable TorchFix.
Need to resolve the following issues before merging:
torch.norm
is deprecated #4229torch.load
warnings #4143Summary by CodeRabbit
New Features
flake8
for enhanced code quality checks.ruff-format
hook for improved linting.Bug Fixes
check-added-large-files
hook to enforce a maximum file size of 1024 KB.Documentation
[tool.flake8]
.