Skip to content

Commit 5d07fd8

Browse files
authored
Merge branch 'master' into bugfix/3827_test_ddp_error
2 parents 7550420 + 96769a7 commit 5d07fd8

File tree

89 files changed

+2006
-575
lines changed

Some content is hidden

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

89 files changed

+2006
-575
lines changed

.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: 55 additions & 4 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.
@@ -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 --color=yes --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/workflows/ci_dockers.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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-conda.yml

Lines changed: 1 addition & 1 deletion
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

.github/workflows/code-formatting.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,21 @@ on: # Trigger the workflow on push or pull request, but only for the master bra
77
branches: [master, "release/*"]
88

99
jobs:
10+
imports-check-isort:
11+
name: Check valid import formatting with isort
12+
runs-on: ubuntu-20.04
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v2
16+
- name: Set up Python 3.8
17+
uses: actions/setup-python@v2
18+
with:
19+
python-version: 3.8
20+
- name: Install isort
21+
run: pip install isort==5.6.4
22+
- name: Run isort
23+
run: isort --settings-path=./pyproject.toml --check-only --diff .
24+
1025
code-black:
1126
name: Check code formatting with Black
1227
runs-on: ubuntu-20.04

.github/workflows/nightly.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,13 @@ jobs:
7070
tags: pytorchlightning/pytorch_lightning:base-xla-py${{ matrix.python_version }}-torch${{ matrix.xla_version }}
7171
timeout-minutes: 55
7272

73-
docker-cuda:
73+
docker-cuda-conda:
7474
runs-on: ubuntu-20.04
7575
strategy:
7676
fail-fast: false
7777
matrix:
7878
python_version: [3.6, 3.7, 3.8]
79-
pytorch_version: [1.3, 1.4, 1.5, 1.6, 1.7]
79+
pytorch_version: [1.3, 1.4, 1.5, 1.6, 1.7, 1.8]
8080
exclude:
8181
# excludes PT 1.3 as it is missing on pypi
8282
- python_version: 3.8
@@ -104,6 +104,8 @@ jobs:
104104
id: extend
105105
106106
- name: Publish CUDA to Docker Hub
107+
# ToDo: extend also building for Nightly from pip
108+
if: matrix.pytorch_version < 1.8
107109
# publish master/release
108110
uses: docker/build-push-action@v2
109111
with:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,4 @@ mlruns/
140140
pytorch\ lightning
141141
test-reports/
142142
wandb
143+
.forked/

.pre-commit-config.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,12 @@ repos:
2121
hooks:
2222
- id: trailing-whitespace
2323
- id: end-of-file-fixer
24+
25+
- repo: local
26+
hooks:
27+
- id: isort
28+
name: isort
29+
entry: python -m isort
30+
args: [--settings-path, ./pyproject.toml]
31+
language: system
32+
types: [python]

.run_local_tests.sh

Lines changed: 0 additions & 14 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 55 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
66

77

8-
## [unreleased] - YYYY-MM-DD
8+
## [unreleased.Features] - YYYY-MM-DD
99

1010
### Added
1111

@@ -27,21 +27,46 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
2727
- Added option to log momentum ([#4384](https://github.com/PyTorchLightning/pytorch-lightning/pull/4384))
2828

2929

30-
- Added `fsspec` to tuner ([#4458](https://github.com/PyTorchLightning/pytorch-lightning/pull/4458))
30+
- Added logging using `self.log` in train and evaluation for most callbacks and model hooks (
31+
[#4552](https://github.com/PyTorchLightning/pytorch-lightning/pull/4552),
32+
[#4495](https://github.com/PyTorchLightning/pytorch-lightning/pull/4495),
33+
[#4439](https://github.com/PyTorchLightning/pytorch-lightning/pull/4439))
3134

3235

33-
- Added metrics aggregation in Horovod and fixed early stopping ([#3775](https://github.com/PyTorchLightning/pytorch-lightning/pull/3775))
36+
### Changed
3437

38+
- Tuner algorithms will be skipped if `fast_dev_run=True` ([#3903](https://github.com/PyTorchLightning/pytorch-lightning/pull/3903))
3539

36-
- Added `manual_optimizer_step` which work with `AMP Native` and `accumulated_grad_batches` ([#4485](https://github.com/PyTorchLightning/pytorch-lightning/pull/4485))
3740

41+
- Metric states are no longer as default added to `state_dict` ([#4685](https://github.com/PyTorchLightning/pytorch-lightning/pull/))
42+
43+
44+
### Deprecated
45+
46+
47+
48+
### Removed
49+
50+
51+
52+
### Fixed
53+
54+
- Allowing decorate model init with saving `hparams` inside ([#4662](https://github.com/PyTorchLightning/pytorch-lightning/pull/4662))
55+
56+
57+
- Fixed `setup` callback hook to correctly pass the LightningModule through ([#4608](https://github.com/PyTorchLightning/pytorch-lightning/pull/4608))
58+
59+
60+
61+
## [unreleased.BugFix] - YYYY-MM-DD
62+
63+
### Added
3864

39-
- Added `persistent(mode)` method to metrics, to enable and disable metric states being added to `state_dict` ([#4482](https://github.com/PyTorchLightning/pytorch-lightning/pull/4482))
4065

4166

4267
### Changed
4368

44-
- Tuner algorithms will be skipped if `fast_dev_run=True` ([#3903](https://github.com/PyTorchLightning/pytorch-lightning/pull/3903))
69+
4570

4671
### Deprecated
4772

@@ -53,13 +78,35 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
5378

5479
### Fixed
5580

56-
- Fixed feature-lack in hpc load ([#4526](https://github.com/PyTorchLightning/pytorch-lightning/pull/4526))
5781

5882

59-
- Fixed metrics states being overridden in ddp mode ([#4482](https://github.com/PyTorchLightning/pytorch-lightning/pull/4482))
83+
## [1.0.6] - 2020-11-11
84+
85+
### Added
86+
87+
- Added metrics aggregation in Horovod and fixed early stopping ([#3775](https://github.com/PyTorchLightning/pytorch-lightning/pull/3775))
88+
- Added `manual_optimizer_step` which work with `AMP Native` and `accumulated_grad_batches` ([#4485](https://github.com/PyTorchLightning/pytorch-lightning/pull/4485))
89+
- Added `persistent(mode)` method to metrics, to enable and disable metric states being added to `state_dict` ([#4482](https://github.com/PyTorchLightning/pytorch-lightning/pull/4482))
90+
- Added congratulations at the end of our notebooks ([#4555](https://github.com/PyTorchLightning/pytorch-lightning/pull/4555))
6091

92+
### Changed
93+
94+
- Changed `fsspec` to tuner ([#4458](https://github.com/PyTorchLightning/pytorch-lightning/pull/4458))
95+
- Unify SLURM/TorchElastic under backend plugin ([#4578](https://github.com/PyTorchLightning/pytorch-lightning/pull/4578),
96+
[#4580](https://github.com/PyTorchLightning/pytorch-lightning/pull/4580),
97+
[#4581](https://github.com/PyTorchLightning/pytorch-lightning/pull/4581),
98+
[#4582](https://github.com/PyTorchLightning/pytorch-lightning/pull/4582),
99+
[#4583](https://github.com/PyTorchLightning/pytorch-lightning/pull/4583))
100+
101+
### Fixed
61102

103+
- Fixed feature-lack in `hpc_load` ([#4526](https://github.com/PyTorchLightning/pytorch-lightning/pull/4526))
104+
- Fixed metrics states being overridden in DDP mode ([#4482](https://github.com/PyTorchLightning/pytorch-lightning/pull/4482))
62105
- Fixed `lightning_getattr`, `lightning_hasattr` not finding the correct attributes in datamodule ([#4347](https://github.com/PyTorchLightning/pytorch-lightning/pull/4347))
106+
- Fixed automatic optimization AMP by `manual_optimization_step` ([#4485](https://github.com/PyTorchLightning/pytorch-lightning/pull/4485))
107+
- Replace `MisconfigurationException` with warning in `ModelCheckpoint` Callback ([#4560](https://github.com/PyTorchLightning/pytorch-lightning/pull/4560))
108+
- Fixed logged keys in mlflow logger ([#4412](https://github.com/PyTorchLightning/pytorch-lightning/pull/4412))
109+
- Fixed `is_picklable` by catching `AttributeError` ([#4508](https://github.com/PyTorchLightning/pytorch-lightning/pull/4508))
63110

64111

65112
## [1.0.5] - 2020-11-03

0 commit comments

Comments
 (0)