Skip to content

CI add pre-commit, check notebook imports are sorted #4088

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

Merged
merged 2 commits into from
Sep 10, 2020

Conversation

MarcoGorelli
Copy link
Contributor

@MarcoGorelli MarcoGorelli commented Sep 8, 2020

closes #4077

This allows the check to be carried out without requiring users to add pre-commit, nbqa, or isort to the dev requirements.

Also, it means that once #4083 is merged, you can easily add

-   repo: https://github.com/asottile/pyupgrade
    rev: v2.7.2
    hooks:
    -   id: pyupgrade

to .pre-commit-config.yaml , and similarly for any other code-quality tool (e.g. black, flake8, you name it...) you decide to add to this amazing repo

@codecov
Copy link

codecov bot commented Sep 8, 2020

Codecov Report

Merging #4088 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #4088   +/-   ##
=======================================
  Coverage   88.48%   88.48%           
=======================================
  Files          88       88           
  Lines       13865    13865           
=======================================
  Hits        12268    12268           
  Misses       1597     1597           

@MarcoGorelli MarcoGorelli mentioned this pull request Sep 8, 2020
Copy link
Contributor

@AlexAndorra AlexAndorra left a comment

Choose a reason for hiding this comment

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

Looks super nice and should make our lives easier, thanks a lot @MarcoGorelli 🎉
Approving but will merge a bit later, in case somebody else wants to comment.

Just had a couple questions:

  • the pre-commit.yml file looks a bit esoteric to me -- does it come from a standard configuration or something like that?
  • Does the line rev: 0.1.29 in .pre-commit-config.yaml mean that the commit hook will stay with this version of nbqa instead of just using the latest?
  • Also, can you update the NB style guide accordingly once this PR is merged?

@MarcoGorelli
Copy link
Contributor Author

Thanks Alex!

* the `pre-commit.yml` file looks a bit esoteric to me -- does it come from a standard configuration or something like that?

Yes, it's for pre-commit. If you install it, then any time you make a commit, pre-commit checks will run against the files you modified. If you don't install it, then the checks will just run during CI and won't interfere with the rest of your development. We use it in pandas https://github.com/pandas-dev/pandas/blob/master/.pre-commit-config.yaml , I find it to be a really great tool.

* Does the line `rev: 0.1.29` in `.pre-commit-config.yaml` mean that the commit hook will stay with this version of nbqa instead of just using the latest?

If you run pre-commit autoupdate from the command line, it'll update each hook to its latest version.

* Also, can you update [the NB style guide](https://github.com/pymc-devs/pymc3/wiki/PyMC's-Jupyter-Notebook-Style) accordingly once this PR is merged?

Would love to but I don't think I have permission to do so

@MarcoGorelli
Copy link
Contributor Author

Thanks Alex!

* the `pre-commit.yml` file looks a bit esoteric to me -- does it come from a standard configuration or something like that?

Yes, it's for pre-commit. If you install it, then any time you make a commit, pre-commit checks will run against the files you modified. If you don't install it, then the checks will just run during CI and won't interfere with the rest of your development. We use it in pandas https://github.com/pandas-dev/pandas/blob/master/.pre-commit-config.yaml , I find it to be a really great tool.

Sorry, my bad, you were asking about pre-commit.yml here, not about .pre-commit-config.yaml. It comes from here https://github.com/pre-commit/action , although it seems they've now released a version 2 of this action (whose config file looks significantly less esoteric 🤣 ) so I've updated to use that one instead

@AlexAndorra
Copy link
Contributor

Ha ha, indeed, this looks much better 😆 Thanks for updating!
Going to merge now, as we gave it 24h. Did you try updating the style guide though? I was under the impression that everyone could update it, but maybe I'm mistaken

@AlexAndorra AlexAndorra merged commit 5ffba85 into pymc-devs:master Sep 10, 2020
@MarcoGorelli MarcoGorelli deleted the pre-commit-checks branch September 10, 2020 12:18
@MarcoGorelli
Copy link
Contributor Author

@AlexAndorra you're right, I was able to update it, and so have done so - thanks!

@AlexAndorra
Copy link
Contributor

Thanks @MarcoGorelli , looks good! Do you mind also adding a line about the new pre-commit GitHub Action you set up?

@MarcoGorelli
Copy link
Contributor Author

Sure, done @AlexAndorra - I also indented the paragraphs so markdown formats them in a more readable manner

@AlexAndorra
Copy link
Contributor

Awesome, thanks again @MarcoGorelli ! Now that I think about it, it seems like we can also Black-format the NBs with nbqa, can't we? If so, we may as well add a GitHub action for that too -- would get rid of the 4th step in the style guide

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

STYLE, CLN order imports according to PyMC's Jupyter Notebook Style
2 participants