Skip to content

Commit

Permalink
unify
Browse files Browse the repository at this point in the history
  • Loading branch information
Borda committed Mar 2, 2021
1 parent c584f03 commit a3307fa
Show file tree
Hide file tree
Showing 52 changed files with 90 additions and 90 deletions.
2 changes: 1 addition & 1 deletion tests/accelerators/test_accelerator_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from pytorch_lightning.plugins.environments import ClusterEnvironment, SLURMEnvironment, TorchElasticEnvironment
from pytorch_lightning.utilities.exceptions import MisconfigurationException
from tests.helpers.boring_model import BoringModel
from tests.helpers.skipif import RunIf
from tests.helpers.runif import RunIf


def test_accelerator_choice_cpu(tmpdir):
Expand Down
4 changes: 2 additions & 2 deletions tests/accelerators/test_ddp.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from pytorch_lightning import Trainer
from tests.accelerators import ddp_model, DDPLauncher
from tests.helpers.boring_model import BoringModel
from tests.helpers.skipif import RunIf
from tests.helpers.runif import RunIf
from tests.utilities.distributed import call_training_script

CLI_ARGS = '--max_epochs 1 --gpus 2 --accelerator ddp'
Expand Down Expand Up @@ -82,7 +82,7 @@ def test_cli_to_pass(tmpdir, args=None):
return '1'


@RunIf(not_windows=True)
@RunIf(skip_windows=True)
@pytest.mark.skipif(torch.cuda.is_available(), reason="test doesn't requires GPU machine")
def test_torch_distributed_backend_env_variables(tmpdir):
"""
Expand Down
2 changes: 1 addition & 1 deletion tests/accelerators/test_ddp_spawn.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from tests.helpers import BoringModel
from tests.helpers.datamodules import ClassifDataModule
from tests.helpers.simple_models import ClassificationModel
from tests.helpers.skipif import RunIf
from tests.helpers.runif import RunIf


@RunIf(min_gpus=2)
Expand Down
2 changes: 1 addition & 1 deletion tests/accelerators/test_dp.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from tests.helpers import BoringModel
from tests.helpers.datamodules import ClassifDataModule
from tests.helpers.simple_models import ClassificationModel
from tests.helpers.skipif import RunIf
from tests.helpers.runif import RunIf

PRETEND_N_OF_GPUS = 16

Expand Down
4 changes: 2 additions & 2 deletions tests/callbacks/test_early_stopping.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,13 +374,13 @@ def on_train_end(self) -> None:
3,
'ddp_cpu',
2,
marks=RunIf(not_windows=True)),
marks=RunIf(skip_windows=True)),
pytest.param([EarlyStopping(monitor='cba', patience=3),
EarlyStopping(monitor='abc')],
3,
'ddp_cpu',
2,
marks=RunIf(not_windows=True)),
marks=RunIf(skip_windows=True)),
],
)
def test_multiple_early_stopping_callbacks(callbacks, expected_stop_epoch, accelerator, num_processes, tmpdir):
Expand Down
2 changes: 1 addition & 1 deletion tests/callbacks/test_gpu_stats_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from pytorch_lightning.trainer.states import TrainerState
from pytorch_lightning.utilities.exceptions import MisconfigurationException
from tests.helpers import BoringModel
from tests.helpers.skipif import RunIf
from tests.helpers.runif import RunIf


@RunIf(min_gpus=1)
Expand Down
6 changes: 3 additions & 3 deletions tests/callbacks/test_pruning.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from pytorch_lightning.callbacks import ModelPruning
from pytorch_lightning.utilities.exceptions import MisconfigurationException
from tests.helpers import BoringModel
from tests.helpers.skipif import RunIf
from tests.helpers.runif import RunIf


class TestModel(BoringModel):
Expand Down Expand Up @@ -168,12 +168,12 @@ def test_pruning_callback_ddp(tmpdir, use_global_unstructured, parameters_to_pru
)


@RunIf(min_gpus=2, windows=True)
@RunIf(min_gpus=2, skip_windows=True)
def test_pruning_callback_ddp_spawn(tmpdir):
train_with_pruning_callback(tmpdir, use_global_unstructured=True, accelerator="ddp_spawn", gpus=2)


@RunIf(windows=True)
@RunIf(skip_windows=True)
def test_pruning_callback_ddp_cpu(tmpdir):
train_with_pruning_callback(tmpdir, parameters_to_prune=True, accelerator="ddp_cpu", num_processes=2)

Expand Down
2 changes: 1 addition & 1 deletion tests/callbacks/test_quantization.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from pytorch_lightning.utilities.exceptions import MisconfigurationException
from tests.helpers.datamodules import RegressDataModule
from tests.helpers.simple_models import RegressionModel
from tests.helpers.skipif import RunIf
from tests.helpers.runif import RunIf


@pytest.mark.parametrize("observe", ['average', pytest.param('histogram', marks=RunIf(min_torch="1.5"))])
Expand Down
4 changes: 2 additions & 2 deletions tests/callbacks/test_stochastic_weight_avg.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from pytorch_lightning.utilities import _TORCH_GREATER_EQUAL_1_6
from pytorch_lightning.utilities.exceptions import MisconfigurationException
from tests.helpers import BoringModel, RandomDataset
from tests.helpers.skipif import RunIf
from tests.helpers.runif import RunIf

if _TORCH_GREATER_EQUAL_1_6:
from pytorch_lightning.callbacks import StochasticWeightAveraging
Expand Down Expand Up @@ -127,7 +127,7 @@ def test_swa_callback_ddp_spawn(tmpdir):
train_with_swa(tmpdir, accelerator="ddp_spawn", gpus=2)


@RunIf(min_torch="1.6.0", windows=True)
@RunIf(min_torch="1.6.0", skip_windows=True)
def test_swa_callback_ddp_cpu(tmpdir):
train_with_swa(tmpdir, accelerator="ddp_cpu", num_processes=2)

Expand Down
4 changes: 2 additions & 2 deletions tests/checkpointing/test_torch_saving.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from pytorch_lightning import Trainer
from tests.helpers import BoringModel
from tests.helpers.skipif import RunIf
from tests.helpers.runif import RunIf


def test_model_torch_save(tmpdir):
Expand All @@ -38,7 +38,7 @@ def test_model_torch_save(tmpdir):
trainer = torch.load(temp_path)


@RunIf(windows=True)
@RunIf(skip_windows=True)
def test_model_torch_save_ddp_cpu(tmpdir):
"""Test to ensure torch save does not fail for model and trainer using cpu ddp."""
model = BoringModel()
Expand Down
2 changes: 1 addition & 1 deletion tests/core/test_datamodules.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from tests.helpers import BoringDataModule, BoringModel
from tests.helpers.datamodules import ClassifDataModule
from tests.helpers.simple_models import ClassificationModel
from tests.helpers.skipif import RunIf
from tests.helpers.runif import RunIf
from tests.helpers.utils import reset_seed, set_random_master_port


Expand Down
2 changes: 1 addition & 1 deletion tests/core/test_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

from pytorch_lightning.core.decorators import auto_move_data
from tests.helpers import BoringModel
from tests.helpers.skipif import RunIf
from tests.helpers.runif import RunIf


@RunIf(min_gpus=1)
Expand Down
2 changes: 1 addition & 1 deletion tests/core/test_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from pytorch_lightning.utilities.exceptions import MisconfigurationException
from tests.helpers import BoringModel
from tests.helpers.advanced_models import ParityModuleRNN
from tests.helpers.skipif import RunIf
from tests.helpers.runif import RunIf


class EmptyModule(LightningModule):
Expand Down
2 changes: 1 addition & 1 deletion tests/core/test_metric_result_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def _ddp_test_fn(rank, worldsize):
assert epoch_expected[k] == epoch_log[k]


@RunIf(not_windows=True)
@RunIf(skip_windows=True)
def test_result_reduce_ddp():
"""Make sure result logging works with DDP"""
tutils.reset_seed()
Expand Down
4 changes: 2 additions & 2 deletions tests/core/test_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from pytorch_lightning.core.step_result import Result
from pytorch_lightning.trainer.states import TrainerState
from tests.helpers import BoringDataModule, BoringModel
from tests.helpers.skipif import RunIf
from tests.helpers.runif import RunIf


def _setup_ddp(rank, worldsize):
Expand All @@ -48,7 +48,7 @@ def _ddp_test_fn(rank, worldsize, result_cls: Result):


@pytest.mark.parametrize("result_cls", [Result])
@RunIf(not_windows=True)
@RunIf(skip_windows=True)
def test_result_reduce_ddp(result_cls):
"""Make sure result logging works with DDP"""
tutils.reset_seed()
Expand Down
4 changes: 2 additions & 2 deletions tests/deprecated_api/test_remove_1-4.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from pytorch_lightning.plugins.environments import TorchElasticEnvironment
from tests.deprecated_api import _soft_unimport_module
from tests.helpers import BoringModel
from tests.helpers.skipif import RunIf
from tests.helpers.runif import RunIf


def test_v1_4_0_deprecated_trainer_attributes():
Expand Down Expand Up @@ -177,7 +177,7 @@ def configure_ddp(self):
assert isinstance(self.model.module, LightningDistributedModule)


@RunIf(min_gpus=2, windows=True)
@RunIf(min_gpus=2, skip_windows=True)
def test_v1_4_0_deprecated_lightning_distributed_data_parallel(tmpdir):
model = BoringModel()
trainer = Trainer(
Expand Down
4 changes: 2 additions & 2 deletions tests/helpers/runif.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def __new__(
min_gpus: int = 0,
min_torch: Optional[str] = None,
quantization: bool = False,
not_windows: bool = False,
skip_windows: bool = False,
**kwargs
):
"""
Expand Down Expand Up @@ -66,7 +66,7 @@ def __new__(
conditions.append(not _TORCH_QUANTIZE_AVAILABLE or _miss_default)
reasons.append("missing PyTorch quantization")

if not_windows:
if skip_windows:
conditions.append(sys.platform == "win32")
reasons.append("unimplemented on Windows")

Expand Down
2 changes: 1 addition & 1 deletion tests/loggers/test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ def on_train_batch_start(self, trainer, pl_module, batch, batch_idx, dataloader_
TestTubeLogger,
]
)
@RunIf(not_windows=True)
@RunIf(skip_windows=True)
def test_logger_created_on_rank_zero_only(tmpdir, monkeypatch, logger_class):
""" Test that loggers get replaced by dummy loggers on global rank > 0"""
_patch_comet_atexit(monkeypatch)
Expand Down
2 changes: 1 addition & 1 deletion tests/metrics/test_composition.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from pytorch_lightning.metrics.compositional import CompositionalMetric
from pytorch_lightning.metrics.metric import Metric
from tests.helpers.skipif import RunIf
from tests.helpers.runif import RunIf


class DummyMetric(Metric):
Expand Down
4 changes: 2 additions & 2 deletions tests/metrics/test_ddp.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def _test_ddp_sum_cat(rank, worldsize):
assert dummy.bar == worldsize


@RunIf(not_windows=True)
@RunIf(skip_windows=True)
@pytest.mark.parametrize("process", [_test_ddp_cat, _test_ddp_sum, _test_ddp_sum_cat])
def test_ddp(process):
torch.multiprocessing.spawn(process, args=(2, ), nprocs=2)
Expand All @@ -65,7 +65,7 @@ def compute(self):
metric.update(torch.randn(10, 5)[:, 0])


@RunIf(not_windows=True)
@RunIf(skip_windows=True)
def test_non_contiguous_tensors():
""" Test that gather_all operation works for non contiguous tensors """
torch.multiprocessing.spawn(_test_non_contiguous_tensors, args=(2, ), nprocs=2)
2 changes: 1 addition & 1 deletion tests/metrics/test_metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from torch import nn

from pytorch_lightning.metrics.metric import Metric, MetricCollection
from tests.helpers.skipif import RunIf
from tests.helpers.runif import RunIf

torch.manual_seed(42)

Expand Down
2 changes: 1 addition & 1 deletion tests/models/test_amp.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from pytorch_lightning.utilities import _APEX_AVAILABLE
from pytorch_lightning.utilities.exceptions import MisconfigurationException
from tests.helpers import BoringModel
from tests.helpers.skipif import RunIf
from tests.helpers.runif import RunIf


class AMPTestModel(BoringModel):
Expand Down
2 changes: 1 addition & 1 deletion tests/models/test_cpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def validation_step(self, *args, **kwargs):
model.unfreeze()


@RunIf(not_windows=True)
@RunIf(skip_windows=True)
def test_multi_cpu_model_ddp(tmpdir):
"""Make sure DDP works."""
tutils.set_random_master_port()
Expand Down
2 changes: 1 addition & 1 deletion tests/models/test_gpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from tests.helpers import BoringModel
from tests.helpers.datamodules import ClassifDataModule
from tests.helpers.simple_models import ClassificationModel
from tests.helpers.skipif import RunIf
from tests.helpers.runif import RunIf

PRETEND_N_OF_GPUS = 16

Expand Down
2 changes: 1 addition & 1 deletion tests/models/test_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from pytorch_lightning import Callback, Trainer
from pytorch_lightning.trainer.states import TrainerState
from tests.helpers import BoringModel, RandomDataset
from tests.helpers.skipif import RunIf
from tests.helpers.runif import RunIf


@pytest.mark.parametrize('max_steps', [1, 2, 3])
Expand Down
Loading

0 comments on commit a3307fa

Please sign in to comment.