Skip to content
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

nbstripout or auto-formatting #105

Open
adrn opened this issue Sep 11, 2022 · 2 comments
Open

nbstripout or auto-formatting #105

adrn opened this issue Sep 11, 2022 · 2 comments

Comments

@adrn
Copy link
Contributor

adrn commented Sep 11, 2022

In my own projects with tutorials and jupyter notebooks, I like to use pre-commit to run nbstripout to remove notebook metadata and cell output to clean up git diffs and the version control history. I also now use black (again with pre-commit) to apply auto-formatting to the notebook cells.

Would you be open to a PR that sets this up for the Session16 notebooks?

@adamamiller
Copy link
Contributor

We also post solutions in the repository along with the notebooks. I'm not familiar with these tools (though they sound like they would remove lots of headaches for our program), but I want to be sure that in a notebook that has solutions - where it's essential to see the output - we don't lose anything.

@adrn
Copy link
Contributor Author

adrn commented Sep 12, 2022

Oh, I should have given a summary:

  • nbstripout will remove metadata and output from notebooks, but it's possible to set directories and glob patterns to exclude.
  • black auto-formats code in a consistent, pep8-compliant way. I don't love all of its choices, but it removes the need to think about code formatting. (As you might expect, it can be a divisive tool and has led to many debates!)
  • pre-commit is a way of automatically running things at the git commit stage, so it provides a way of running nbstripout and black to clean up and reformat notebooks before they even get committed to a repo.

To start, we could try just enabling it for the non-solution notebooks in Session16?

I was also thinking it might make sense to make each session its own repository within the LSSTC-DSFP organization rather than a subfolder (cloning the repo takes a long time!), which would allow for more fine-grained control over testing and repository infrastructure (installation requirements, CI, etc.), but just a thought.

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

No branches or pull requests

2 participants