From 7e77b7689ffa154d78f5cdd6ef2c824df85af23a Mon Sep 17 00:00:00 2001 From: Julia Kroll Date: Thu, 4 Aug 2022 11:51:13 -0500 Subject: [PATCH 1/2] Revise linter section to switch from tox to black-nb --- CONTRIBUTING.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9c096ab564..542a6ce35d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -36,12 +36,13 @@ Before sending us a pull request, please ensure that: 1. Clone your fork of the repository: `git clone https://github.com//amazon-sagemaker-examples` where `` is your github username. -### Run the Linters +### Run the Linter -1. Install tox using `pip install tox` -1. cd into the amazon-sagemaker-examples folder: `cd amazon-sagemaker-examples` or `cd /environment/amazon-sagemaker-examples` -1. Run the following tox command and verify that all linters pass: `tox -e black-check,black-nb-check` -1. If the linters did not pass, run the following tox command to fix the issues: `tox -e black-format,black-nb-format` +Apply Python code formatting to Jupyter notebook files using [black-nb](https://pypi.org/project/black-nb/). + +1. Install black-nb using `pip install black-nb` +1. Run the following black-nb command on each of your ipynb notebook files and verify that the linter passes: `black-nb -l 100 {path}/{notebook-name}.ipynb` +1. Some notebook features such as `%` bash commands or `%%` cell magic cause black-nb to fail. As long as you run the above command to format as much as possible, that is sufficient, even if the check fails ### Test Your Notebook End-to-End From e4fb6bb11b731ce88c33a5e867d8017da12d7377 Mon Sep 17 00:00:00 2001 From: Julia Kroll Date: Thu, 4 Aug 2022 11:55:05 -0500 Subject: [PATCH 2/2] Update PR template from tox to black-nb --- .github/PULL_REQUEST_TEMPLATE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index c7d1c2ece8..fbf4feee60 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -11,6 +11,6 @@ _Put an `x` in the boxes that apply. You can also fill these out after creating - [ ] I have read the [CONTRIBUTING](https://github.com/aws/amazon-sagemaker-examples/blob/master/CONTRIBUTING.md) doc and adhered to the example notebook best practices - [ ] I have updated any necessary documentation, including [READMEs](https://github.com/aws/amazon-sagemaker-examples/blob/master/README.md) - [ ] I have tested my notebook(s) and ensured it runs end-to-end -- [ ] I have linted my notebook(s) and code using `tox -e black-format,black-nb-format` +- [ ] I have linted my notebook(s) and code using `black-nb -l 100 {path}/{notebook-name}.ipynb` By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.