Skip to content

Commit f15dca2

Browse files
committed
flake8 ++
1 parent 68ce6fd commit f15dca2

File tree

21 files changed

+59
-66
lines changed

21 files changed

+59
-66
lines changed

CHANGELOG.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,6 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
4040
- Support number for logging with `sync_dist=True` ([#5080](https://github.com/PyTorchLightning/pytorch-lightning/pull/5080)
4141
- Added offset logging step when resuming for Wandb logger ([#5050](https://github.com/PyTorchLightning/pytorch-lightning/pull/5050)
4242

43-
### Changed
44-
45-
46-
### Deprecated
47-
48-
4943
### Removed
5044

5145
- `enable_pl_optimizer=False` by default to temporarily fix AMP issues ([#5163](https://github.com/PyTorchLightning/pytorch-lightning/pull/5163)

pl_examples/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
from pytorch_lightning.utilities import _module_available
44

5-
EXAMPLES_ROOT = os.path.dirname(__file__)
6-
PACKAGE_ROOT = os.path.dirname(EXAMPLES_ROOT)
7-
DATASETS_PATH = os.path.join(PACKAGE_ROOT, 'Datasets')
5+
_EXAMPLES_ROOT = os.path.dirname(__file__)
6+
_PACKAGE_ROOT = os.path.dirname(_EXAMPLES_ROOT)
7+
_DATASETS_PATH = os.path.join(_PACKAGE_ROOT, 'Datasets')
88

9-
TORCHVISION_AVAILABLE = _module_available("torchvision")
10-
DALI_AVAILABLE = _module_available("nvidia.dali")
9+
_TORCHVISION_AVAILABLE = _module_available("torchvision")
10+
_DALI_AVAILABLE = _module_available("nvidia.dali")
1111

1212

1313
LIGHTNING_LOGO = """

pl_examples/basic_examples/autoencoder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
from torch.utils.data import random_split
2222

2323
import pytorch_lightning as pl
24-
from pl_examples import TORCHVISION_AVAILABLE, cli_lightning_logo
24+
from pl_examples import _TORCHVISION_AVAILABLE, cli_lightning_logo
2525

26-
if TORCHVISION_AVAILABLE:
26+
if _TORCHVISION_AVAILABLE:
2727
from torchvision.datasets.mnist import MNIST
2828
from torchvision import transforms
2929
else:

pl_examples/basic_examples/backbone_image_classifier.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
from torch.utils.data import DataLoader, random_split
2020

2121
import pytorch_lightning as pl
22-
from pl_examples import DATASETS_PATH, TORCHVISION_AVAILABLE, cli_lightning_logo
22+
from pl_examples import _DATASETS_PATH, _TORCHVISION_AVAILABLE, cli_lightning_logo
2323

24-
if TORCHVISION_AVAILABLE:
24+
if _TORCHVISION_AVAILABLE:
2525
from torchvision.datasets.mnist import MNIST
2626
from torchvision import transforms
2727
else:
@@ -111,8 +111,8 @@ def cli_main():
111111
# ------------
112112
# data
113113
# ------------
114-
dataset = MNIST(DATASETS_PATH, train=True, download=True, transform=transforms.ToTensor())
115-
mnist_test = MNIST(DATASETS_PATH, train=False, download=True, transform=transforms.ToTensor())
114+
dataset = MNIST(_DATASETS_PATH, train=True, download=True, transform=transforms.ToTensor())
115+
mnist_test = MNIST(_DATASETS_PATH, train=False, download=True, transform=transforms.ToTensor())
116116
mnist_train, mnist_val = random_split(dataset, [55000, 5000])
117117

118118
train_loader = DataLoader(mnist_train, batch_size=args.batch_size)

pl_examples/basic_examples/dali_image_classifier.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@
2323
from torch.utils.data import random_split
2424

2525
import pytorch_lightning as pl
26-
from pl_examples import TORCHVISION_AVAILABLE, DALI_AVAILABLE, cli_lightning_logo
26+
from pl_examples import _TORCHVISION_AVAILABLE, _DALI_AVAILABLE, cli_lightning_logo
2727

28-
if TORCHVISION_AVAILABLE:
28+
if _TORCHVISION_AVAILABLE:
2929
from torchvision.datasets.mnist import MNIST
3030
from torchvision import transforms
3131
else:
3232
from tests.base.datasets import MNIST
3333

34-
if DALI_AVAILABLE:
34+
if _DALI_AVAILABLE:
3535
from nvidia.dali import ops
3636
from nvidia.dali.pipeline import Pipeline
3737
from nvidia.dali.plugin.pytorch import DALIClassificationIterator
@@ -166,7 +166,7 @@ def add_model_specific_args(parent_parser):
166166

167167

168168
def cli_main():
169-
if not DALI_AVAILABLE:
169+
if not _DALI_AVAILABLE:
170170
return
171171

172172
pl.seed_everything(1234)

pl_examples/basic_examples/mnist_datamodule.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616

1717
from torch.utils.data import DataLoader, random_split
1818

19-
from pl_examples import DATASETS_PATH, TORCHVISION_AVAILABLE
19+
from pl_examples import _DATASETS_PATH, _TORCHVISION_AVAILABLE
2020
from pytorch_lightning import LightningDataModule
2121

22-
if TORCHVISION_AVAILABLE:
22+
if _TORCHVISION_AVAILABLE:
2323
from torchvision import transforms as transform_lib
2424
from torchvision.datasets import MNIST
2525
else:
@@ -38,7 +38,7 @@ class MNISTDataModule(LightningDataModule):
3838

3939
def __init__(
4040
self,
41-
data_dir: str = DATASETS_PATH,
41+
data_dir: str = _DATASETS_PATH,
4242
val_split: int = 5000,
4343
num_workers: int = 16,
4444
normalize: bool = False,
@@ -123,7 +123,7 @@ def test_dataloader(self):
123123

124124
@property
125125
def default_transforms(self):
126-
if not TORCHVISION_AVAILABLE:
126+
if not _TORCHVISION_AVAILABLE:
127127
return None
128128
if self.normalize:
129129
mnist_transforms = transform_lib.Compose(

pl_examples/domain_templates/semantic_segmentation.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ class KITTI(Dataset):
6767
encoded using `encode_segmap`, and given `transform` (if any) are applied to the image only
6868
(mask does not usually require transforms, but they can be implemented in a similar way).
6969
70-
>>> from pl_examples import DATASETS_PATH
71-
>>> dataset_path = os.path.join(DATASETS_PATH, "Kitti")
70+
>>> from pl_examples import _DATASETS_PATH
71+
>>> dataset_path = os.path.join(_DATASETS_PATH, "Kitti")
7272
>>> _create_synth_kitti_dataset(dataset_path, image_dims=(1024, 512))
7373
>>> KITTI(dataset_path, 'train') # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
7474
<...semantic_segmentation.KITTI object at ...>
@@ -161,8 +161,8 @@ class SegModel(pl.LightningModule):
161161
162162
Adam optimizer is used along with Cosine Annealing learning rate scheduler.
163163
164-
>>> from pl_examples import DATASETS_PATH
165-
>>> dataset_path = os.path.join(DATASETS_PATH, "Kitti")
164+
>>> from pl_examples import _DATASETS_PATH
165+
>>> dataset_path = os.path.join(_DATASETS_PATH, "Kitti")
166166
>>> _create_synth_kitti_dataset(dataset_path, image_dims=(1024, 512))
167167
>>> SegModel(dataset_path) # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
168168
SegModel(

pl_examples/test_examples.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import pytest
2020
import torch
2121

22-
from pl_examples import DALI_AVAILABLE
22+
from pl_examples import _DALI_AVAILABLE
2323

2424
ARGS_DEFAULT = """
2525
--default_root_dir %(tmpdir)s \
@@ -104,7 +104,7 @@ def test_examples_cpu(tmpdir, import_cli, cli_args):
104104
module.cli_main()
105105

106106

107-
@pytest.mark.skipif(not DALI_AVAILABLE, reason="Nvidia DALI required")
107+
@pytest.mark.skipif(not _DALI_AVAILABLE, reason="Nvidia DALI required")
108108
@pytest.mark.skipif(not torch.cuda.is_available(), reason="test requires GPU machine")
109109
@pytest.mark.skipif(platform.system() != 'Linux', reason='Only applies to Linux platform.')
110110
@pytest.mark.parametrize('cli_args', [ARGS_GPU])

pytorch_lightning/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
_logger.addHandler(python_logging.StreamHandler())
4141
_logger.setLevel(python_logging.INFO)
4242

43-
PACKAGE_ROOT = os.path.dirname(__file__)
44-
PROJECT_ROOT = os.path.dirname(PACKAGE_ROOT)
43+
_PACKAGE_ROOT = os.path.dirname(__file__)
44+
_PROJECT_ROOT = os.path.dirname(_PACKAGE_ROOT)
4545

4646
try:
4747
# This variable is injected in the __builtins__ by the build

pytorch_lightning/loggers/wandb.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,9 @@ def log_metrics(self, metrics: Dict[str, float], step: Optional[int] = None) ->
162162

163163
metrics = self._add_prefix(metrics)
164164
if step is not None and step + self._step_offset < self.experiment.step:
165-
self.warning_cache.warn('Trying to log at a previous step. Use `commit=False` when logging metrics manually.')
165+
self.warning_cache.warn(
166+
'Trying to log at a previous step. Use `commit=False` when logging metrics manually.'
167+
)
166168
self.experiment.log(metrics, step=(step + self._step_offset) if step is not None else None)
167169

168170
@property

0 commit comments

Comments
 (0)