Skip to content

Commit 959f304

Browse files
author
Svetlana Karslioglu
authored
Merge branch 'master' into fix_display_bug
2 parents b3d4518 + a585992 commit 959f304

File tree

1 file changed

+362
-21
lines changed

1 file changed

+362
-21
lines changed

CONTRIBUTING.md

Lines changed: 362 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,372 @@
11
# Contributing to tutorials
2+
23
We want to make contributing to this project as easy and transparent as
3-
possible.
4+
possible. This file covers information on flagging issues, contributing
5+
updates to existing tutorials--and also submitting new tutorials.
6+
7+
NOTE: This guide assumes that you have your GitHub account properly
8+
configured, such as having an SSH key. If this is your first time
9+
contributing on GitHub, see the [GitHub
10+
Documentation](https://docs.github.com/en/get-started/quickstart/contributing-to-projects)
11+
on contributing to projects.
12+
13+
14+
# Issues
15+
16+
We use [GitHub Issues](https://github.com/pytorch/tutorials/issues) to
17+
track public bugs. Please ensure your description is clear and has
18+
sufficient instructions to be able to reproduce the issue.
19+
20+
21+
# Security Bugs
422

5-
## Pull Requests
6-
We actively welcome your pull requests.
23+
Facebook has a [bounty program](https://www.facebook.com/whitehat/) for
24+
the safe disclosure of security bugs. For these types of issues, please
25+
go through the process outlined on that page and do not file a public
26+
issue.
727

8-
1. Fork the repo and create your branch from `master`.
9-
2. If you've added code that should be tested, add tests.
10-
3. If you've changed APIs, update the documentation.
11-
4. Ensure the test suite passes.
12-
5. Make sure your code lints.
13-
6. If you haven't already, complete the Contributor License Agreement ("CLA").
28+
# Contributor License Agreement ("CLA")
1429

15-
## Contributor License Agreement ("CLA")
16-
In order to accept your pull request, we need you to submit a CLA. You only need
17-
to do this once to work on any of Facebook's open source projects.
30+
In order to accept a pull request, you need to submit a CLA. You only
31+
need to do this once and you will be able to work on all of Facebook's
32+
open source projects, not just PyTorch.
1833

1934
Complete your CLA here: <https://code.facebook.com/cla>
2035

21-
## Issues
22-
We use GitHub issues to track public bugs. Please ensure your description is
23-
clear and has sufficient instructions to be able to reproduce the issue.
2436

25-
Facebook has a [bounty program](https://www.facebook.com/whitehat/) for the safe
26-
disclosure of security bugs. In those cases, please go through the process
27-
outlined on that page and do not file a public issue.
37+
# License
38+
39+
By contributing to the tutorials, you agree that your contributions will
40+
be licensed as described in the `LICENSE` file in the root directory of
41+
this source tree.
42+
43+
44+
# Updates to existing tutorials
45+
46+
We welcome your pull requests (PR) for updates and fixes.
47+
48+
1. If you haven't already, complete the Contributor License Agreement
49+
("CLA").
50+
1. Fork the repo and create a branch from
51+
[`master`](https://github.com/pytorch/tutorials).
52+
1. Test your code.
53+
1. Lint your code with a tool such as
54+
[Pylint](https://pylint.pycqa.org/en/latest/).
55+
1. Submit your PR for review.
56+
57+
58+
# New Tutorials
59+
60+
There are three types of tutorial content that we host on
61+
[`pytorch.org/tutorials`](https://github.com/pytorch/tutorials):
62+
63+
* **Interactive tutorials** are authored and submitted as Python files.
64+
The build system converts these into Jupyter notebooks and HTML. The
65+
code in these tutorials is run every time they are built. To keep
66+
these tutorials up and running all their package dependencies need to
67+
be resolved--which makes it more challenging to maintain this type of
68+
tutorial.
69+
70+
* **Non-interactive tutorials** are authored and submitted as
71+
reStructuredText files. The build system only converts them into HTML;
72+
the code in them does not run on build. These tutorials are easier to
73+
create and maintain but they do not provide an interactive experience.
74+
An example is the [Dynamic Quantization
75+
tutorial](https://pytorch.org/tutorials/recipes/recipes/dynamic_quantization.html).
76+
77+
* **Recipes** are tutorials that provide bite-sized, actionable
78+
examples of how to use specific features, which differentiates them
79+
from full-length tutorials. Recipes can be interactive or
80+
non-interactive.
81+
82+
83+
# Managing data that is used by your tutorial
84+
85+
Your tutorial might depend on external data, such as pre-trained models,
86+
training data, or test data. We recommend storing this data in a
87+
commonly-used storage service, such as Amazon S3, and instructing your
88+
users to download the data at the beginning of your tutorial.
89+
90+
The
91+
[Makefile](https://github.com/pytorch/tutorials/blob/master/Makefile)
92+
that we use to build the tutorials contains automation that downloads
93+
required data files.
94+
95+
96+
# Python packages used by your tutorial
97+
98+
If your tutorial has dependencies that are not already defined in
99+
`requirements.txt`, you should add them to that file. We recommend that
100+
you use only mature, well-supported packages in your tutorial. Packages
101+
that are obscure or not well-maintained may break as a result of, for
102+
example, updates to Python or PyTorch or other packages. If your
103+
tutorial fails to build in our Continuous Integration (CI) system, we
104+
might contact you in order to resolve the issue.
105+
106+
107+
# Deprecation of tutorials
108+
109+
Under some circumstances, we might deprecate--and subsequently
110+
archive--a tutorial removing it from the site. For example, if the
111+
tutorial breaks in our CI and we are not able to resolve the issue and
112+
are also not able to reach you, we might archive the tutorial. In these
113+
situations, resolving the breaking issue would normally be sufficient to
114+
make the tutorial available again.
115+
116+
Another situation in which a tutorial might be deprecated is if it
117+
consistently receives low ratings--or low usage--by the community. Again,
118+
if this occurs, we will attempt to contact you.
119+
120+
If we identify, or suspect, that your tutorial--or a package that your
121+
tutorial uses--has a **security or privacy** issue, we will immediately
122+
take the tutorial off the site.
123+
124+
125+
# Guidance for authoring tutorials and recipes
126+
127+
In this section, we describe the process for creating tutorials and
128+
recipes for Pytorch.
129+
130+
The first step is to decide which type of tutorial you want to create,
131+
taking into account how much support you can provide to keep the
132+
tutorial up-to-date. Ideally, your tutorial should demonstrate PyTorch
133+
functionality that is not duplicated in other tutorials.
134+
135+
As described earlier, tutorials are resources that provide a holistic
136+
end-to-end understanding of how to use PyTorch. Recipes are scoped
137+
examples of how to use specific features; the goal of a recipe is to
138+
teach readers how to easily leverage features of PyTorch for their
139+
needs. Tutorials and recipes are always _actionable_. If the material is
140+
purely informative, consider adding it to the API docs instead.
141+
142+
View our current [full-length tutorials](https://pytorch.org/tutorials/).
143+
144+
To create actionable tutorials, start by identifying _learning
145+
objectives_, which are the end goals. Working backwards from these
146+
objectives will help to eliminate extraneous information.
147+
148+
149+
## Learning objectives ##
150+
151+
To create the learning objectives, focus on what the user will
152+
implement. Set expectations by explicitly stating what the recipe will
153+
cover and what users will implement by the end. Here are some examples:
154+
155+
- Create a custom dataset
156+
- Integrate a dataset using a library
157+
- Iterate over samples in the dataset
158+
- Apply a transform to the dataset
159+
160+
161+
## Voice and writing style ##
162+
163+
Write for a global audience with an instructive and directive voice.
164+
165+
- PyTorch has a global audience; use clear, easy to understand
166+
language. Avoid idioms or other figures of speech.
167+
- To keep your instructions concise, use
168+
[active voice](https://writing.wisc.edu/handbook/style/ccs_activevoice/) as much as possible.
169+
- For a short guide on the essentials of writing style,
170+
[The Elements of Style](https://www.gutenberg.org/files/37134/37134-h/37134-h.htm)
171+
is invaluable.
172+
- For extensive guidance on technical-writing style, the Google developer documentation
173+
[google style](https://developers.google.com/style)
174+
is a great resource.
175+
- Think of the process as similar to creating a (really practical)
176+
Medium post.
177+
178+
179+
## Structure ##
180+
181+
We recommend that tutorials use the following structure which guides users through the learning experience and provides appropriate context:
182+
183+
1. Introduction
184+
1. Motivation: Why is this topic important?
185+
1. Link to relevant research papers or other background material.
186+
1. Learning objectives: Clearly state what the tutorial covers and what
187+
users will implement by the end. For example: Provide a summary of
188+
how the Integrated Gradients feature works and how to implement it
189+
using Captum. The
190+
[TensorBoard](https://pytorch.org/tutorials/intermediate/tensorboard_tutorial.html)
191+
tutorial provides a good example of how to specify learning
192+
objectives.
193+
1. Setup and requirements. Call out any required setup or data
194+
downloads.
195+
1. Step-by-step instructions. Ideally, the steps in the tutorial should
196+
map back to the learning objectives. Consider adding comments in the
197+
code that correspond to these steps and that help to clarify what
198+
each section of the code is doing.
199+
1. Link to relevant [PyTorch
200+
documentation](https://pytorch.org/docs/stable/index.html). This
201+
helps readers have context for the tutorial source code and better
202+
understand how and why it implements the technique you’re
203+
demonstrating.
204+
1. Recap/Conclusion: Summarize the steps and concepts covered. Highlight
205+
key takeaways.
206+
1. (Optional) Additional practice exercises for users to test their
207+
knowledge. An example is [NLP From Scratch: Generating Names with a
208+
Character-Level RNN tutorial](https://pytorch.org/tutorials/intermediate/char_rnn_generation_tutorial.html#exercises).
209+
1. Additional resources for more learning, such as documentation, other
210+
tutorials, or relevant research.
211+
212+
213+
## Example Tutorials ##
214+
215+
The following tutorials do a good job of demonstrating the ideas
216+
described in the preceding sections:
217+
218+
- [Chatbot Tutorial](https://pytorch.org/tutorials/beginner/chatbot_tutorial.html)
219+
- [Tensorboard Tutorial](https://pytorch.org/tutorials/intermediate/tensorboard_tutorial.html)
220+
- [NLP From Scratch: Generating Names with a Character-Level RNN
221+
Tutorial](https://pytorch.org/tutorials/intermediate/char_rnn_generation_tutorial.html)
222+
223+
If you are creating a recipe, we recommend that you use [this
224+
template](https://github.com/pytorch/tutorials/blob/tutorials_refresh/recipes_source/recipes/example_recipe.py)
225+
as a guide.
226+
227+
228+
# Submission Process #
229+
230+
Submit your tutorial as either a Python (`.py`) file or a
231+
reStructuredText (`.rst`) file. For Python files, the filename for your
232+
tutorial should end in "`_tutorial.py`"; for example,
233+
"`cool_pytorch_feature_tutorial.py`".
234+
235+
Do not submit a Jupyter notebook. If you develop your tutorial in
236+
Jupyter, you'll need to convert it to Python. This
237+
[script](https://gist.github.com/chsasank/7218ca16f8d022e02a9c0deb94a310fe)
238+
is one option for performing this conversion.
239+
240+
For Python files, our CI system runs your code during each build.
241+
242+
243+
## Add Your Tutorial Code ##
244+
245+
1. [Fork and
246+
clone](https://docs.github.com/en/get-started/quickstart/contributing-to-projects)
247+
the repo:
248+
[https://github.com/pytorch/tutorials](https://github.com/pytorch/tutorials)
249+
250+
1. Put the tutorial in one of the
251+
[`beginner_source`](https://github.com/pytorch/tutorials/tree/master/beginner_source),
252+
[`intermediate_source`](https://github.com/pytorch/tutorials/tree/master/intermediate_source),
253+
[`advanced_source`](https://github.com/pytorch/tutorials/tree/master/advanced_source)
254+
based on the technical level of the content. For recipes, put the
255+
recipe in
256+
[`recipes_source`](https://github.com/pytorch/tutorials/tree/master/recipes_source).
257+
In addition, for recipes, add the recipe in the recipes
258+
[README.txt](https://github.com/pytorch/tutorials/blob/master/recipes_source/recipes/README.txt)
259+
file.
260+
261+
262+
## Include Your Tutorial in `index.rst`#
263+
264+
In order for your tutorial to appear on the website, and through tag
265+
search, you need to include it in `index.rst`, or for recipes, in
266+
`recipes_index.rst`.
267+
268+
1. Open the relevant file
269+
[`index.rst`](https://github.com/pytorch/tutorials/blob/master/index.rst)
270+
or
271+
[`recipes_index.rst`](https://github.com/pytorch/tutorials/blob/master/recipes_source/recipes_index.rst)
272+
1. Add a _card_ in reStructuredText format similar to the following:
273+
274+
```
275+
.. customcarditem::
276+
:header: Learn the Basics # Tutorial title
277+
:card_description: A step-by-step guide to building a complete ML workflow with PyTorch. # Short description
278+
:image: _static/img/thumbnails/cropped/60-min-blitz.png # Image that appears with the card
279+
:link: beginner/basics/intro.html
280+
:tags: Getting-Started
281+
```
282+
283+
284+
### Link ###
285+
286+
The `link` should be the path to your tutorial in the source tree. For
287+
example, if the tutorial is in `beginner_source`, the link will be
288+
`beginner_source/rest/of/the/path.html`
289+
290+
291+
### Tags ###
292+
293+
Choose tags from the existing tags in the file. Reach out to a project
294+
maintainer to create a new tag. The list of tags should not have any
295+
white space between the words. Multi-word tags, such as “Getting
296+
Started”, should be hyphenated: Getting-Started. Otherwise, the tutorial
297+
might fail to build, and the cards will not display properly.
298+
299+
300+
### Image ###
301+
302+
Add a thumbnail to the
303+
[`_static/img/thumbnails/cropped`](https://github.com/pytorch/tutorials/tree/master/_static/img/thumbnails/cropped)
304+
directory. Images that render the best are square--that is, they have
305+
equal `x` and `y` dimensions--and also have high resolution. [Here is an
306+
example](https://github.com/pytorch/tutorials/blob/master/_static/img/thumbnails/cropped/loading-data.PNG).
307+
308+
## `toctree` ##
309+
310+
1. Add your tutorial under the corresponding toctree (also in
311+
`index.rst`). For example, if you are adding a tutorial that
312+
demonstrates the PyTorch ability to process images or video, add it
313+
under `Image and Video`:
314+
315+
```
316+
.. toctree::
317+
:maxdepth: 2
318+
:includehidden:
319+
:hidden:
320+
:caption: Image and Video
321+
322+
intermediate/torchvision_tutorial
323+
beginner/my-new-tutorial
324+
```
325+
326+
327+
## Test Your Tutorial Locally ##
328+
329+
The following command builds an HTML version of the tutorial website.
330+
331+
```
332+
make html-noplot
333+
```
334+
335+
This command does not run your tutorial code. To build the tutorial in a
336+
way that executes the code, use `make docs`. However, unless you have a
337+
GPU-powered machine and a proper PyTorch CUDA setup, running this `make`
338+
command locally won't work. The continuous integration (CI) system will
339+
test your tutorial when you submit your PR.
340+
341+
342+
## Submit the PR ##
343+
344+
NOTE: Please do not use [ghstack](https://github.com/ezyang/ghstack). We
345+
do not support ghstack in the [`pytorch/tutorials`](https://github.com/pytorch/tutorials) repo.
346+
347+
Submit the changes as a PR to the master branch of
348+
[`pytorch/tutorials`](https://github.com/pytorch/tutorials).
349+
350+
1. Add your changes, commit, and push:
351+
352+
```
353+
git add -A
354+
git commit -m "Add <mytutorial>"
355+
git push --set-upstream mybranch
356+
```
357+
358+
1. Submit the PR and tag individuals on the PyTorch project who can review
359+
your PR.
360+
1. Address all feedback comments from your reviewers.
361+
1. Make sure all CI checks are passing.
362+
363+
Once you submit your PR, you can see a generated Netlify preview of your
364+
build. You can see an example Netlify preview at the following URL:
365+
366+
> <https://deploy-preview-954--pytorch-tutorials-preview.netlify.app/>
367+
368+
369+
## Do not merge the PR yourself ##
370+
371+
Please **DO NOT MERGE** your own PR; the tutorial won't be published. In order to avoid potential build breaks with the tutorials site, only certain maintainers can authorize publishing.
28372
29-
## License
30-
By contributing to tutorials, you agree that your contributions will be licensed
31-
under the LICENSE file in the root directory of this source tree.

0 commit comments

Comments
 (0)