Skip to content

Commit 20f4353

Browse files
doc: add documentation guidelines to CONTRIBUTING.md (aws#1279)
* doc: add doc guidelines to CONTRIBUTING.md * fix headings * remove doc-building section from main README Co-authored-by: Aaron Markham <[email protected]>
1 parent 106d949 commit 20f4353

File tree

2 files changed

+123
-40
lines changed

2 files changed

+123
-40
lines changed

CONTRIBUTING.md

+123-29
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,25 @@ information to effectively respond to your bug report or contribution.
99

1010
## Table of Contents
1111

12-
* [Table of Contents](#table-of-contents)
13-
* [Reporting Bugs/Feature Requests](#reporting-bugsfeature-requests)
14-
* [Contributing via Pull Requests (PRs)](#contributing-via-pull-requests-prs)
15-
* [Setting up Your Development Environment *[Optional, but Recommended]*](#setting-up-your-development-environment-optional-but-recommended)
16-
* [Pulling Down the Code](#pulling-down-the-code)
17-
* [Running the Unit Tests](#running-the-unit-tests)
18-
* [Running the Integration Tests](#running-the-integration-tests)
19-
* [Making and Testing Your Change](#making-and-testing-your-change)
20-
* [Committing Your Change](#committing-your-change)
21-
* [Sending a Pull Request](#sending-a-pull-request)
22-
* [Finding Contributions to Work On](#finding-contributions-to-work-on)
12+
* [Report Bugs/Feature Requests](#report-bugsfeature-requests)
13+
* [Contribute via Pull Requests (PRs)](#contribute-via-pull-requests-prs)
14+
* [Set up Your Development Environment *[Optional, but Recommended]*](#set-up-your-development-environment-optional-but-recommended)
15+
* [Pull Down the Code](#pull-down-the-code)
16+
* [Run the Unit Tests](#run-the-unit-tests)
17+
* [Run the Integration Tests](#run-the-integration-tests)
18+
* [Make and Test Your Change](#make-and-test-your-change)
19+
* [Commit Your Change](#commit-your-change)
20+
* [Send a Pull Request](#send-a-pull-request)
21+
* [Documentation Guidelines](#documentation-guidelines)
22+
* [Overviews](#overviews)
23+
* [API References (docstrings)](#api-references-docstrings)
24+
* [Build and Test Documentation](#build-and-test-documentation)
25+
* [Find Contributions to Work On](#find-contributions-to-work-on)
2326
* [Code of Conduct](#code-of-conduct)
2427
* [Security Issue Notifications](#security-issue-notifications)
2528
* [Licensing](#licensing)
2629

27-
## Reporting Bugs/Feature Requests
30+
## Report Bugs/Feature Requests
2831

2932
We welcome you to use the GitHub issue tracker to report bugs or suggest features.
3033

@@ -37,7 +40,7 @@ reported the issue. Please try to include as much information as you can. Detail
3740
* A description of your environment or deployment.
3841

3942

40-
## Contributing via Pull Requests (PRs)
43+
## Contribute via Pull Requests (PRs)
4144

4245
Contributions via pull requests are much appreciated.
4346

@@ -48,53 +51,53 @@ Before sending us a pull request, please ensure that:
4851
* You open an issue to discuss any significant work - we would hate for your time to be wasted.
4952

5053

51-
### Setting up Your Development Environment *[Optional, but Recommended]*
54+
### Set up Your Development Environment *[Optional, but Recommended]*
5255

5356
1. Set up the Cloud9 environment:
5457
1. Instance type: You'll need at least 4 GB of RAM to avoid running into memory issues. We recommend at least a t3.medium to run the unit tests. A larger host will reduce the chance of encountering resource limits.
5558
1. Follow the instructions at [Creating a Cloud9 EC2 Environment](https://docs.aws.amazon.com/cloud9/latest/user-guide/create-environment.html#create-environment-main) to set up a Cloud9 EC2 environment.
5659
1. Expand the storage of the EC2 instance from 10GB to 20GB:
57-
1. Because you'll need a minimum of 11GB of disk storage on the EC2 instance to run the repository's unit tests, you'll need to expand your EC2 volume size. We recommend at least 20GB. A larger volume will reduce the chance of encountering resource limits.
60+
1. Because you'll need a minimum of 11GB of disk storage on the EC2 instance to run the repository's unit tests, you'll need to expand your EC2 volume size. We recommend at least 20GB. A larger volume will reduce the chance of encountering resource limits.
5861
1. Follow the instructions at [Modifying an EBS Volume Using Elastic Volumes (Console)](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/requesting-ebs-volume-modifications.html#modify-ebs-volume) to increase the EBS volume size associated with the newly created EC2 instance.
5962
1. Wait 5-10min for the new EBS volume increase to finalize.
6063
1. Allow EC2 to claim the additional space by stopping and then starting your EC2 host.
6164

6265

63-
### Pulling Down the Code
66+
### Pull Down the Code
6467

6568
1. If you do not already have one, create a GitHub account by following the prompts at [Join Github](https://github.com/join).
6669
1. Create a fork of this repository on GitHub. You should end up with a fork at `https://github.com/<username>/sagemaker-python-sdk`.
6770
1. Follow the instructions at [Fork a Repo](https://help.github.com/en/articles/fork-a-repo) to fork a GitHub repository.
6871
1. Clone your fork of the repository: `git clone https://github.com/<username>/sagemaker-python-sdk` where `<username>` is your github username.
6972

7073

71-
### Running the Unit Tests
74+
### Run the Unit Tests
7275

7376
1. Install tox using `pip install tox`
7477
1. Install coverage using `pip install .[test]`
7578
1. cd into the sagemaker-python-sdk folder: `cd sagemaker-python-sdk` or `cd /environment/sagemaker-python-sdk`
7679
1. Run the following tox command and verify that all code checks and unit tests pass: `tox tests/unit`
7780

78-
You can also run a single test with the following command: `tox -e py36 -- -s -vv <path_to_file><file_name>::<test_function_name>`
81+
You can also run a single test with the following command: `tox -e py36 -- -s -vv <path_to_file><file_name>::<test_function_name>`
7982
* Note that the coverage test will fail if you only run a single test, so make sure to surround the command with `export IGNORE_COVERAGE=-` and `unset IGNORE_COVERAGE`
8083
* Example: `export IGNORE_COVERAGE=- ; tox -e py36 -- -s -vv tests/unit/test_estimator.py::test_sagemaker_model_s3_uri_invalid ; unset IGNORE_COVERAGE`
8184

8285

83-
### Running the Integration Tests
86+
### Run the Integration Tests
8487

85-
Our CI system runs integration tests (the ones in the `tests/integ` directory), in parallel, for every Pull Request.
86-
You should only worry about manually running any new integration tests that you write, or integration tests that test an area of code that you've modified.
88+
Our CI system runs integration tests (the ones in the `tests/integ` directory), in parallel, for every Pull Request.
89+
You should only worry about manually running any new integration tests that you write, or integration tests that test an area of code that you've modified.
8790

8891
1. Follow the instructions at [Set Up the AWS Command Line Interface (AWS CLI)](https://docs.aws.amazon.com/polly/latest/dg/setup-aws-cli.html).
8992
1. To run a test, specify the test file and method you want to run per the following command: `tox -e py36 -- -s -vv <path_to_file><file_name>::<test_function_name>`
9093
* Note that the coverage test will fail if you only run a single test, so make sure to surround the command with `export IGNORE_COVERAGE=-` and `unset IGNORE_COVERAGE`
9194
* Example: `export IGNORE_COVERAGE=- ; tox -e py36 -- -s -vv tests/integ/test_tf_script_mode.py::test_mnist ; unset IGNORE_COVERAGE`
9295

93-
If you are writing or modifying a test that creates a SageMaker job (training, tuner, or transform) or endpoint, it's important to assign a concurrency-friendly `job_name` (or `endpoint_name`), or your tests may fail randomly due to name collisions. We have a helper method `sagemaker.utils.unique_name_from_base(base, max_length)` that makes test-friendly names. You can find examples of how to use it [here](https://github.com/aws/sagemaker-python-sdk/blob/3816a5658d3737c9767e01bc8d37fc3ed5551593/tests/integ/test_tfs.py#L37) and
96+
If you are writing or modifying a test that creates a SageMaker job (training, tuner, or transform) or endpoint, it's important to assign a concurrency-friendly `job_name` (or `endpoint_name`), or your tests may fail randomly due to name collisions. We have a helper method `sagemaker.utils.unique_name_from_base(base, max_length)` that makes test-friendly names. You can find examples of how to use it [here](https://github.com/aws/sagemaker-python-sdk/blob/3816a5658d3737c9767e01bc8d37fc3ed5551593/tests/integ/test_tfs.py#L37) and
9497
[here](https://github.com/aws/sagemaker-python-sdk/blob/3816a5658d3737c9767e01bc8d37fc3ed5551593/tests/integ/test_tuner.py#L616), or by searching for "unique\_name\_from\_base" in our test code.
9598

9699

97-
### Making and Testing Your Change
100+
### Make and Test Your Change
98101

99102
1. Create a new git branch:
100103
```shell
@@ -105,11 +108,12 @@ If you are writing or modifying a test that creates a SageMaker job (training, t
105108
1. Prove that your code works correctly.
106109
1. Guard against future breaking changes to lower the maintenance cost.
107110
1. Please focus on the specific change you are contributing. If you also reformat all the code, it will be hard for us to focus on your change.
108-
1. Run all the unit tests as per [Running the Unit Tests](#running-the-unit-tests), and verify that all checks and tests pass.
109-
1. Note that this also runs tools that may be necessary for the automated build to pass (ex: code reformatting by 'black').
111+
1. Run all the unit tests as per [Run the Unit Tests](#run-the-unit-tests), and verify that all checks and tests pass.
112+
1. Note that this also runs tools that may be necessary for the automated build to pass (ex: code reformatting by 'black').
113+
1. If your changes include documentation changes, please see the [Documentation Guidelines](#documentation-guidelines).
110114

111115

112-
### Committing Your Change
116+
### Commit Your Change
113117

114118
We use commit messages to update the project version number and generate changelog entries, so it's important for them to follow the right format. Valid commit messages include a prefix, separated from the rest of the message by a colon and a space. Here are a few examples:
115119
@@ -135,17 +139,107 @@ Some of the prefixes allow abbreviation ; `break`, `feat`, `depr`, and `doc` are
135139
For the rest of the message, use imperative style and keep things concise but informative. See [How to Write a Git Commit Message](https://chris.beams.io/posts/git-commit/) for guidance.
136140
137141
138-
### Sending a Pull Request
142+
### Send a Pull Request
139143
140144
GitHub provides additional document on [Creating a Pull Request](https://help.github.com/articles/creating-a-pull-request/).
141145
142146
Please remember to:
143-
* Use commit messages (and PR titles) that follow the guidelines under [Committing Your Change](#committing-your-change).
147+
* Use commit messages (and PR titles) that follow the guidelines under [Commit Your Change](#commit-your-change).
144148
* Send us a pull request, answering any default questions in the pull request interface.
145149
* Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation.
146150
147151
148-
## Finding Contributions to Work On
152+
## Documentation Guidelines
153+
154+
We use reStructuredText (RST) for most of our documentation. For a quick primer on the syntax,
155+
see [the Sphinx documentation](https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html).
156+
157+
In this repository, we have two main categories of documentation: overviews and API references.
158+
"How to" tutorials are housed in the [Amazon SageMaker Examples repository](https://github.com/awslabs/amazon-sagemaker-examples).
159+
Overviews and API references are discussed in more detail below.
160+
161+
Here are some general guidelines to follow when writing either kind of documentation:
162+
* Use present tense.
163+
* 👍 "The estimator fits a model."
164+
* 👎 "The estimator will fit a model."
165+
* When referring to an AWS product, use its full name in the first invocation.
166+
(This applies only to prose; use what makes sense when it comes to writing code, etc.)
167+
* 👍 "Amazon S3"
168+
* 👎 "s3"
169+
* Provide links to other ReadTheDocs pages, AWS documentation, etc. when helpful.
170+
Try to not duplicate documentation when you can reference it instead.
171+
* Use meaningful text in a link.
172+
* 👍 You can learn more about [hyperparameter tuning with SageMaker](https://docs.aws.amazon.com/sagemaker/latest/dg/automatic-model-tuning-how-it-works.html) in the SageMaker docs.
173+
* 👎 Read more about it [here](#).
174+
175+
176+
### Overviews
177+
178+
This section refers to documentation that discusses a specific topic or feature to
179+
help the reader deepen their understanding, and may include short snippets of how to do specific tasks.
180+
Examples include "[Amazon SageMaker Debugger](https://sagemaker.readthedocs.io/en/stable/amazon_sagemaker_debugger.html)"
181+
and "[Use MXNet with the SageMaker Python SDK](https://sagemaker.readthedocs.io/en/stable/using_mxnet.html)."
182+
183+
The goal of these documents is to explain basic usage.
184+
This includes the general purpose of the topic or feature,
185+
and common ways to use the SageMaker Python SDK in that context.
186+
187+
This type of documentation should not be a step-by-step tutorial.
188+
That is better suited for the [example notebooks](https://github.com/awslabs/amazon-sagemaker-examples).
189+
Instead, keep the content focused on the unique aspects of the feature.
190+
For example, if one is writing specifically about deploying models,
191+
there is no need to also include instructions on how to train a model first.
192+
In this case, consider linking to existing documentation about training models and any other prerequisites.
193+
194+
Lastly, in addition to the general guidelines listed above:
195+
* Use the imperative mood for headings.
196+
* 👍 "Prepare a Training Script"
197+
* 👎 "Preparing a Training Script"
198+
* Don’t refer to features as "new" - they might be at the time of writing, but they won’t always be!
199+
200+
### API References (docstrings)
201+
202+
The API references are generated from docstrings.
203+
A docstring is the comment in the source code that describes a module, class, function, or variable.
204+
205+
```python
206+
def foo():
207+
"""This comment is a docstring for the function foo."""
208+
```
209+
210+
We use [Google-style docstrings](https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html).
211+
There should be a docstring for every public module, class, and function.
212+
For functions, make sure your docstring covers all of the arguments, exceptions, and any other relevant information.
213+
When possible, link to classes and functions, e.g. use ":class:~\`sagemaker.session.Session\`" over just "Session."
214+
215+
If a parameter of a function has a default value, please note what the default is.
216+
If that default value is `None`, it can also be helpful to explain what happens when the parameter is `None`.
217+
If `**kwargs` is part of the function signature, link to the parent class(es) or method(s) so that the reader knows where to find the available parameters.
218+
219+
For an example file with docstrings, see [the `processing` module](https://github.com/aws/sagemaker-python-sdk/blob/master/src/sagemaker/processing.py).
220+
221+
To have a class's docstrings included in the API reference, it needs to be included in one of the files in the `doc/` folder.
222+
For example, see the [Processing API reference](https://github.com/aws/sagemaker-python-sdk/blob/master/doc/processing.rst).
223+
224+
225+
### Build and Test Documentation
226+
227+
To build the Sphinx docs, run the following command in the `doc/` directory:
228+
229+
```shell
230+
make html
231+
```
232+
233+
You can then find the generated HTML files in `doc/_build/html/`.
234+
235+
To check both the README and API documentation for build errors, you can run the following:
236+
237+
```shell
238+
tox -e twine,sphinx
239+
```
240+
241+
242+
## Find Contributions to Work On
149243

150244
Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels ((enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any ['help wanted'](https://github.com/aws/sagemaker-python-sdk/labels/help%20wanted) issues is a great place to start.
151245

README.rst

-11
Original file line numberDiff line numberDiff line change
@@ -155,17 +155,6 @@ You can also run them in parallel:
155155
tox -- -n auto tests/integ
156156

157157

158-
Building Sphinx docs
159-
~~~~~~~~~~~~~~~~~~~~
160-
161-
``cd`` into the ``doc`` directory and run:
162-
163-
::
164-
165-
make html
166-
167-
You can edit the templates for any of the pages in the docs by editing the .rst files in the ``doc`` directory and then running ``make html`` again.
168-
169158
MXNet SageMaker Estimators
170159
--------------------------
171160

0 commit comments

Comments
 (0)