Skip to content

Commit f1c9693

Browse files
Bordajustusschockairiumyukw777awaelchli
authored
repair CI for Win (#2358)
* no cov * no cov * ReduceOp * group * reduce_op.sum * Update sklearns.py * formatting * horovod * Apply suggestions from code review * horovod * horovod * horovod * horovod * ci * print * ci * timeout * timeout * time * fix * distributed cpu * pipes * time * cpu * spawn * spawn * spawn * tp * separate * os * os * npm * Fix load_from_checkpoint() not working with URL on Windows * Update CHANGELOG * Update CHANGELOG.md Co-authored-by: Peter Yu <[email protected]> * Apply suggestions from code review * fix * fix meta tags creating empty lines * pyright * node * fix httpserver address * drop tutils.default_trainer_options * imports * Better fix for load_from_checkpoint() not working with absolute path on Windows (#2294) * Fix load_from_checkpoint() not working with URL on Windows * Update CHANGELOG * Update CHANGELOG.md Co-authored-by: Peter Yu <[email protected]> * Apply suggestions from code review Co-authored-by: Jirka Borovec <[email protected]> Co-authored-by: Peter Yu <[email protected]> * drop duplicate Co-authored-by: Justus Schock <[email protected]> Co-authored-by: airium <[email protected]> Co-authored-by: Peter Yu <[email protected]> Co-authored-by: Adrian Wälchli <[email protected]> Co-authored-by: AIRIUM <[email protected]>
1 parent a5f4578 commit f1c9693

Some content is hidden

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

50 files changed

+462
-436
lines changed

.github/workflows/ci-testing.yml

+10-8
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ jobs:
3333
os: macOS-10.15
3434

3535
# Timeout: https://stackoverflow.com/a/59076067/4521646
36-
timeout-minutes: 15
36+
timeout-minutes: 50
3737
steps:
3838
- uses: actions/checkout@v2
3939
- name: Set up Python ${{ matrix.python-version }}
40-
uses: actions/setup-python@v1
40+
uses: actions/setup-python@v2
4141
with:
4242
python-version: ${{ matrix.python-version }}
4343

@@ -122,8 +122,9 @@ jobs:
122122
run: |
123123
# tox --sitepackages
124124
# flake8 .
125-
coverage run --source pytorch_lightning -m py.test pytorch_lightning tests -v --junitxml=junit/test-results-${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.requires }}.xml
126-
coverage report
125+
# NOTE: run coverage on tests does not propagare faler status for Win, https://github.com/nedbat/coveragepy/issues/1003
126+
python -m pytest pytorch_lightning tests -v --junitxml=junit/test-results-${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.requires }}.xml
127+
# coverage report
127128
128129
- name: Upload pytest test results
129130
uses: actions/upload-artifact@master
@@ -139,14 +140,15 @@ jobs:
139140
python setup.py check --metadata --strict
140141
python setup.py sdist
141142
twine check dist/*
143+
142144
#- name: Try install package
143145
# if: ! startsWith(matrix.os, 'windows')
144146
# run: |
145147
# virtualenv vEnv ; source vEnv/bin/activate
146148
# pip install --editable . ; cd .. & python -c "import pytorch_lightning ; print(pytorch_lightning.__version__)"
147149
# deactivate ; rm -rf vEnv
148150

149-
- name: Statistics
150-
if: success()
151-
run: |
152-
coverage report
151+
#- name: Statistics
152+
# if: success()
153+
# run: |
154+
# coverage report

.github/workflows/code-formatting.yml

+49-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: "Check Formatting - Black"
1+
name: "Check Code Format"
22
on:
33
# Trigger the workflow on push or pull request,
44
# but only for the master branch
@@ -10,18 +10,63 @@ on:
1010
- master
1111

1212
jobs:
13-
check_code_formatting:
13+
code-black:
1414
name: Check code formatting with Black
1515
runs-on: ubuntu-latest
1616
steps:
1717
- name: Checkout
1818
uses: actions/checkout@v2
19-
- name: Set up Python
20-
uses: actions/setup-python@v1.1.1
19+
- name: Set up Python 3.8
20+
uses: actions/setup-python@v2
2121
with:
2222
python-version: 3.8
2323
- name: Install Black
2424
run: pip install black==19.10b0
2525
- name: Run Black
2626
run: echo "LGTM"
2727
# run black --skip-string-normalization --config=pyproject.toml --check . # TODO, uncomment
28+
29+
python-types:
30+
name: Python static type checking with Pyright
31+
runs-on: ubuntu-18.04
32+
33+
# Timeout: https://stackoverflow.com/a/59076067/4521646
34+
timeout-minutes: 15
35+
steps:
36+
- name: Checkout
37+
uses: actions/checkout@v2
38+
- uses: actions/setup-python@v2
39+
with:
40+
python-version: 3.7
41+
42+
# Note: This uses an internal pip API and may not always work
43+
# https://github.com/actions/cache/blob/master/examples.md#multiple-oss-in-a-workflow
44+
- name: Cache pip
45+
uses: actions/cache@v1
46+
with:
47+
path: ~/.cache/pip
48+
key: ${{ runner.os }}-pip-${{ hashFiles('requirements/base.txt') }}-${{ hashFiles('requirements/extra.txt') }}
49+
restore-keys: |
50+
${{ runner.os }}-pip-
51+
52+
- name: Install dependencies
53+
run: |
54+
# python -m pip install --upgrade --user pip
55+
pip install -r requirements/base.txt -U -f https://download.pytorch.org/whl/torch_stable.html -q
56+
HOROVOD_BUILD_ARCH_FLAGS="-mfma" pip install -r ./requirements/devel.txt -q
57+
# pip install tox coverage
58+
python --version ; pip --version ; pip list
59+
shell: bash
60+
61+
- name: Set up node
62+
uses: actions/setup-node@v1
63+
with:
64+
node-version: '12'
65+
66+
- name: Install pyright
67+
run: |
68+
npm install pyright
69+
70+
- name: Run type checking
71+
run: |
72+
$(npm bin)/pyright --project .pyrightconfig.json

.github/workflows/docker-builds.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ jobs:
1616
python_version: [3.6, 3.7, 3.8]
1717
pytorch_version: [1.3, 1.4, 1.5]
1818
steps:
19-
- uses: actions/checkout@v2
19+
- name: Checkout
20+
uses: actions/checkout@v2
21+
- uses: actions/setup-python@v2
22+
with:
23+
python-version: 3.7
2024

2125
- name: Publish Master to Docker
2226
# publish master

.github/workflows/pypi-release.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ jobs:
1919

2020
steps:
2121
- uses: actions/checkout@v2
22-
- name: Set up Python 3.7
23-
uses: actions/setup-python@v1
22+
- uses: actions/setup-python@v2
2423
with:
2524
python-version: 3.7
2625

.github/workflows/python-type-check.yml

-67
This file was deleted.

CHANGELOG.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
2424

2525
- Fixed an issue with forward hooks not being removed after model summary ([#2298](https://github.com/PyTorchLightning/pytorch-lightning/pull/2298))
2626

27+
- Fix for `load_from_checkpoint()` not working with absolute path on Windows ([#2294](https://github.com/PyTorchLightning/pytorch-lightning/pull/2294))
28+
2729
- Fixed an issue how _has_len handles `NotImplementedError` e.g. raised by `torchtext.data.Iterator` ([#2293](https://github.com/PyTorchLightning/pytorch-lightning/pull/2293)), ([#2307](https://github.com/PyTorchLightning/pytorch-lightning/pull/2307))
2830

2931
- Fixed `average_precision` metric ([#2319](https://github.com/PyTorchLightning/pytorch-lightning/pull/2319))
@@ -49,7 +51,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
4951
### Added
5052

5153
- Added `overfit_batches`, `limit_{val|test}_batches` flags (overfit now uses training set for all three) ([#2213](https://github.com/PyTorchLightning/pytorch-lightning/pull/2213))
52-
- Added metrics
54+
- Added metrics
5355
* Base classes ([#1326](https://github.com/PyTorchLightning/pytorch-lightning/pull/1326), [#1877](https://github.com/PyTorchLightning/pytorch-lightning/pull/1877))
5456
* Sklearn metrics classes ([#1327](https://github.com/PyTorchLightning/pytorch-lightning/pull/1327))
5557
* Native torch metrics ([#1488](https://github.com/PyTorchLightning/pytorch-lightning/pull/1488), [#2062](https://github.com/PyTorchLightning/pytorch-lightning/pull/2062))
@@ -59,7 +61,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
5961
- Allow dataloaders without sampler field present ([#1907](https://github.com/PyTorchLightning/pytorch-lightning/pull/1907))
6062
- Added option `save_last` to save the model at the end of every epoch in `ModelCheckpoint` [(#1908)](https://github.com/PyTorchLightning/pytorch-lightning/pull/1908)
6163
- Early stopping checks `on_validation_end` ([#1458](https://github.com/PyTorchLightning/pytorch-lightning/pull/1458))
62-
- Attribute `best_model_path` to `ModelCheckpoint` for storing and later retrieving the path to the best saved model file ([#1799](https://github.com/PyTorchLightning/pytorch-lightning/pull/1799))
64+
- Attribute `best_model_path` to `ModelCheckpoint` for storing and later retrieving the path to the best saved model file ([#1799](https://github.com/PyTorchLightning/pytorch-lightning/pull/1799))
6365
- Speed up single-core TPU training by loading data using `ParallelLoader` ([#2033](https://github.com/PyTorchLightning/pytorch-lightning/pull/2033))
6466
- Added a model hook `transfer_batch_to_device` that enables moving custom data structures to the target device ([1756](https://github.com/PyTorchLightning/pytorch-lightning/pull/1756))
6567
- Added [black](https://black.readthedocs.io/en/stable/) formatter for the code with code-checker on pull ([1610](https://github.com/PyTorchLightning/pytorch-lightning/pull/1610))
@@ -74,7 +76,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
7476

7577
- Allow user to select individual TPU core to train on ([#1729](https://github.com/PyTorchLightning/pytorch-lightning/pull/1729))
7678
- Removed non-finite values from loss in `LRFinder` ([#1862](https://github.com/PyTorchLightning/pytorch-lightning/pull/1862))
77-
- Allow passing model hyperparameters as complete kwarg list ([#1896](https://github.com/PyTorchLightning/pytorch-lightning/pull/1896))
79+
- Allow passing model hyperparameters as complete kwarg list ([#1896](https://github.com/PyTorchLightning/pytorch-lightning/pull/1896))
7880
- Renamed `ModelCheckpoint`'s attributes `best` to `best_model_score` and `kth_best_model` to `kth_best_model_path` ([#1799](https://github.com/PyTorchLightning/pytorch-lightning/pull/1799))
7981
- Re-Enable Logger's `ImportError`s ([#1938](https://github.com/PyTorchLightning/pytorch-lightning/pull/1938))
8082
- Changed the default value of the Trainer argument `weights_summary` from `full` to `top` ([#2029](https://github.com/PyTorchLightning/pytorch-lightning/pull/2029))
@@ -107,7 +109,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
107109

108110
- Run graceful training teardown on interpreter exit ([#1631](https://github.com/PyTorchLightning/pytorch-lightning/pull/1631))
109111
- Fixed user warning when apex was used together with learning rate schedulers ([#1873](https://github.com/PyTorchLightning/pytorch-lightning/pull/1873))
110-
- Fixed multiple calls of `EarlyStopping` callback ([#1863](https://github.com/PyTorchLightning/pytorch-lightning/pull/1863))
112+
- Fixed multiple calls of `EarlyStopping` callback ([#1863](https://github.com/PyTorchLightning/pytorch-lightning/pull/1863))
111113
- Fixed an issue with `Trainer.from_argparse_args` when passing in unknown Trainer args ([#1932](https://github.com/PyTorchLightning/pytorch-lightning/pull/1932))
112114
- Fixed bug related to logger not being reset correctly for model after tuner algorithms ([#1933](https://github.com/PyTorchLightning/pytorch-lightning/pull/1933))
113115
- Fixed root node resolution for SLURM cluster with dash in host name ([#1954](https://github.com/PyTorchLightning/pytorch-lightning/pull/1954))

benchmarks/test_parity.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import pytest
55
import torch
66

7-
import tests.base.utils as tutils
7+
import tests.base.develop_utils as tutils
88
from pytorch_lightning import Trainer, seed_everything
99
from tests.base.models import ParityModuleRNN, ParityModuleMNIST
1010

pl_examples/basic_examples/gpu_template.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ def main(hparams):
6161
'--distributed_backend',
6262
type=str,
6363
default='dp',
64-
help='supports four options dp, ddp, ddp2, ddp_spawn'
64+
help='supports four options dp, ddp, ddp2, ddp_spawn, ...',
65+
choices=['dp', 'ddp', 'ddp2', 'ddp_spawn', 'ddp_cpu'],
6566
)
6667
parent_parser.add_argument(
6768
'--use_16bit',

pytorch_lightning/core/saving.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ def load_hparams_from_tags_csv(tags_csv: str) -> Dict[str, Any]:
279279
"""Load hparams from a file.
280280
281281
>>> hparams = Namespace(batch_size=32, learning_rate=0.001, data_root='./any/path/here')
282-
>>> path_csv = './testing-hparams.csv'
282+
>>> path_csv = os.path.join('.', 'testing-hparams.csv')
283283
>>> save_hparams_to_tags_csv(path_csv, hparams)
284284
>>> hparams_new = load_hparams_from_tags_csv(path_csv)
285285
>>> vars(hparams) == hparams_new
@@ -304,7 +304,7 @@ def save_hparams_to_tags_csv(tags_csv: str, hparams: Union[dict, Namespace]) ->
304304
if isinstance(hparams, Namespace):
305305
hparams = vars(hparams)
306306

307-
with open(tags_csv, 'w') as fp:
307+
with open(tags_csv, 'w', newline='') as fp:
308308
fieldnames = ['key', 'value']
309309
writer = csv.DictWriter(fp, fieldnames=fieldnames)
310310
writer.writerow({'key': 'key', 'value': 'value'})

pytorch_lightning/metrics/converters.py

+14-6
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,16 @@
1010
import numpy as np
1111
import torch
1212
from torch.utils.data._utils.collate import np_str_obj_array_pattern
13-
1413
from pytorch_lightning.utilities.apply_func import apply_to_collection
14+
from pytorch_lightning.utilities import rank_zero_warn
15+
16+
try:
17+
from torch.distributed import ReduceOp
18+
except ImportError:
19+
class ReduceOp:
20+
SUM = None
21+
22+
rank_zero_warn('Unsupported `ReduceOp` for distributed computing.')
1523

1624

1725
def _apply_to_inputs(func_to_apply: Callable, *dec_args, **dec_kwargs) -> Callable:
@@ -217,7 +225,7 @@ def _tensor_collection_metric_conversion(func_to_decorate: Callable) -> Callable
217225

218226
def _sync_ddp_if_available(result: Union[torch.Tensor],
219227
group: Optional[Any] = None,
220-
reduce_op: Optional[torch.distributed.ReduceOp] = None,
228+
reduce_op: Optional[ReduceOp] = None,
221229
) -> torch.Tensor:
222230
"""
223231
Function to reduce the tensors from several ddp processes to one master process
@@ -247,7 +255,7 @@ def _sync_ddp_if_available(result: Union[torch.Tensor],
247255

248256

249257
def sync_ddp(group: Optional[Any] = None,
250-
reduce_op: Optional[torch.distributed.ReduceOp] = None) -> Callable:
258+
reduce_op: Optional[ReduceOp] = None) -> Callable:
251259
"""
252260
This decorator syncs a functions outputs across different processes for DDP.
253261
@@ -269,7 +277,7 @@ def decorator_fn(func_to_decorate):
269277

270278

271279
def numpy_metric(group: Optional[Any] = None,
272-
reduce_op: Optional[torch.distributed.ReduceOp] = None) -> Callable:
280+
reduce_op: Optional[ReduceOp] = None) -> Callable:
273281
"""
274282
This decorator shall be used on all function metrics working on numpy arrays.
275283
It handles the argument conversion and DDP reduction for metrics working on numpy.
@@ -292,7 +300,7 @@ def decorator_fn(func_to_decorate):
292300

293301

294302
def tensor_metric(group: Optional[Any] = None,
295-
reduce_op: Optional[torch.distributed.ReduceOp] = None) -> Callable:
303+
reduce_op: Optional[ReduceOp] = None) -> Callable:
296304
"""
297305
This decorator shall be used on all function metrics working on tensors.
298306
It handles the argument conversion and DDP reduction for metrics working on tensors.
@@ -314,7 +322,7 @@ def decorator_fn(func_to_decorate):
314322

315323

316324
def tensor_collection_metric(group: Optional[Any] = None,
317-
reduce_op: Optional[torch.distributed.ReduceOp] = None) -> Callable:
325+
reduce_op: Optional[ReduceOp] = None) -> Callable:
318326
"""
319327
This decorator shall be used on all function metrics working on tensors and returning collections
320328
that cannot be converted to tensors.

0 commit comments

Comments
 (0)