-
Notifications
You must be signed in to change notification settings - Fork 246
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
Updat .pre-commit hook version #1795
Conversation
Hi @juanitorduz, just want to double check my understanding:
|
Hey @fehiepsi, thanks for your feedback. Here are some comments:
Yes! I just added it ✅
Yes! The user has to simply do once
Yes. They look like py-econometrics/pyfixest#417
In principle, once you do
As mentioned above, the pre-commit environment will always be in sync with the version from the config. This is the version in which all the checks (locally and in CI) will be used. If you install it in your environment, one needs to install the version from the .pre-commit config (only source of truth)
The checks will be done on whatever is specified in numpyro/.pre-commit-config.yaml Line 8 in 1d0cedb
It's up to us to decide which folders to consider. At the moment is doing it in both (numpyro and test) and checks are 🟢 :)
The ruff configurations from the pre-commit hooks are consistently specified in https://github.com/pyro-ppl/numpyro/blob/master/pyproject.toml. This is why they are incorporated. To test this PR (and see if this is something you want to have), I suggest you create a fresh Python environment and make a dummy change without installing |
Thanks, @juanitorduz! Just a couple of thoughts:
|
Thanks for the clarification. Here are some answers to your valid concerns:
I am sorry to hear! Feel free to open issues if you see this happening again and I will take a look at it. In my experience, having everything synced with pree-commit does help (this is just a personal opinion based on previous experiences)
This makes sense when developing. As described before you can add the
Indeeed! Some projects do it and some projects do not. If you want to do it we can have a separate issue / PR to tackle this and atdd the
In view of this observation, I moved the pre-commit to @fehiepsi, think about the proposed changes, and if you are not convinced, it is totally ok (this was just a suggestion). We can close this one and come back once we are ready :) |
Thanks for your clarifications, @juanitorduz! I'm also learning. I think we will want to make this optional for contributors who prefer using precommit, rather than requiring it. Regarding the configuration, the upstream doc seems to suggest that an entry for How about just enhancing precommit in this PR? |
78b77e9
to
157d120
Compare
Sure! Let's do it! As we want to keep |
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. It would be nice if you can update the precommit to include the id ruff-format
and support for other folders like notebooks and examples. This will make precommit aligns with what make format
does. But it is fine if you just want to use it to fix lint (not format) issues on numpyro and tests folders.
Added in 0156028 :) I also ran |
.pre-commit-config.yaml
Outdated
files: "numpyro/.*|tests/.*" | ||
entry: ruff check | ||
args: ["--fix", "--output-format=full"] | ||
files: "numpyro/.*|tests/.*|examples/*.py|notebooks/*.ipynb" |
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.
just curious: would this include subfolders, like notebooks/source or examples/cvae_flax?
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.
Now that you mention this, I'll actually try to remove this so that it can target all relevant files as in the make
commands 👌
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.
ok! 😅 After some manual tests and edge cases I think 44595d0 is what we want :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.
thanks!
Thank you for your feedback and patience @fehiepsi 🙌 |
Update pre-commit hook versions:
Edit: This was the original scope of this PR. After #1795 (comment) we decided to unco these changes as we want to keep pre-commit usage optional :)
In this PR, I want to suggest a way to improve the development experience by adding https://pre-commit.ci/ as a unique source of truth for the project's linter.
Motivation
Currently, the CI (GitHub actions) uses the command
make lint
, which runsruff
's check. The problem is that it depends on the local version ofruff
and is therefore ambiguous. See:numpyro/Makefile
Lines 3 to 6 in 2b85765
Suggested Solution
In other projects I have contributed to, we have seen the benefit of having this manager by https://pre-commit.ci/ to:
The only thing you (NumPyro devs) need to do is to add the app to the repo (one click as described in https://pre-commit.ci/)
If we merge this one, we could even remove the lint from GitHub actions (see py-econometrics/pyfixest#397), and the linter would be managed independently. That is, remove
numpyro/.github/workflows/ci.yml
Lines 35 to 37 in 2b85765