-
Notifications
You must be signed in to change notification settings - Fork 7
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
Pre commit #17
Pre commit #17
Conversation
Required downgrading python to 3.7; it looks like maybe a virtualenv issue, rather than a pre-commit issue? I also created a very brief README mostly to include instructions on using pre-commit.
Note that this will downgrade python from 3.8 to 3.7; it looks like there's an issue with |
We want to allow large files in the repo, otherwise we won't be able to update notebooks.
Just need to run the pre-commit install line from casper rather than cheyenne (documented this in the README as well)
First set of tests came from Keith's CESM2 carbon cycle paper work (that seemed like a good source, since it's also where the utils_units.py file came from)
I'm not sure if we'll be able to test this before accepting the PR; there's a bit of a chicken and egg problem where I can't put this directly on master since the tests are only on my branch
Beginning to wish there was a way to test this before committing it...
It takes ~4 minutes to spin up the conda environment and run @klindsay28 -- I was getting deprecation warnings from |
Also, I'm leaning against having |
I think this one is ready to go, but would appreciate more eyes on it. There's a README with instructions for setting up |
rev: 19.10b0 | ||
hooks: | ||
- id: black | ||
args: [] |
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 we add the following pre-commit hook for formatting notebooks as well:
- repo: https://github.com/deathbeds/prenotebook
rev: f5bdb72a400f1a56fe88109936c83aa12cc349fa
hooks:
- id: prenotebook
args:
[
'--keep-output',
'--keep-metadata',
'--keep-execution-count',
'--keep-empty',
]
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.
I have nothing to add beyond the feedback from @andersy005.
Looks good to me.
1. Add prenotebook hook to pre-commit 2. Use pre-commit to run black (and now prenotebook) in Github Action I also updated the environment to get black from pip instead of conda so that users will have the latest version in their environment. This avoids a weird inconsistency where running black through pre-commit behaves differently than running black from the command line -- as a specific example, conda was installing black v19.10b, but Github Action was pulling 20.8b1 from pip and the later version had stricter formatting requirements for docstrings. I updated pre-commit to match what was being reported from Github Action (before modifying the action itself), and wanted the same version in environment.yaml. Note that the prenotebook hook picked up some changes in several notebooks.
As noted in the last commit message, I've implemented two of Anderson's suggestions:
I also updated the environment file to get |
Adding
pre-commit
to the environment and aREADME.md
file detailing how to set it up. I want to addpytest
via this pull request as well (and have pre-commit run the tests as well), so this will remain a draft PR until I finish that.Fixes #13