Skip to content

Commit 2fd2d41

Browse files
committed
Merge branch 'master' into bugfix/3827_test_ddp_error
2 parents 096f457 + ef762a0 commit 2fd2d41

File tree

238 files changed

+15523
-9231
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

238 files changed

+15523
-9231
lines changed

.circleci/config.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ references:
3636
command: |
3737
gcloud --quiet auth configure-docker
3838
#cd dockers/tpu-tests
39-
docker build --tag "$GCR_IMAGE_PATH:$CIRCLE_WORKFLOW_JOB_ID" -f ./dockers/tpu-tests/Dockerfile --build-arg "PYTHON_VERSION=$PYTHON_VER" .
39+
docker build --tag "$GCR_IMAGE_PATH:$CIRCLE_WORKFLOW_JOB_ID" -f ./dockers/tpu-tests/Dockerfile --build-arg "PYTHON_VERSION=$PYTHON_VER" --build-arg "PYTORCH_VERSION=$XLA_VER" .
4040
docker push "$GCR_IMAGE_PATH:$CIRCLE_WORKFLOW_JOB_ID"
4141
4242
deploy_cluster: &deploy_cluster
@@ -45,6 +45,7 @@ references:
4545
command: |
4646
go get github.com/google/go-jsonnet/cmd/jsonnet
4747
export PATH=$PATH:$HOME/go/bin
48+
python -c "fname = 'dockers/tpu-tests/tpu_test_cases.jsonnet' ; fff = open(fname).read().replace('pytorch-VERSION', 'pytorch-$XLA_VER') ; open(fname, 'w').write(fff)"
4849
job_name=$(jsonnet -J ml-testing-accelerators/ dockers/tpu-tests/tpu_test_cases.jsonnet --ext-str image=$GCR_IMAGE_PATH --ext-str image-tag=$CIRCLE_WORKFLOW_JOB_ID | kubectl create -f -)
4950
job_name=${job_name#job.batch/}
5051
job_name=${job_name% created}
@@ -102,6 +103,7 @@ jobs:
102103
- image: circleci/python:3.7
103104
environment:
104105
- PYTHON_VER: << parameters.python >>
106+
- XLA_VER: 1.7
105107
- MAX_CHECKS: 240
106108
- CHECK_SPEEP: 5
107109
steps:

.drone.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,12 @@ steps:
3232
- pip --version
3333
- nvidia-smi
3434
- pip install -r ./requirements/devel.txt --upgrade-strategy only-if-needed -v --no-cache-dir
35+
# when Image has defined CUDa version we can switch to this package spec "nvidia-dali-cuda${CUDA_VERSION%%.*}0"
36+
# todo: temprarl fix till https://github.com/PyTorchLightning/pytorch-lightning/pull/4922 is resolved
37+
- pip install --extra-index-url https://developer.download.nvidia.com/compute/redist "nvidia-dali-cuda100<0.27" --upgrade-strategy only-if-needed
3538
- pip list
36-
- coverage run --source pytorch_lightning -m pytest pytorch_lightning tests -v --color=yes --durations=25 # --flake8
37-
- python -m pytest benchmarks pl_examples -v --color=yes --maxfail=2 --durations=0 # --flake8
39+
- coverage run --source pytorch_lightning -m pytest pytorch_lightning tests -v --durations=25 # --flake8
40+
- python -m pytest benchmarks pl_examples -v --maxfail=2 --durations=0 # --flake8
3841
#- cd docs; make doctest; make coverage
3942
- coverage report
4043
# see: https://docs.codecov.io/docs/merging-reports

.github/CODEOWNERS

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,16 @@
1212
/tests/metrics/* @teddykoker @ananyahjha93 @justusschock
1313
/docs/source/metrics.rst @teddykoker @ananyahjha93 @justusschock
1414

15+
# API
16+
/pytorch_lightning/callbacks/base.py @williamfalcon
17+
/pytorch_lightning/core/datamodule.py @williamfalcon
18+
/pytorch_lightning/trainer/trainer.py @williamfalcon
19+
/pytorch_lightning/core/hooks.py @williamfalcon
20+
/pytorch_lightning/core/lightning.py @williamfalcon
1521

22+
23+
# accelerators
24+
/pytorch_lightning/accelerators/* @williamfalcon
25+
26+
# owners
27+
/pytorch_lightning/.github/CODEOWNERS @williamfalcon

.github/CONTRIBUTING.md

Lines changed: 56 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ In case you adding new dependencies, make sure that they are compatible with the
112112

113113
### Coding Style
114114

115-
1. Use f-strings for output formation (except logging when we stay with lazy `logging.info("Hello %s!`, name);
116-
2. Black code formatter is used using `pre-commit` hook.
115+
1. Use f-strings for output formation (except logging when we stay with lazy `logging.info("Hello %s!", name)`.
116+
2. Black code formatter is used using a `pre-commit` hook.
117117

118118
### Documentation
119119

@@ -182,10 +182,10 @@ python -m pip install ".[dev, examples]"
182182
python -m pip install pre-commit
183183
```
184184

185-
You can run the full test-case in your terminal via this bash script:
185+
You can run the full test-case in your terminal via this make script:
186186

187187
```bash
188-
bash .run_local_tests.sh
188+
make test
189189
```
190190

191191
Note: if your computer does not have multi-GPU nor TPU these tests are skipped.
@@ -196,7 +196,7 @@ This is useful if you do not test against all required dependency versions.
196196
**Docker:** Another option is utilize the [pytorch lightning cuda base docker image](https://hub.docker.com/repository/docker/pytorchlightning/pytorch_lightning/tags?page=1&name=cuda). You can then run:
197197

198198
```bash
199-
python -m pytest pytorch_lightning tests pl_examples -v --color=yes --flake8
199+
python -m pytest pytorch_lightning tests pl_examples -v --flake8
200200
```
201201

202202
### Pull Request
@@ -276,6 +276,57 @@ We welcome any useful contribution! For your convenience here's a recommended wo
276276
git push -f
277277
```
278278

279+
4. **How to add new tests**
280+
281+
We are using [pytest](https://docs.pytest.org/en/stable/) in Pytorch Lightning.
282+
283+
Here are tutorials:
284+
* (recommended) [Visual Testing with pytest](https://www.youtube.com/playlist?list=PLCTHcU1KoD99Rim2tzg-IhYY2iu9FFvNo) from JetBrains on YouTube
285+
* [Effective Python Testing With Pytest](https://realpython.com/pytest-python-testing/) article on realpython.com
286+
287+
Here is the process to create a new test
288+
289+
* 0. Optional: Follow tutorials !
290+
* 1. Find a file in tests/ which match what you want to test. If none, create one.
291+
* 2. Use this template to get started !
292+
* 3. Use `BoringModel and derivates to test out your code`.
293+
294+
```python
295+
# TEST SHOULD BE IN YOUR FILE: tests/..../...py
296+
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
302+
# @pytest.mark.skipif(not torch.cuda.is_available(), reason="test requires GPU machine")
303+
def test_explain_what_is_being_tested(tmpdir):
304+
"""
305+
Test description about text reason to be
306+
"""
307+
308+
# os.environ["PL_DEV_DEBUG"] = '1' optional. When activated, you can use internal trainer.dev_debugger
309+
310+
class ExtendedModel(BoringModel):
311+
...
312+
313+
model = ExtendedModel()
314+
315+
# BoringModel is a functional model. You might want to set methods to None to test your behaviour
316+
# Example: model.training_step_end = None
317+
318+
trainer = Trainer(
319+
default_root_dir=tmpdir, # will save everything within a tmpdir generated for this test
320+
...
321+
)
322+
trainer.fit(model)
323+
result = trainer.test()
324+
325+
# assert the behaviour is correct.
326+
assert ...
327+
assert ...
328+
```
329+
279330
### Bonus Workflow Tip
280331

281332
If you don't want to remember all the commands above every time you want to push some code/setup a Lightning Dev environment on a new VM, you can set up bash aliases for some common commands. You can add these to one of your `~/.bashrc`, `~/.zshrc`, or `~/.bash_aliases` files.

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
Please include a summary of the change and which issue is fixed.
55
Please also include relevant motivation and context.
66
List any dependencies that are required for this change.
7+
8+
If we didn't discuss your PR in Github issues there's a high chance it will not be merged.
79
-->
810

911
Fixes # (issue)
@@ -17,13 +19,17 @@ Fixes # (issue)
1719
- [ ] Did you verify new and existing tests pass locally with your changes?
1820
- [ ] If you made a notable change (that affects users), did you update the [CHANGELOG](https://github.com/PyTorchLightning/pytorch-lightning/blob/master/CHANGELOG.md)?
1921

20-
<!-- For CHANGELOG separate each item in unreleased section by a blank line to reduce collisions -->
22+
<!-- For CHANGELOG separate each item in the unreleased section by a blank line to reduce collisions -->
2123

2224
## PR review
23-
- [ ] Is this pull request ready for review? (if not, please submit in draft mode)
25+
Anyone in the community is free to review the PR once the tests have passed.
26+
Before you start reviewing make sure you have read [Review guidelines](https://github.com/PyTorchLightning/pytorch-lightning/wiki/Review-guidelines). In short, see the following bullet-list:
2427

25-
Anyone in the community is free to review the PR once the tests have passed.
26-
If we didn't discuss your PR in Github issues there's a high chance it will not be merged.
28+
- [ ] Is this pull request ready for review? (if not, please submit in draft mode)
29+
- [ ] Check that all items from **Before submitting** are resolved
30+
- [ ] Make sure the title is self-explanatory and the description concisely explains the PR
31+
- [ ] Add labels and milestones (and optionally projects) to the PR so it can be classified; _Bugfixes should be including in bug-fix release milestones (m.f.X) and features should be included in (m.X.b) releases._
32+
2733

2834
## Did you have fun?
2935
Make sure you had fun coding 🙃

.github/stale.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,10 @@ pulls:
4040
staleLabel: "won't fix"
4141
# Limit the number of actions per hour, from 1-30. Default is 30
4242
limitPerRun: 10
43+
44+
# Set to true to ignore issues in a project (defaults to false)
45+
exemptProjects: true
46+
# Set to true to ignore issues in a milestone (defaults to false)
47+
exemptMilestones: true
48+
# Set to true to ignore issues with an assignee (defaults to false)
49+
exemptAssignees: true

.github/workflows/ci_dockers.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
fail-fast: false
4141
matrix:
4242
python_version: [3.7]
43-
xla_version: [1.6, "nightly"]
43+
xla_version: [1.6, 1.7, "nightly"]
4444
steps:
4545
- name: Checkout
4646
uses: actions/checkout@v2
@@ -66,6 +66,9 @@ jobs:
6666
fail-fast: false
6767
matrix:
6868
include:
69+
# todo: see notes in Dockerfile
70+
#- python_version: 3.7
71+
# pytorch_version: 1.8
6972
- python_version: 3.8
7073
pytorch_version: 1.7
7174
- python_version: 3.7
@@ -110,9 +113,8 @@ jobs:
110113
pytorch_version: 1.4
111114
- python_version: 3.7
112115
pytorch_version: 1.7
113-
# TODO
114-
# - python_version: 3.7
115-
# pytorch_version: 1.8
116+
- python_version: 3.7
117+
pytorch_version: 1.8
116118
steps:
117119
- name: Checkout
118120
uses: actions/checkout@v2

.github/workflows/ci_test-base.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ jobs:
6969
- name: Test Package [only]
7070
run: |
7171
# NOTE: run coverage on tests does not propagare faler status for Win, https://github.com/nedbat/coveragepy/issues/1003
72-
coverage run --source pytorch_lightning -m pytest pytorch_lightning -v --color=yes --junitxml=junit/test-results-${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.requires }}.xml
72+
coverage run --source pytorch_lightning -m pytest pytorch_lightning -v --junitxml=junit/test-results-${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.requires }}.xml
7373
7474
- name: Upload pytest test results
7575
uses: actions/upload-artifact@v2

.github/workflows/ci_test-conda.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
matrix:
1717
# os: [ubuntu-20.04]
1818
python-version: [3.7]
19-
pytorch-version: [1.3, 1.4, 1.5, 1.6, 1.7]
19+
pytorch-version: [1.3, 1.4, 1.5, 1.6, 1.7, 1.8]
2020

2121
# Timeout: https://stackoverflow.com/a/59076067/4521646
2222
timeout-minutes: 35
@@ -41,7 +41,7 @@ jobs:
4141
- name: Tests
4242
run: |
4343
# NOTE: run coverage on tests does not propagare faler status for Win, https://github.com/nedbat/coveragepy/issues/1003
44-
python -m pytest pytorch_lightning tests -v --color=yes --durations=0 --junitxml=junit/test-results-${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.requires }}.xml
44+
python -m pytest pytorch_lightning tests -v --durations=50 --junitxml=junit/test-results-${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.requires }}.xml
4545
# coverage report
4646
shell: bash -l {0}
4747

.github/workflows/ci_test-full.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ jobs:
6464
python -c "fname = 'requirements/extra.txt' ; req = open(fname).read().replace('>=', '==') ; open(fname, 'w').write(req)"
6565
python -c "fname = 'requirements/test.txt' ; req = open(fname).read().replace('>=', '==') ; open(fname, 'w').write(req)"
6666
python -c "fname = 'requirements/examples.txt' ; req = open(fname).read().replace('>=', '==') ; open(fname, 'w').write(req)"
67+
# remove Fairscale from requirements
68+
python -c "fname = 'requirements/extra.txt' ; lines = [line for line in open(fname).readlines() if 'fairscale' not in line] ; open(fname, 'w').writelines(lines)"
6769
6870
# Note: This uses an internal pip API and may not always work
6971
# https://github.com/actions/cache/blob/master/examples.md#multiple-oss-in-a-workflow
@@ -119,7 +121,7 @@ jobs:
119121
- name: Tests
120122
run: |
121123
# NOTE: do not include coverage report here, see: https://github.com/nedbat/coveragepy/issues/1003
122-
coverage run --source pytorch_lightning -m pytest pytorch_lightning tests pl_examples -v --color=yes --durations=0 --junitxml=junit/test-results-${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.requires }}.xml
124+
coverage run --source pytorch_lightning -m pytest pytorch_lightning tests pl_examples -v --durations=50 --junitxml=junit/test-results-${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.requires }}.xml
123125
124126
- name: Upload pytest test results
125127
uses: actions/upload-artifact@v2

0 commit comments

Comments
 (0)