-
Notifications
You must be signed in to change notification settings - Fork 197
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
Run linters using pre-commit #965
Conversation
This change adds pre-commit hook to run on each commit, that will automatically run code linters and not allow you commit changes if the linters fail. This is similar to how cudf uses pre-commit, as described in rapidsai/cudf#9309 . The pre-commit checks will also be run in CI as part of the check style script. This change also adds several new linters that weren't been run in CI before: * pydocstyle * mypy * black * isort * cmake-format * cmake-lint Of these new linters - mypy caught an issue where the test_comms.py would always be skipped (`python/raft-dask/raft_dask/test/test_comms.py:23: error: Module "raft_dask" has no attribute "Comms"` ), and Pydocstyle caught some minor formatting inconsistencies in the python docstrings. black/isort ensure consistent code formatting for the python raft code
Add pylibraft to known first party imports for isort
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.
I think the workflow that results from these hooks is going to be quite efficient and I'm really looking forward to these changes. I did a pass through the changes and I'm going to check out your branch and play with the hooks locally as well.
I'm a fan of this change and am happy to provide any extra info you need on how this works in cudf or help address any specific issues anyone is concerned about! |
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.
I checked this out locally and played with a bunch of the linters. Really digging the cmake formatting.
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.
🔥 🎉 Thank you very much for this! I am planning to do similar changes for rmm and other libraries. I checked closely and this PR contains a lot of the minor fixes that I've adopted in cuDF for various issues with configurations.
@@ -0,0 +1,98 @@ | |||
# Copyright (c) 2022, NVIDIA CORPORATION. | |||
|
|||
repos: |
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.
I'll mention it here because I haven't fixed it yet in cuDF and this is a new file: the indentation of this file is ...aggressive. I'd prefer to see something more like 2 or 4 spaces instead of 8 spaces in some places and 2 or 4 in others. Maybe there's a standard YAML formatter that can be run once (no need to enforce the format with tooling, just get it into a normalized state).
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.
I usually add https://github.com/jumanjihouse/pre-commit-hook-yamlfmt to the pre-commit hooks for this reason.
@gpucibot merge |
This change adds a pre-commit hook to run on each commit, that will automatically run code linters and not allow you
to commit changes if the linters fail. This is similar to how cudf uses pre-commit, as described in rapidsai/cudf#9309 . The pre-commit checks will also be run in CI as part of the check style script.
This change also adds several new linters that weren't being run in CI before:
Of these new linters - mypy caught an issue where the test_comms.py would always be skipped (
python/raft-dask/raft_dask/test/test_comms.py:23: error: Module "raft_dask" has no attribute "Comms"
), and Pydocstyle caught some minor formatting inconsistencies in the python docstrings. black/isort ensure consistent code formatting for the python raft code