Skip to content

Commit 211590e

Browse files
authored
Add PR/issue workflow to CONTRIBUTING.md (#4107) (#4153)
Summary: Give contributors more instructions for how we would like them to claim issues and work on PRs. Based on https://github.com/pytorch/torchtune/blob/main/CONTRIBUTING.md Pull Request resolved: #4107 Reviewed By: mergennachin Differential Revision: D59251166 Pulled By: dbort fbshipit-source-id: 29f696452708552feec109eb15dbaae987507258
1 parent ebd076d commit 211590e

File tree

4 files changed

+215
-4
lines changed

4 files changed

+215
-4
lines changed

CONTRIBUTING.md

Lines changed: 191 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,91 @@
1-
Thank you for your interest in contributing to ExecuTorch!
1+
Thank you for your interest in contributing to ExecuTorch! We want to make
2+
it easy to contribute to this project.
23

3-
This document (CONTRIBUTING.md) covers some of the more technical aspects of
4-
contributing.
4+
 
5+
6+
## Dev Install
7+
8+
Set up your environment by following the instructions at
9+
https://pytorch.org/executorch/stable/getting-started-setup.html to clone
10+
the repo and install the necessary requirements.
11+
12+
 
13+
14+
## Contributing workflow
15+
We actively welcome your pull requests (PRs).
16+
17+
1. [Claim an issue](#claiming-issues), if present, before starting work. If an
18+
issue doesn't cover the work you plan to do, consider creating one to provide
19+
context about it, and to build consensus about the scope and solution.
20+
1. Create your new branch from `main` in your forked repo, with a name
21+
describing the work you're completing; e.g., `add-feature-x`.
22+
1. If you've added code that should be tested, add tests. Ensure all tests pass.
23+
See the [testing section](#testing) for more information.
24+
1. If you've changed APIs or added a new tool or feature, [update the
25+
documentation](#updating-documentation).
26+
1. Make sure your code follows the [style guides](#coding-style) and passes the
27+
[lint checks](#lintrunner).
28+
1. If you haven't already, complete the [Contributor License Agreement ("CLA")](#contributor-license-agreement-cla).
29+
1. Create a pull request in the `pytorch/executorch` Github repo using the
30+
[instructions below](#pull-requests).
31+
32+
 
33+
34+
## Issues
35+
36+
### Creating Issues
37+
We use GitHub issues to track public bugs and feature requests. Ensure that the
38+
issue title is clear and descriptive, and that the description has sufficient
39+
instructions to be able to reproduce the issue.
40+
41+
Meta has a [bounty program](https://www.facebook.com/whitehat/) for the safe
42+
disclosure of security bugs. In those cases, please go through the process
43+
outlined on that page and do not file a public issue.
44+
45+
### Claiming Issues
46+
We'd love your help closing out [open
47+
issues](https://github.com/pytorch/executorch/issues?q=sort%3Aupdated-desc+is%3Aissue+is%3Aopen)
48+
in the Github repo.
49+
50+
1. Find an issue with the
51+
[`actionable`](https://github.com/pytorch/executorch/issues?q=sort%3Aupdated-desc+is%3Aissue+is%3Aopen+label%3Aactionable)
52+
or [`good first
53+
issue`](https://github.com/pytorch/executorch/issues?q=sort%3Aupdated-desc+is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22)
54+
label that is not currently assigned to anyone.
55+
- If you'd like to work on an issue that is assigned but hasn't been updated
56+
in a while, discuss a hand-off with the current assignee in the issue
57+
comments.
58+
- If you'd like to work on an issue that isn't marked `actionable`, please
59+
comment on the issue to ask about its status and wait for a response.
60+
1. Set yourself as the assignee of the issue.
61+
1. If you decide not to finish the issue, update the issue with information to
62+
help the next person, then remove yourself from the assignee list.
63+
1. When creating pull requests (PRs), mention the issue number like `#1234` in
64+
the PR description details (the first comment in the PR conversation thread).
65+
1. When the final PR has merged and resolves the issue, close the issue with the
66+
button at the bottom of the issue's page.
67+
68+
 
569

670
## Coding Style
771

872
Goal: Encourage standards that make it easier to read, edit, maintain, and debug
973
the ExecuTorch code.
1074

11-
You can see [lintrunner](https://pypi.org/project/lintrunner/) for making sure the code follows our standard. Here's how to set up `lintrunner`:
75+
### lintrunner
76+
77+
We use [`lintrunner`](https://pypi.org/project/lintrunner/) to help make sure the
78+
code follows our standards. Set it up with:
1279

1380
```
1481
pip install lintrunner==0.11.0
1582
pip install lintrunner-adapters==0.11.0
1683
lintrunner init
1784
```
1885

86+
Then run `lintrunner` from the root of the repo to see its suggestions, or run
87+
`lintrunner -a` to automatically apply the suggestions.
88+
1989
### Python Style
2090

2191
ExecuTorch Python code follows the style used by the PyTorch core project.
@@ -109,9 +179,126 @@ must work with threading**
109179
`ArrayRef<T>`, or code that handles multiple `ScalarType` types), but for the
110180
most part avoid them if possible.
111181

182+
&nbsp;
183+
184+
## Testing
185+
186+
### Writing Tests
187+
To help keep code quality high, ExecuTorch uses a combination of unit tests and
188+
end-to-end (e2e) tests. If you add a new feature or fix a bug, please add tests
189+
to ensure that the feature/fix works properly and continues to work properly.
190+
191+
Most directories in the repo already contain test files. In many cases, you can
192+
add a test to an existing file, and the existing CI jobs will run it will run
193+
automatically. If you do this, please take a look at the CI job logs to ensure
194+
that it did actually run.
195+
196+
If it's not clear how to add a test for your PR, take a look at the blame for
197+
the code you're modifying and find an author who has more context. Ask them
198+
for their help in the PR comments.
199+
200+
TODO: Explain how to run tests locally without needing to push and wait for CI.
201+
202+
### Continuous Integration
203+
See https://hud.pytorch.org/hud/pytorch/executorch/main for the current state of
204+
the CI (continuous integration) jobs. If `main` is broken, consider rebasing
205+
your PR onto the `viable/strict` branch, which points to the most recent
206+
all-green commit.
207+
208+
&nbsp;
209+
210+
## Updating Documentation
211+
212+
### APIs
213+
ExecuTorch documents its APIs using inline code comments: doc strings for
214+
Python, and Doxygen comments for C++. When modifying or adding an API, be sure
215+
to modify or add documentation to the interfaces that you change. If the API
216+
doesn't have inline documentation yet, please help improve the code by adding
217+
documentation and describing the rest of the piece you modified.
218+
219+
Also search for references to the API you modified under `docs/source` to see if
220+
any docs need to be modified to reflect your changes; these are the files that
221+
are published on https://pytorch.org/executorch. If you are adding a new API,
222+
look for places in the docs that would benefit from talking about that API, or
223+
even create a new document for it. A job on the PR will give you a link to a
224+
website preview based on your changes.
225+
226+
&nbsp;
227+
228+
## Pull Requests
229+
This repo uses Github pull requests (PRs) to stage and review code before
230+
merging it into the `main` branch. See the [Github
231+
docs](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork)
232+
for basics.
233+
234+
1. Push your branch to your fork of `pytorch/executorch`. Most people do not
235+
have permission to push a branch directoy to the upstream repo.
236+
1. Create your PR
237+
- Use the `main` branch as the base.
238+
- Give the PR a clear and descriptive title. It will become the title of the
239+
merged commit, so it needs to be useful in the output of `git log`.
240+
- Bad title: "Fix a bug"
241+
- Good title: "Add XYZ method to ABC"
242+
- Give the PR a clear and thorough description. Don't just describe what the PR
243+
does: the diff will do that. Explain *why* you are making this change, in a
244+
way that will make sense to someone years from now.
245+
- Add the line `Test Plan:` (with that spelling, capitalization, and trailing
246+
colon character), followed by lines containing repeatable instructions for
247+
testing the PR.
248+
- If you added tests, this can be as simple as the command you used to run the
249+
tests.
250+
- If you tested the PR manually, include the steps and the outputs. Help a
251+
future editor understand how to test the code that you're modifying
252+
today.
253+
- See https://github.com/pytorch/executorch/pull/3612 for an example PR that
254+
follows this advice.
255+
1. Before asking for a review, ensure that all [CI (continuous integration)
256+
jobs](#continuous-integration) on your pull request succeed.
257+
- If the jobs on your PR are broken but you're not sure why, add a comment
258+
and proceed to finding a reviewer.
259+
- Not all users can trigger the CI jobs. If the jobs don't run on your PR,
260+
proceed to finding a reviewer.
261+
1. Find reviewers
262+
- If you have been working with a member of the ExecuTorch repo, add them
263+
as a reviewer (*not* an "assignee").
264+
- If not, look at the blame for the files that the PR modifies, and try
265+
picking one or two ExecuTorch repo members as reviewers (*not*
266+
"assignees").
267+
- If you are unsure, leave a comment on the PR and keep it unassigned with no
268+
reviewers. A member of the ExecuTorch repo will find someone to review it.
269+
1. Address and discuss comments left by reviewers
270+
- If the reviewers have requests or questions, follow up with them.
271+
- The goal of the reviewer is to ensure that the code in the `main` branch of
272+
the repo is consistent, maintainable, and of high quality.
273+
1. Once approved, your reviewer will import the PR into Meta's internal system
274+
and merge it from there.
275+
- If the PR is approved and not merged within a few business days, please
276+
comment on the PR to ask about its status.
277+
- Note that if the `main` [CI](#continuous-integration) jobs are broken, we
278+
will only merge PRs that fix the broken jobs until all critical jobs are
279+
fixed.
280+
281+
&nbsp;
282+
112283
## For Backend Delegate Authors
113284

114285
- Use [this](/docs/source/backend-delegates-integration.md) guide when
115286
integrating your delegate with ExecuTorch.
116287
- Refer to [this](/docs/source/backend-delegates-dependencies.md) set of
117288
guidelines when including a third-party depenency for your delegate.
289+
290+
&nbsp;
291+
292+
## License
293+
By contributing to ExecuTorch, you agree that your contributions will be
294+
licensed under the LICENSE file in the root directory of this source tree.
295+
296+
&nbsp;
297+
298+
## Contributor License Agreement ("CLA")
299+
In order to accept your pull request, we need you to submit a CLA. You only need
300+
to do this once to work on any of Meta's open source projects.
301+
302+
Complete your CLA here: <https://code.facebook.com/cla>
303+
304+
&nbsp;

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ repository](https://github.com/pytorch/executorch/issues) for bug reporting.
3131
We recommend using the latest release tag from the
3232
[Releases](https://github.com/pytorch/executorch/releases) page when developing.
3333

34+
## Contributing
35+
36+
See [CONTRIBUTING.md](CONTRIBUTING.md) for details about issues, PRs, code
37+
style, CI jobs, and other development topics.
38+
3439
## Directory Structure
3540

3641
```

docs/source/contributing.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Contributing to ExecuTorch
2+
3+
Thank you for your interest in contributing to ExecuTorch! We want to make
4+
it easy to contribute to this project.
5+
6+
The source is hosted on GitHub at
7+
[pytorch/executorch](https://github.com/pytorch/executorch).
8+
9+
See
10+
[CONTRIBUTING.md](https://github.com/pytorch/executorch/blob/main/CONTRIBUTING.md)
11+
for detailed information about contributing to ExecuTorch.

docs/source/index.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,14 @@ Topics in this section will help you get started with ExecuTorch.
205205
sdk-delegate-integration
206206
sdk-tutorial
207207

208+
.. toctree::
209+
:glob:
210+
:maxdepth: 1
211+
:caption: Contributing
212+
:hidden:
213+
214+
contributing
215+
208216
Tutorials and Examples
209217
~~~~~~~~~~~~~~~~~~~~~~
210218

0 commit comments

Comments
 (0)