-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Add generate pip dependency's from conda to pre-commit #36531
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 generate pip dependency's from conda to pre-commit #36531
Conversation
Hmm not sure I think this is worth adding to pre-commit - this is something that rarely gets touched |
I think that, if we're relying on pre-commit to manage checks on CI, we should also be checking that development environments (i.e. those specified by environment.yml and requirements.txt) are doing the same checks when e.g. IDEs do linting. Making sure they all describe the same toolchain is important for this and should at least be part of CI. The time added to pre-commit (compared to formatting and linting) would surely be trivial? |
I think this is exactly what should go in pre-commit. Since I don't change the deps often I never remember the check and am annoyed when CI fails :) |
I think you'll need |
I tried using system, but it gives a weird error as if the file name is passed as argument:
|
yeah this is prob fine. @erfannariman you can change out of draft mode; ping on green. |
failed with an ImportError of yaml |
Yes, same error as my initial comment. Not sure how to use local environment. Tried to go through docs of pre-commit and some issues created for the same problem, could not figure out. |
Found the solution, this should work, I had to use |
Nice! Could you just remove the
line, so that if you do modify |
Yes makes sense, done. |
Could this be extended to check that pre-commit uses the same tool versions as environment.yml? I know that's not true currently with flake8 but it could save some pain for contributors in the future, as pre-commit uses a different environment to the rest. |
@MarcoGorelli we can have |
Not sure if I understand you correctly, but isn't the usecase for this hook that it checks your local environment? |
I think that, once the version of flake8 has been aligned between environment.yml and pre-commit-config.yaml, then this could be added as a separate pre-commit hook (in a separate PR) |
sounds like a good idea |
ready for review @MarcoGorelli |
can you resolve the conflict please? Then I'll take another look |
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 also include requirements-dev.txt, in case it was changed accidentally and no longer matches?
@MarcoGorelli yes, done @clbarnes added requirements-dev.txt as well. |
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.
Nice! I just checked this out locally and it works as intended
thanks @erfannariman |
I'm seeing |
I thought |
Looks like on mac python will point at python3 sometime later this year when 10.16 is released. ill just be patient until then. thanks for taking a look |
Sorry, my bad, this uses @jbrockmendel if you change this hook to - repo: local
hooks:
- id: pip_to_conda
name: Generate pip dependency from conda
description: This hook checks if the conda environment.yml and requirements-dev.txt are equal
language: python
entry: python -m scripts.generate_pip_deps_from_conda
files: ^(environment.yml|requirements-dev.txt)$
pass_filenames: false
additional_dependencies: [pyyaml] then does it work? (just tried this on a laptop where |
closes: #36529
First try, not sure yet how to activate local virtual env, error message right now is: