-
Notifications
You must be signed in to change notification settings - Fork 15
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 hooks for notebook formatting & reproducibility #22
Conversation
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
Yes, I've configured an endpoint like that for the hoomd azp config that posts releases. You may be able to reuse the existing endpoint. |
Or maybe not, they appear to be per project. The ones I've configured are "release" in gsd, hoomd, and fresnel. |
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!
Does nbqa work with any formatters other than black?
jobs: | ||
- template: job--pre-commit.yml@asottile |
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.
So we are running a job that is define by a .yml file in asottile/azure-pipeline-templates. What if this repo changes the file, or goes stale? We just copy the file in to our templates directory and remove the resources block to keep control.
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.
It's tagged to a release so this file should not be expected to change. I would prefer to let it use the external template for simplicity. ref: refs/tags/v2.1.0
" ]\n", | ||
" scene.camera = fresnel.camera.orthographic(\n", | ||
" position=(0, 0, L + 1), look_at=(0, 0, 0), up=(0, 1, 0), height=L + 1\n", | ||
" )\n", |
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.
In my opinion, black makes code blocks like this harder to read.
"outputs": [], | ||
"source": [ | ||
"m = 5\n", | ||
"N_particles = 2 * m**3" | ||
"N_particles = 2 * m ** 3" |
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.
Spaces around the exponent operator make it hard to read.
Yes, nbqa is flexible. I suspect yapf will work if that's your preference. If you have a yapf settings file or other configuration you want to use, let me know. |
This is the yapf config I use with HOOMD:
You may want to wait until we merge #21 which rewrites many of the notebook files and accept merge those incoming changes before rerunning the formatting. |
@joaander I updated this PR and I think it's using yapf correctly. I copied the |
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!
Description
This PR adds pre-commit checks that should make notebooks a bit more reproducible and improves & automates notebook cell formatting. Metadata is no longer committed, which is a good thing. I verified that the tags discussed in #21 related to nbsphinx hiding certain cells and continuing execution after a cell failure are preserved.
Checklist: