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
Add precommit #2790
Add precommit #2790
Conversation
@SauravMaheshkar Thanks for the contribution! @arunppsg Could you take a quick look at this PR? It might dovetail nicely with your planned work on the yml infrastructure for the CI |
Hey @SauravMaheshkar, thank you very much for the contribution. A couple of general thoughts and suggestions:
A general doubt: I feel that the requirement of |
NOTE: I've removed
|
On 1, sorry I did not know it earlier that it only runs on staged files. On 2, I defer to @rbharath. |
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.
Chatted offline with @arunppsg. I think that since pre-commit is not on the critical path, it would be fine to add on as an extra dependency. The main thing we will need to do in this PR before merge is add in more documentation.
Could you add a description of pre-commit installation/usage as a section to https://github.com/deepchem/deepchem/blob/master/docs/source/development_guide/coding.rst? New developers should be able to read the docs section and set up and run pre-commit locally afterwards
I've added some description in a2424d9. LMK if it looks good. |
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.
Have a couple of minor comments on the docs
First you'll need to setup the git hook scripts by installing them. | ||
|
||
.. code-block:: bash | ||
|
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.
We need to do pip install pre-commit
first right?
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.
Could you also try these instructions out locally on a fresh environment/deepchem install to make sure they work as expected?
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.
pre-commit
is already present in env.common.yml
so there shouldn't be any need to run pip install pre-commit
right ?
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.
Hmm, I'm not sure actually. Could you try installing from source in a fresh environment following directions in the doc and see if it is present for you? The installation flow is a little complex so I'm not sure if the user will actually have pre-commit installed correctly on a fresh install
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.
Yes, it's present by default. Steps I followed:
- Clone my branch (
add-precommit
) to my local system and create a new conda env namedtest
usingenv.common.yml
. - activate the
test
environment and runpre-commit install
. PFA the output
pre-commit installed at .git/hooks/pre-commit
- run
pre-commit run --all-files
this runs pre-commit on the codebase. Output is as follows :
[INFO] Installing environment for https://github.com/pre-commit/mirrors-yapf.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
Check for merge conflicts................................................Passed
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.
PS: There seems to be a lot of yapf
and flake8
inconsistencies in the codebase.
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.
Ah good catch! If you're interested, a follow-up PR cleaning up yapf/flake8 inconsistencies in the codebase would be very useful
I think if the CI looks good, we are clear on my end to merge in. @arunppsg Could you do a review pass as well? |
LGTM! |
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.
A personnel note: I have limited bandwidth and I always try to review pull request at the earliest. Nudging for review sometimes irritates.
Configure
pre-commit
Description
Fix #2743
stable
/master
/main
. For clarification please refer to this.local
" instead of being a hook. For clarification please refer to thisType of change
Please check the option that is related to your PR.
Checklist
yapf -i <modified file>
and check no errors (yapf version must be 0.22.0)mypy -p deepchem
and check no errorsflake8 <modified file> --count
and check no errorspython -m doctest <modified file>
and check no errors