Skip to content

Commit e45fde5

Browse files
Bordarohitgr7ananthsubs-rog
committed
add contrib questions (#5691)
* add contrib questions * Apply suggestions from code review Co-authored-by: Rohit Gupta <[email protected]> * Apply suggestions from code review Co-authored-by: ananthsub <[email protected]> Co-authored-by: Roger Shieh <[email protected]> Co-authored-by: Rohit Gupta <[email protected]> Co-authored-by: ananthsub <[email protected]> Co-authored-by: Roger Shieh <[email protected]>
1 parent 78918a9 commit e45fde5

File tree

1 file changed

+79
-50
lines changed

1 file changed

+79
-50
lines changed

.github/CONTRIBUTING.md

+79-50
Original file line numberDiff line numberDiff line change
@@ -223,60 +223,44 @@ We welcome any useful contribution! For your convenience here's a recommended wo
223223

224224
### Question & Answer
225225

226-
1. **How can I help/contribute?**
226+
#### How can I help/contribute?
227227

228-
All help is extremely welcome - reporting bugs, fixing documentation, adding test cases, solving issues and preparing bug fixes. To solve some issues you can start with label [good first issue](https://github.com/PyTorchLightning/pytorch-lightning/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22) or chose something close to your domain with label [help wanted](https://github.com/PyTorchLightning/pytorch-lightning/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22). Before you start to implement anything check that the issue description that it is clear and self-assign the task to you (if it is not possible, just comment that you take it and we assign it to you...).
228+
All types of contributions are welcome - reporting bugs, fixing documentation, adding test cases, solving issues, and preparing bug fixes.
229+
To get started with code contributions, look for issues marked with the label [good first issue](https://github.com/PyTorchLightning/pytorch-lightning/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22) or chose something close to your domain with the label [help wanted](https://github.com/PyTorchLightning/pytorch-lightning/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22). Before coding, make sure that the issue description is clear and comment on the issue so that we can assign it to you (or simply self-assign if you can).
229230

230-
2. **Is there a recommendation for branch names?**
231+
#### Is there a recommendation for branch names?
231232

232-
We do not rely on the name convention so far you are working with your own fork. Anyway it would be nice to follow this convention `<type>/<issue-id>_<short-name>` where the types are: `bugfix`, `feature`, `docs`, `tests`, ...
233+
We recommend you follow this convention `<type>/<issue-id>_<short-name>` where the types are: `bugfix`, `feature`, `docs`, or `tests` (but if you are using your own fork that's optional).
233234

234-
3. **How to rebase my PR?**
235+
#### How to rebase my PR?
235236

236-
We recommend creating a PR in separate branch other than `master`, especially if you plan submitting several changes and do not want to wait until the first one is resolved (we can work on them in parallel).
237+
We recommend creating a PR in a separate branch other than `master`, especially if you plan to submit several changes and do not want to wait until the first one is resolved (we can work on them in parallel).
237238

238-
First, make sure you have set [upstream](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/configuring-a-remote-for-a-fork) by running:
239+
First, make sure you have set [upstream](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/configuring-a-remote-for-a-fork) by running:
239240

240-
```bash
241-
git remote add upstream https://github.com/PyTorchLightning/pytorch-lightning.git
242-
```
243-
244-
You'll know its set up right if you run `git remote -v` and see something similar to this:
245-
246-
```bash
247-
origin https://github.com/{YOUR_USERNAME}/pytorch-lightning.git (fetch)
248-
origin https://github.com/{YOUR_USERNAME}/pytorch-lightning.git (push)
249-
upstream https://github.com/PyTorchLightning/pytorch-lightning.git (fetch)
250-
upstream https://github.com/PyTorchLightning/pytorch-lightning.git (push)
251-
```
252-
253-
Now you can update your master with upstream's master by running:
254-
255-
```bash
256-
git fetch --all --prune
257-
git checkout master
258-
git merge upstream/master
259-
```
241+
```bash
242+
git remote add upstream https://github.com/PyTorchLightning/pytorch-lightning.git
243+
```
260244

261-
Finally, checkout your feature branch and rebase it with master before pushing up your feature branch:
245+
You'll know its set up right if you run `git remote -v` and see something similar to this:
262246

263-
```bash
264-
git checkout my-PR-branch
265-
git rebase master
266-
# follow git instructions to resolve conflicts
267-
git push -f
268-
```
247+
```bash
248+
origin https://github.com/{YOUR_USERNAME}/pytorch-lightning.git (fetch)
249+
origin https://github.com/{YOUR_USERNAME}/pytorch-lightning.git (push)
250+
upstream https://github.com/PyTorchLightning/pytorch-lightning.git (fetch)
251+
upstream https://github.com/PyTorchLightning/pytorch-lightning.git (push)
252+
```
269253

270-
Eventually, you can perform the rebasing directly from upstream after setting it up:
254+
Checkout your feature branch and rebase it with upstream's master before pushing up your feature branch:
271255

272-
```bash
273-
git fetch --all --prune
274-
git rebase upstream/master
275-
# follow git instructions to resolve conflicts
276-
git push -f
277-
```
256+
```bash
257+
git fetch --all --prune
258+
git rebase upstream/master
259+
# follow git instructions to resolve conflicts
260+
git push -f
261+
```
278262

279-
4. **How to add new tests**
263+
#### How to add new tests?**
280264

281265
We are using [pytest](https://docs.pytest.org/en/stable/) in Pytorch Lightning.
282266

@@ -293,19 +277,16 @@ Here is the process to create a new test
293277

294278
```python
295279
# TEST SHOULD BE IN YOUR FILE: tests/..../...py
280+
# TEST CODE TEMPLATE
296281

297-
# RUN OUR TEST WITH: pytest tests/..../...py::test_explain_what_is_being_tested --verbose --capture=no
298-
299-
# TEST CODE TEMPLATE
300-
301-
# pytest decorator
282+
# [OPTIONAL] pytest decorator
302283
# @pytest.mark.skipif(not torch.cuda.is_available(), reason="test requires GPU machine")
303284
def test_explain_what_is_being_tested(tmpdir):
304285
"""
305286
Test description about text reason to be
306287
"""
307288

308-
# os.environ["PL_DEV_DEBUG"] = '1' optional. When activated, you can use internal trainer.dev_debugger
289+
# os.environ["PL_DEV_DEBUG"] = '1' # [OPTIONAL] When activated, you can use internal trainer.dev_debugger
309290

310291
class ExtendedModel(BoringModel):
311292
...
@@ -320,12 +301,60 @@ def test_explain_what_is_being_tested(tmpdir):
320301
...
321302
)
322303
trainer.fit(model)
323-
result = trainer.test()
304+
trainer.test() # [OPTIONAL]
324305

325306
# assert the behaviour is correct.
326307
assert ...
327-
assert ...
328308
```
309+
run our/your test with
310+
```bash
311+
python -m pytest tests/..../...py::test_explain_what_is_being_tested --verbose --capture=no
312+
```
313+
314+
#### How to contribute bugfixes/features?
315+
316+
Currently we have separate streams/branches for bugfixes/features and release from the default branch (`master`).
317+
Bugfixes should land in this `master` branch and features should land in `release/X.y-dev`.
318+
This means that when starting your contribution and creating a branch according to question 2) you should start this new branch from master or future release dev branch.
319+
Later in PR creation also pay attention to properly set the target branch, usually the starting (base) and target branch are the same.
320+
321+
_Note, that this flow may change after the 1.2 release as we will adjust releasing strategy._
322+
323+
#### How to fix PR with mixed base and target branches?
324+
325+
Sometimes you start your PR as a bug-fix but it turns out to be more of a feature (or the other way around).
326+
Do not panic, the solution is very straightforward and quite simple.
327+
All you need to do are these two steps in arbitrary order:
328+
- Ask someone from Core to change the base/target branch to the correct one
329+
- Rebase or cherry-pick your commits onto the correct base branch...
330+
331+
Let's show how to deal with the git...
332+
the sample case is moving a PR from `master` to `release/1.2-dev` assuming my branch name is `my-branch`
333+
and the last true master commit is `ccc111` and your first commit is `mmm222`.
334+
* **Cherry-picking** way
335+
```bash
336+
git checkout my-branch
337+
# create a local backup of your branch
338+
git checkout -b my-branch-backup
339+
# reset your branch to the correct base
340+
git reset release/1.2-dev --hard
341+
# ACTION: this step is much easier to do with IDE
342+
# so open one and cherry-pick your last commits from `my-branch-backup`
343+
# resolve all eventual conflict as the new base may contain different code
344+
# when all done, push back to the open PR
345+
git push -f
346+
```
347+
* **Rebasing way**, see more about [rebase onto usage](https://womanonrails.com/git-rebase-onto)
348+
```bash
349+
git checkout my-branch
350+
# rebase your commits on the correct branch
351+
git rebase --onto release/1.2-dev ccc111
352+
# if there is no collision you shall see just success
353+
# eventually you would need to resolve collision and in such case follow the instruction in terminal
354+
# when all done, push back to the open PR
355+
git push -f
356+
```
357+
329358

330359
### Bonus Workflow Tip
331360

0 commit comments

Comments
 (0)