sandialabs / pyttb

Python Tensor Toolbox
https://pyttb.readthedocs.io
BSD 2-Clause "Simplified" License
26 stars 13 forks source link

Add nbstripout to dev dependencies and commit checks #208

Closed dmdunla closed 1 year ago

dmdunla commented 1 year ago

The following is useful for keeping the jupyter notebook tutorials clean (output and metadata removed):

nbstripout docs/source/tutorial/class_ttensor.ipynb \
--extra-keys "metadata.language_info metadata.vscode metadata.kernelspec"

This will require including nbstripout into the dev dependencies and adding a hook for pre-commits.

ntjohnson1 commented 1 year ago

I looked at adding a check for this, but ran into an issue where nbstripout's check option would fail because it would want to edit something but the change was only the windows line endings not tracked by git. There's hopefully a work around for that but I didn't have time to dig deeper

ntjohnson1 commented 1 year ago

This is much more complicated that desired. The dry-run check on nbstripout is kind of broken currently: https://github.com/kynan/nbstripout/issues/158 we could probably put in the leg work to fix it, but I don't have immediate bandwidth for that. However, it looks like there is a github action to basically just run our pre-commit hooks on a repo https://github.com/pre-commit/action NICE! Even better there is an action that could run the pre-commit hook and commit the changes https://pre-commit.ci/lite but that requires permissions that probably aren't acceptable (or at least would need to check). This would be nice because it would fix the times we forget to run black etc locally or doing a merge on the gui.