From dddc5174c687450d599252640a32dee4717fa1de Mon Sep 17 00:00:00 2001 From: Jiri Borovec Date: Fri, 7 Feb 2020 16:03:47 +0100 Subject: [PATCH 1/3] drop torchvision, tests only --- pl_examples/requirements.txt | 1 + pytorch_lightning/testing/__init__.py | 12 ---------- pytorch_lightning/testing/model.py | 13 ---------- requirements.txt | 1 - tests/models/__init__.py | 24 +++++++++++++++++++ .../model_base.py => tests/models/base.py | 0 .../model_mixins.py => tests/models/mixins.py | 0 tests/requirements.txt | 1 + tests/test_amp.py | 2 +- tests/test_cpu_models.py | 2 +- tests/test_gpu_models.py | 2 +- tests/test_logging.py | 2 +- tests/test_restore_models.py | 2 +- tests/test_trainer.py | 2 +- tests/utils.py | 2 +- 15 files changed, 33 insertions(+), 33 deletions(-) create mode 100644 pl_examples/requirements.txt delete mode 100644 pytorch_lightning/testing/__init__.py delete mode 100644 pytorch_lightning/testing/model.py create mode 100644 tests/models/__init__.py rename pytorch_lightning/testing/model_base.py => tests/models/base.py (100%) rename pytorch_lightning/testing/model_mixins.py => tests/models/mixins.py (100%) diff --git a/pl_examples/requirements.txt b/pl_examples/requirements.txt new file mode 100644 index 0000000000000..d9f4c0d808165 --- /dev/null +++ b/pl_examples/requirements.txt @@ -0,0 +1 @@ +torchvision>=0.4.0 \ No newline at end of file diff --git a/pytorch_lightning/testing/__init__.py b/pytorch_lightning/testing/__init__.py deleted file mode 100644 index 326f67caf118a..0000000000000 --- a/pytorch_lightning/testing/__init__.py +++ /dev/null @@ -1,12 +0,0 @@ -from .model import LightningTestModel -from .model_base import LightningTestModelBase -from .model_mixins import ( - LightningValidationStepMixin, - LightningValidationMixin, - LightningValidationStepMultipleDataloadersMixin, - LightningValidationMultipleDataloadersMixin, - LightningTestStepMixin, - LightningTestMixin, - LightningTestStepMultipleDataloadersMixin, - LightningTestMultipleDataloadersMixin, -) diff --git a/pytorch_lightning/testing/model.py b/pytorch_lightning/testing/model.py deleted file mode 100644 index 51ed6b57b9658..0000000000000 --- a/pytorch_lightning/testing/model.py +++ /dev/null @@ -1,13 +0,0 @@ -import torch - -from .model_base import LightningTestModelBase -from .model_mixins import LightningValidationMixin, LightningTestMixin - - -class LightningTestModel(LightningValidationMixin, LightningTestMixin, LightningTestModelBase): - """ - Most common test case. Validation and test dataloaders - """ - - def on_training_metrics(self, logs): - logs['some_tensor_to_test'] = torch.rand(1) diff --git a/requirements.txt b/requirements.txt index 90cec5a5f5606..92731a1a91788 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,6 @@ scikit-learn>=0.20.2 tqdm>=4.35.0 numpy>=1.16.4 torch>=1.1 -torchvision>=0.4.0, < 0.5 # the 0.5. has some issues with torch JIT tensorboard>=1.14 future>=0.17.1 # required for builtins in setup.py diff --git a/tests/models/__init__.py b/tests/models/__init__.py new file mode 100644 index 0000000000000..5da8521e0f618 --- /dev/null +++ b/tests/models/__init__.py @@ -0,0 +1,24 @@ +"""Models for testing.""" + +import torch + +from .base import LightningTestModelBase +from .mixins import ( + LightningValidationStepMixin, + LightningValidationMixin, + LightningValidationStepMultipleDataloadersMixin, + LightningValidationMultipleDataloadersMixin, + LightningTestStepMixin, + LightningTestMixin, + LightningTestStepMultipleDataloadersMixin, + LightningTestMultipleDataloadersMixin, +) + + +class LightningTestModel(LightningValidationMixin, LightningTestMixin, LightningTestModelBase): + """ + Most common test case. Validation and test dataloaders. + """ + + def on_training_metrics(self, logs): + logs['some_tensor_to_test'] = torch.rand(1) diff --git a/pytorch_lightning/testing/model_base.py b/tests/models/base.py similarity index 100% rename from pytorch_lightning/testing/model_base.py rename to tests/models/base.py diff --git a/pytorch_lightning/testing/model_mixins.py b/tests/models/mixins.py similarity index 100% rename from pytorch_lightning/testing/model_mixins.py rename to tests/models/mixins.py diff --git a/tests/requirements.txt b/tests/requirements.txt index 7d30b65a8679e..b2c3ca4769830 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -1,3 +1,4 @@ +torchvision>=0.4.0, < 0.5 # the 0.5. has some issues with torch JIT tox coverage codecov diff --git a/tests/test_amp.py b/tests/test_amp.py index 4d4ae22d578d2..b5050d68773f6 100644 --- a/tests/test_amp.py +++ b/tests/test_amp.py @@ -4,7 +4,7 @@ import tests.utils as tutils from pytorch_lightning import Trainer -from pytorch_lightning.testing import ( +from tests.models import ( LightningTestModel, ) from pytorch_lightning.utilities.debugging import MisconfigurationException diff --git a/tests/test_cpu_models.py b/tests/test_cpu_models.py index fa643c64ac5fc..aa5a19f3e44b1 100644 --- a/tests/test_cpu_models.py +++ b/tests/test_cpu_models.py @@ -7,7 +7,7 @@ from pytorch_lightning.callbacks import ( EarlyStopping, ) -from pytorch_lightning.testing import ( +from tests.models import ( LightningTestModel, LightningTestModelBase, LightningTestMixin, diff --git a/tests/test_gpu_models.py b/tests/test_gpu_models.py index ec7f36e838472..7081bae63356e 100644 --- a/tests/test_gpu_models.py +++ b/tests/test_gpu_models.py @@ -9,7 +9,7 @@ ModelCheckpoint, ) from pytorch_lightning.core import memory -from pytorch_lightning.testing import ( +from tests.models import ( LightningTestModel, ) from pytorch_lightning.trainer.distrib_parts import ( diff --git a/tests/test_logging.py b/tests/test_logging.py index 9f260ebce09c9..747c3510cf115 100644 --- a/tests/test_logging.py +++ b/tests/test_logging.py @@ -15,7 +15,7 @@ WandbLogger, NeptuneLogger ) -from pytorch_lightning.testing import LightningTestModel +from tests.models import LightningTestModel def test_testtube_logger(tmpdir): diff --git a/tests/test_restore_models.py b/tests/test_restore_models.py index 57d28040f1016..3df462af9b125 100644 --- a/tests/test_restore_models.py +++ b/tests/test_restore_models.py @@ -6,7 +6,7 @@ import tests.utils as tutils from pytorch_lightning import Trainer from pytorch_lightning.callbacks import ModelCheckpoint -from pytorch_lightning.testing import LightningTestModel +from tests.models import LightningTestModel def test_running_test_pretrained_model_ddp(tmpdir): diff --git a/tests/test_trainer.py b/tests/test_trainer.py index ad2748506fc9f..d8114bde7d862 100644 --- a/tests/test_trainer.py +++ b/tests/test_trainer.py @@ -8,7 +8,7 @@ from pytorch_lightning.callbacks import ( ModelCheckpoint, ) -from pytorch_lightning.testing import ( +from tests.models import ( LightningTestModel, LightningTestModelBase, LightningValidationStepMixin, diff --git a/tests/utils.py b/tests/utils.py index e3f84567dac2c..7a641b56ad6e2 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -9,7 +9,7 @@ from pytorch_lightning import Trainer from pytorch_lightning.callbacks import ModelCheckpoint from pytorch_lightning.loggers import TestTubeLogger, TensorBoardLogger -from pytorch_lightning.testing import LightningTestModel +from tests.models import LightningTestModel # generate a list of random seeds for each test RANDOM_PORTS = list(np.random.randint(12000, 19000, 1000)) From ba9da40f63668caa050885d097fd79dea486926b Mon Sep 17 00:00:00 2001 From: Jiri Borovec Date: Fri, 7 Feb 2020 22:30:56 +0100 Subject: [PATCH 2/3] manifest --- MANIFEST.in | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index b15ebfd8c2c2a..f12a637d5ac17 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -15,9 +15,7 @@ exclude *.svg recursive-include pytorch_lightning *.py # include examples -recursive-include pl_examples *.py -recursive-include pl_examples *.md -recursive-include pl_examples *.sh +recursive-include pl_examples *.py *.md *.sh *.txt # exclude tests from package recursive-exclude tests * From 2ea05b0becd46ff42852bf5b5d6a24e43d0b4885 Mon Sep 17 00:00:00 2001 From: Jiri Borovec Date: Sat, 8 Feb 2020 00:17:03 +0100 Subject: [PATCH 3/3] move test utils --- tests/{ => models}/debug.py | 0 tests/{ => models}/utils.py | 0 tests/test_amp.py | 2 +- tests/test_cpu_models.py | 2 +- tests/test_gpu_models.py | 2 +- tests/test_logging.py | 2 +- tests/test_restore_models.py | 2 +- tests/test_trainer.py | 2 +- 8 files changed, 6 insertions(+), 6 deletions(-) rename tests/{ => models}/debug.py (100%) rename tests/{ => models}/utils.py (100%) diff --git a/tests/debug.py b/tests/models/debug.py similarity index 100% rename from tests/debug.py rename to tests/models/debug.py diff --git a/tests/utils.py b/tests/models/utils.py similarity index 100% rename from tests/utils.py rename to tests/models/utils.py diff --git a/tests/test_amp.py b/tests/test_amp.py index b5050d68773f6..0ea7799148ccb 100644 --- a/tests/test_amp.py +++ b/tests/test_amp.py @@ -2,7 +2,7 @@ import pytest -import tests.utils as tutils +import tests.models.utils as tutils from pytorch_lightning import Trainer from tests.models import ( LightningTestModel, diff --git a/tests/test_cpu_models.py b/tests/test_cpu_models.py index aa5a19f3e44b1..37daf58c12aa9 100644 --- a/tests/test_cpu_models.py +++ b/tests/test_cpu_models.py @@ -2,7 +2,7 @@ import torch -import tests.utils as tutils +import tests.models.utils as tutils from pytorch_lightning import Trainer, data_loader from pytorch_lightning.callbacks import ( EarlyStopping, diff --git a/tests/test_gpu_models.py b/tests/test_gpu_models.py index 7081bae63356e..51f2541b3c4bb 100644 --- a/tests/test_gpu_models.py +++ b/tests/test_gpu_models.py @@ -3,7 +3,7 @@ import pytest import torch -import tests.utils as tutils +import tests.models.utils as tutils from pytorch_lightning import Trainer from pytorch_lightning.callbacks import ( ModelCheckpoint, diff --git a/tests/test_logging.py b/tests/test_logging.py index 747c3510cf115..c0166796ca0c5 100644 --- a/tests/test_logging.py +++ b/tests/test_logging.py @@ -4,7 +4,7 @@ import pytest import torch -import tests.utils as tutils +import tests.models.utils as tutils from pytorch_lightning import Trainer from pytorch_lightning.loggers import ( LightningLoggerBase, diff --git a/tests/test_restore_models.py b/tests/test_restore_models.py index 3df462af9b125..92ab71364ccae 100644 --- a/tests/test_restore_models.py +++ b/tests/test_restore_models.py @@ -3,7 +3,7 @@ import torch -import tests.utils as tutils +import tests.models.utils as tutils from pytorch_lightning import Trainer from pytorch_lightning.callbacks import ModelCheckpoint from tests.models import LightningTestModel diff --git a/tests/test_trainer.py b/tests/test_trainer.py index d8114bde7d862..b4aa4788c2943 100644 --- a/tests/test_trainer.py +++ b/tests/test_trainer.py @@ -3,7 +3,7 @@ import pytest import torch -import tests.utils as tutils +import tests.models.utils as tutils from pytorch_lightning import Trainer from pytorch_lightning.callbacks import ( ModelCheckpoint,