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 * 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/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/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/utils.py b/tests/models/utils.py similarity index 99% rename from tests/utils.py rename to tests/models/utils.py index e3f84567dac2c..7a641b56ad6e2 100644 --- a/tests/utils.py +++ b/tests/models/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)) 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..0ea7799148ccb 100644 --- a/tests/test_amp.py +++ b/tests/test_amp.py @@ -2,9 +2,9 @@ import pytest -import tests.utils as tutils +import tests.models.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..37daf58c12aa9 100644 --- a/tests/test_cpu_models.py +++ b/tests/test_cpu_models.py @@ -2,12 +2,12 @@ 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, ) -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..51f2541b3c4bb 100644 --- a/tests/test_gpu_models.py +++ b/tests/test_gpu_models.py @@ -3,13 +3,13 @@ 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, ) 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..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, @@ -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..92ab71364ccae 100644 --- a/tests/test_restore_models.py +++ b/tests/test_restore_models.py @@ -3,10 +3,10 @@ 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 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..b4aa4788c2943 100644 --- a/tests/test_trainer.py +++ b/tests/test_trainer.py @@ -3,12 +3,12 @@ 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, ) -from pytorch_lightning.testing import ( +from tests.models import ( LightningTestModel, LightningTestModelBase, LightningValidationStepMixin,