Skip to content
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

[dev] restrict pylint to changed files #4184

Merged
merged 3 commits into from
Oct 29, 2024
Merged

Conversation

cg505
Copy link
Collaborator

@cg505 cg505 commented Oct 26, 2024

Use a similar approach to what we do with yapf to limit pylint to only files that have changed from master.

On my machine this shaves about a minute off pylint runtime, making pylint 7-8x faster and format.sh 3-4x faster.

Tested (run the relevant ones):

  • Code formatting: bash format.sh :)
  • Any manual or new tests for this PR (please specify below)
  • All smoke tests: pytest tests/test_smoke.py
  • Relevant individual smoke tests: pytest tests/test_smoke.py::test_fill_in_the_name
  • Backward compatibility tests: conda deactivate; bash -i tests/backward_compatibility_tests.sh

@cg505
Copy link
Collaborator Author

cg505 commented Oct 26, 2024

oh it seems this is actually broken it is fixed now

@cg505 cg505 marked this pull request as draft October 26, 2024 01:13
@cg505 cg505 marked this pull request as ready for review October 26, 2024 01:18
Copy link
Collaborator

@romilbhardwaj romilbhardwaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @cg505!

format.sh Outdated
@@ -77,7 +81,7 @@ format_changed() {
MERGEBASE="$(git merge-base origin/master HEAD)"

if ! git diff --diff-filter=ACM --quiet --exit-code "$MERGEBASE" -- '*.py' '*.pyi' &>/dev/null; then
git diff --name-only --diff-filter=ACM "$MERGEBASE" -- '*.py' '*.pyi' | xargs -P 5 \
git diff --name-only --diff-filter=ACM "$MERGEBASE" -- '*.py' '*.pyi' | xargs -P 5 -d '\n' \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like -d is not available on mac:

xargs: invalid option -- d
usage: xargs [-0opt] [-E eofstr] [-I replstr [-R replacements] [-S replsize]]
             [-J replstr] [-L number] [-n number [-x]] [-P maxprocs]
             [-s size] [utility [argument ...]]

Any other fix than having all macos users install gnu xargs? https://superuser.com/questions/467176/replacement-for-xargs-d-in-osx

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the catch! This only matters if there are filenames with spaces, which we probably don't expect but should still handle.
I think we can use tr '\n' '\0' | xargs -0 instead. Will update.

Copy link
Collaborator

@romilbhardwaj romilbhardwaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @cg505! Excited that pylint is much faster now :)

@cg505 cg505 added this pull request to the merge queue Oct 29, 2024
Merged via the queue into skypilot-org:master with commit ce8d2df Oct 29, 2024
20 checks passed
@cg505 cg505 deleted the fast-pylint branch October 29, 2024 16:24
yika-luo pushed a commit that referenced this pull request Oct 29, 2024
* [dev] restrict pylint to changed files

* fix glob

* avoid use of xargs -d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants