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

QOL: easy way to run lint locally that matches the behavior in CI #1448

Open
vkuzo opened this issue Dec 19, 2024 · 5 comments
Open

QOL: easy way to run lint locally that matches the behavior in CI #1448

vkuzo opened this issue Dec 19, 2024 · 5 comments

Comments

@vkuzo
Copy link
Contributor

vkuzo commented Dec 19, 2024

We have the CI lint rules here: https://github.com/pytorch/ao/blob/main/.github/workflows/ruff_linter.yml , currently expressed as

        ruff check .
        # --isolated is used to skip the allowlist at all so this applies to all files
        # please be careful when using this large changes means everyone needs to rebase
        ruff check --isolated --select F821,F823,W191
        ruff check --select F,I
        ruff format --check || {
          echo "Ruff check failed, please try again after running 'ruff format'."
          exit 1
        }

It would be nice to have this logic be reusable, so I can run it locally with something like ./lint_my_code.sh and know that CI will be green. I used to do this with ruff format ., but that no longer matches the CI logic, slowing down the iteration cycle on PRs that pass ruff format . but fail the more extensive checks.

@jerryzh168
Copy link
Contributor

jerryzh168 commented Dec 19, 2024

yeah I already added it: https://github.com/pytorch/ao/blob/main/scripts/run_ruff_fix.sh

does this work for you?

@vkuzo
Copy link
Contributor Author

vkuzo commented Dec 19, 2024

can we make both CI and that script use the same rules, so the chance of divergence from future PRs is reduced?

@jerryzh168
Copy link
Contributor

can we make both CI and that script use the same rules, so the chance of divergence from future PRs is reduced?

yeah I also commented with the same before, although I looked again and CI is doing check but the script is doing fix, we can have a arg to say we are checking or fixing though, I'll submit a PR

@jerryzh168
Copy link
Contributor

jerryzh168 commented Dec 19, 2024

Added here: #1450

@drisspg
Copy link
Contributor

drisspg commented Dec 20, 2024

Updated here: #1453
Left comment about making sure to keep isolated checks in sync.

For more context the way to do this is to use pre-commit run. I would highly recommend people just install these hooks

pre-commit install they are very lightweight

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

No branches or pull requests

3 participants