diff --git a/.actions/pull_legacy_checkpoints.sh b/.actions/pull_legacy_checkpoints.sh index 8b3f791297b66..cf8a0fdf4e574 100644 --- a/.actions/pull_legacy_checkpoints.sh +++ b/.actions/pull_legacy_checkpoints.sh @@ -1,9 +1,9 @@ #!/bin/bash # Run this script from the project root. URL="https://pl-public-data.s3.amazonaws.com/legacy/checkpoints.zip" -mkdir -p legacy +mkdir -p tests/legacy # wget is simpler but does not work on Windows -python -c "from urllib.request import urlretrieve; urlretrieve('$URL', 'legacy/checkpoints.zip')" -ls -l legacy/ -unzip -o legacy/checkpoints.zip -d legacy/ -ls -l legacy/checkpoints/ +python -c "from urllib.request import urlretrieve; urlretrieve('$URL', 'tests/legacy/checkpoints.zip')" +ls -l tests/legacy/ +unzip -o tests/legacy/checkpoints.zip -d tests/legacy/ +ls -l tests/legacy/checkpoints/ diff --git a/.azure-pipelines/gpu-benchmark.yml b/.azure-pipelines/gpu-benchmark.yml index a303663d9758b..1fbcc7c7cdaa5 100644 --- a/.azure-pipelines/gpu-benchmark.yml +++ b/.azure-pipelines/gpu-benchmark.yml @@ -40,8 +40,8 @@ jobs: pip list displayName: 'Install package' - - bash: | - python -m pytest tests/benchmarks -v --durations=0 - displayName: 'Testing: benchmarks' + - bash: python -m pytest benchmarks -v --durations=0 env: PL_RUNNING_BENCHMARKS: 1 + workingDirectory: tests/tests_pytorch + displayName: 'Testing: PyTorch benchmarks' diff --git a/.azure-pipelines/gpu-tests.yml b/.azure-pipelines/gpu-tests.yml index 211d6e852b4a5..afc01958a962a 100644 --- a/.azure-pipelines/gpu-tests.yml +++ b/.azure-pipelines/gpu-tests.yml @@ -17,7 +17,7 @@ pr: - "release/*" jobs: - - job: pytest + - job: testing strategy: matrix: 'PyTorch - stable': @@ -67,17 +67,19 @@ jobs: - bash: bash .actions/pull_legacy_checkpoints.sh displayName: 'Get legacy checkpoints' - - bash: python -m coverage run --source pytorch_lightning -m pytest pytorch_lightning - workingDirectory: src - displayName: 'Testing: doctests' + - bash: python -m coverage run --source pytorch_lightning -m pytest + workingDirectory: src/pytorch_lightning + displayName: 'Testing: PyTorch doctests' - - bash: python -m coverage run --source pytorch_lightning -m pytest tests --ignore tests/benchmarks -v --junitxml=$(Build.StagingDirectory)/test-results.xml --durations=50 - displayName: 'Testing: unittests' + - bash: python -m coverage run --source pytorch_lightning -m pytest --ignore benchmarks -v --junitxml=$(Build.StagingDirectory)/test-results.xml --durations=50 + displayName: 'Testing: PyTorch standard' + workingDirectory: tests/tests_pytorch - - bash: bash tests/standalone_tests.sh + - bash: bash run_standalone_tests.sh + workingDirectory: tests/tests_pytorch env: PL_USE_MOCKED_MNIST: "1" - displayName: 'Testing: standalone' + displayName: 'Testing: PyTorch standalone tests' - bash: | python -m coverage report @@ -85,6 +87,7 @@ jobs: python -m coverage html python -m codecov --token=$(CODECOV_TOKEN) --commit=$(Build.SourceVersion) --flags=gpu,pytest --name="GPU-coverage" --env=linux,azure ls -l + workingDirectory: tests/tests_pytorch displayName: 'Statistics' - task: PublishTestResults@2 @@ -94,16 +97,6 @@ jobs: testRunTitle: '$(Agent.OS) - $(Build.DefinitionName) - Python $(python.version)' condition: succeededOrFailed() - # todo: re-enable after schema check pass, also atm it seems does not have any effect - #- task: PublishCodeCoverageResults@2 - # displayName: 'Publish coverage report' - # inputs: - # codeCoverageTool: 'Cobertura' - # summaryFileLocation: 'coverage.xml' - # reportDirectory: '$(Build.SourcesDirectory)/htmlcov' - # testRunTitle: '$(Agent.OS) - $(Build.BuildNumber)[$(Agent.JobName)] - Python $(python.version)' - # condition: succeededOrFailed() - - script: | set -e bash run_ddp_examples.sh @@ -113,8 +106,8 @@ jobs: workingDirectory: examples env: PL_USE_MOCKED_MNIST: "1" - displayName: 'Testing: examples' + displayName: 'Testing: PyTorch examples' - - bash: | - python -m pytest tests/benchmarks -v --maxfail=2 --durations=0 - displayName: 'Testing: benchmarks' + - bash: python -m pytest benchmarks -v --maxfail=2 --durations=0 + workingDirectory: tests/tests_pytorch + displayName: 'Testing: PyTorch benchmarks' diff --git a/.azure-pipelines/hpu-tests.yml b/.azure-pipelines/hpu-tests.yml index 5d3973eae548d..6385f8874aa1e 100644 --- a/.azure-pipelines/hpu-tests.yml +++ b/.azure-pipelines/hpu-tests.yml @@ -14,8 +14,7 @@ pr: - "release/*" jobs: - - job: tests - + - job: testing # how long to run the job before automatically cancelling timeoutInMinutes: "10" # how much time to give 'run always even if cancelled tasks' before stopping them @@ -36,15 +35,21 @@ jobs: displayName: 'Install dependencies' - bash: | - python -m pytest -sv tests/accelerators/test_hpu.py --forked --junitxml=hpu1_test-results.xml + python -m pytest -sv accelerators/test_hpu.py --forked --junitxml=hpu1_test-results.xml + workingDirectory: tests/tests_pytorch displayName: 'Single card HPU test' - bash: | - python -m pytest -sv tests/accelerators/test_hpu.py --forked --hpus 8 --junitxml=hpu8_test-results.xml + python -m pytest -sv accelerators/test_hpu.py --forked --hpus 8 --junitxml=hpu8_test-results.xml + workingDirectory: tests/tests_pytorch displayName: 'Multi card(8) HPU test' - bash: | - python -m pytest -sv tests/plugins/precision/hpu/test_hpu.py --hmp-bf16 'tests/plugins/precision/hpu/ops_bf16.txt' --hmp-fp32 'tests/plugins/precision/hpu/ops_fp32.txt' --forked --junitxml=hpu1_precision_test-results.xml + python -m pytest -sv plugins/precision/hpu/test_hpu.py --hmp-bf16 \ + 'plugins/precision/hpu/ops_bf16.txt' --hmp-fp32 \ + 'plugins/precision/hpu/ops_fp32.txt' --forked \ + --junitxml=hpu1_precision_test-results.xml + workingDirectory: tests/tests_pytorch displayName: 'HPU precision test' - bash: | diff --git a/.azure-pipelines/ipu-tests.yml b/.azure-pipelines/ipu-tests.yml index 7e3a9dcdc4caa..8608c77b0d812 100644 --- a/.azure-pipelines/ipu-tests.yml +++ b/.azure-pipelines/ipu-tests.yml @@ -16,8 +16,7 @@ variables: value: "poplar_sdk-ubuntu_20_04-2.3.1+793-89796d462d" jobs: - - job: tests - + - job: testing # how long to run the job before automatically cancelling timeoutInMinutes: "15" pool: graphcore-ipus @@ -73,16 +72,17 @@ jobs: - bash: | source ${{ variables.poplar_sdk }}/poplar-ubuntu*/enable.sh source ${{ variables.poplar_sdk }}/popart-ubuntu*/enable.sh - cd src - python -m pytest pytorch_lightning - displayName: 'DocTests' + python -m coverage run --source pytorch_lightning -m pytest + workingDirectory: src/pytorch_lightning + displayName: 'Testing: PyTorch doctests' - bash: | source ${{ variables.poplar_sdk }}/poplar-ubuntu*/enable.sh source ${{ variables.poplar_sdk }}/popart-ubuntu*/enable.sh - python -m coverage run --source pytorch_lightning -m pytest tests -vv --durations=50 + python -m coverage run --source pytorch_lightning -m pytest -vv --durations=50 env: MKL_THREADING_LAYER: "GNU" POPTORCH_WAIT_FOR_IPU: 1 PL_RUN_IPU_TESTS: 1 - displayName: 'UnitTests' + displayName: 'Testing: PyTorch standard' + workingDirectory: tests/tests_pytorch diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 06285ce7ac50d..e12e80ca26e47 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -240,11 +240,11 @@ Here is the process to create a new test - 3. Use **BoringModel and derivates to test out your code**. ```python -# TEST SHOULD BE IN YOUR FILE: tests/..../...py +# TEST SHOULD BE IN YOUR FILE: tests/.../test_file.py # TEST CODE TEMPLATE # [OPTIONAL] pytest decorator -# @pytest.mark.skipif(not torch.cuda.is_available(), reason="test requires GPU machine") +# @RunIf(min_cuda_gpus=1) def test_explain_what_is_being_tested(tmpdir): """ Test description about text reason to be @@ -269,7 +269,7 @@ def test_explain_what_is_being_tested(tmpdir): run our/your test with ```bash -python -m pytest tests/..../...py::test_explain_what_is_being_tested -v --capture=no +python -m pytest tests/.../test_file.py::test_explain_what_is_being_tested -v --capture=no ``` #### How to fix PR with mixed base and target branches? diff --git a/.github/workflows/ci_test-conda.yml b/.github/workflows/ci_test-conda.yml index 4d4268112caa8..f2e36aab57d3a 100644 --- a/.github/workflows/ci_test-conda.yml +++ b/.github/workflows/ci_test-conda.yml @@ -31,7 +31,7 @@ jobs: timeout-minutes: 30 steps: - name: Workaround for https://github.com/actions/checkout/issues/760 - run: git config --global --add safe.directory /__w/pytorch-lightning/pytorch-lightning + run: git config --global --add safe.directory /__w/lightning/lightning - uses: actions/checkout@v2 @@ -66,20 +66,20 @@ jobs: - name: Pull legacy checkpoints run: bash .actions/pull_legacy_checkpoints.sh - - name: Testing - run: | - coverage run --source pytorch_lightning -m pytest --timeout 150 tests -v --durations=50 --junitxml=junit/test-results-${{ runner.os }}-torch${{ matrix.pytorch-version }}.xml + - name: Testing PyTorch + working-directory: tests/tests_pytorch + run: coverage run --source pytorch_lightning -m pytest -v --timeout 150 --durations=50 --junitxml=results-${{ runner.os }}-torch${{ matrix.pytorch-version }}.xml - name: Upload pytest results uses: actions/upload-artifact@v2 with: - name: pytest-results-${{ runner.os }}-torch${{ matrix.pytorch-version }} - path: junit/test-results-${{ runner.os }}-torch${{ matrix.pytorch-version }}.xml - if-no-files-found: error + name: unittest-results-${{ runner.os }}-torch${{ matrix.pytorch-version }} + path: tests/tests_pytorch/results-${{ runner.os }}-torch${{ matrix.pytorch-version }}.xml if: failure() - name: Statistics if: success() + working-directory: tests/tests_pytorch run: | coverage report coverage xml @@ -91,7 +91,7 @@ jobs: continue-on-error: true with: token: ${{ secrets.CODECOV_TOKEN }} - file: coverage.xml + file: tests/tests_pytorch/coverage.xml flags: cpu,pytest,torch${{ matrix.pytorch-version }} name: CPU-coverage fail_ci_if_error: false diff --git a/.github/workflows/ci_test-full.yml b/.github/workflows/ci_test-full.yml index 469edc45fbe42..01ea7b7042645 100644 --- a/.github/workflows/ci_test-full.yml +++ b/.github/workflows/ci_test-full.yml @@ -122,17 +122,16 @@ jobs: - name: Sanity check run: python requirements/check-avail-extras.py - - name: Testing - run: | - # NOTE: do not include coverage report here, see: https://github.com/nedbat/coveragepy/issues/1003 - coverage run --source pytorch_lightning -m pytest tests -v --durations=50 --junitxml=junit/test-results-${{ runner.os }}-py${{ matrix.python-version }}-${{ matrix.requires }}-${{ matrix.release }}.xml + - name: Testing PyTorch + working-directory: tests/tests_pytorch + # NOTE: do not include coverage report here, see: https://github.com/nedbat/coveragepy/issues/1003 + run: coverage run --source pytorch_lightning -m pytest -v --durations=50 --junitxml=results-${{ runner.os }}-py${{ matrix.python-version }}-${{ matrix.requires }}-${{ matrix.release }}.xml - name: Upload pytest results uses: actions/upload-artifact@v2 with: - name: pytest-results-${{ runner.os }}-py${{ matrix.python-version }}-${{ matrix.requires }}-${{ matrix.release }} - path: junit/test-results-${{ runner.os }}-py${{ matrix.python-version }}-${{ matrix.requires }}-${{ matrix.release }}.xml - if-no-files-found: error + name: unittest-results-${{ runner.os }}-py${{ matrix.python-version }}-${{ matrix.requires }}-${{ matrix.release }} + path: tests/tests_pytorch/results-${{ runner.os }}-py${{ matrix.python-version }}-${{ matrix.requires }}-${{ matrix.release }}.xml if: failure() - name: Prepare Examples @@ -147,6 +146,7 @@ jobs: - name: Statistics if: success() + working-directory: tests/tests_pytorch run: | coverage report coverage xml @@ -158,7 +158,7 @@ jobs: continue-on-error: true with: token: ${{ secrets.CODECOV_TOKEN }} - file: coverage.xml + file: tests/tests_pytorch/coverage.xml flags: cpu,pytest,python${{ matrix.python-version }} name: CPU-coverage fail_ci_if_error: false diff --git a/.github/workflows/ci_test-slow.yml b/.github/workflows/ci_test-slow.yml index 0f9728b9dc80b..e45bac284d7df 100644 --- a/.github/workflows/ci_test-slow.yml +++ b/.github/workflows/ci_test-slow.yml @@ -53,22 +53,22 @@ jobs: pip list shell: bash - - name: Tests - run: | - coverage run --source pytorch_lightning -m pytest tests -v --junitxml=junit/test-results-${{ runner.os }}-py${{ matrix.python-version }}.xml + - name: Testing PyTorch + working-directory: tests/tests_pytorch + run: coverage run --source pytorch_lightning -m pytest -v --junitxml=results-${{ runner.os }}-py${{ matrix.python-version }}.xml env: PL_RUN_SLOW_TESTS: 1 - name: Upload pytest test results uses: actions/upload-artifact@v2 with: - name: pytest-results-${{ runner.os }}-py${{ matrix.python-version }} - path: junit/test-results-${{ runner.os }}-py${{ matrix.python-version }}.xml - if-no-files-found: error + name: unittest-results-${{ runner.os }}-py${{ matrix.python-version }} + path: tests/tests_pytorch/results-${{ runner.os }}-py${{ matrix.python-version }}.xml if: failure() - name: Statistics if: success() + working-directory: tests/tests_pytorch run: | coverage report coverage xml @@ -80,7 +80,7 @@ jobs: continue-on-error: true with: token: ${{ secrets.CODECOV_TOKEN }} - file: coverage.xml + file: tests/tests_pytorch/coverage.xml flags: cpu,pytest,torch${{ matrix.pytorch-version }} name: CPU-coverage fail_ci_if_error: false diff --git a/.github/workflows/code-checks.yml b/.github/workflows/code-checks.yml index 172807a286898..ef1ff0215dd21 100644 --- a/.github/workflows/code-checks.yml +++ b/.github/workflows/code-checks.yml @@ -36,6 +36,6 @@ jobs: pip install '.[dev]' pip list - - name: Type check - working-directory: ./src - run: mypy -p pytorch_lightning --install-types --non-interactive --config-file ../pyproject.toml + - name: Type check PyTorch + working-directory: src/pytorch_lightning + run: mypy . --install-types --non-interactive --config-file ../../pyproject.toml diff --git a/.github/workflows/legacy-checkpoints.yml b/.github/workflows/legacy-checkpoints.yml index 6f9cb05a5c39c..ffe65663690f3 100644 --- a/.github/workflows/legacy-checkpoints.yml +++ b/.github/workflows/legacy-checkpoints.yml @@ -29,12 +29,12 @@ jobs: - name: Generate checkpoint run: | while IFS= read -r line; do - bash legacy/generate_checkpoints.sh $line - done <<< $(cat legacy/back-compatible-versions.txt) + bash tests/legacy/generate_checkpoints.sh $line + done <<< $(cat tests/legacy/back-compatible-versions.txt) - name: Push files to S3 - working-directory: ./legacy + working-directory: ./tests/legacy run: | - aws s3 sync legacy/checkpoints/ s3://pl-public-data/legacy/checkpoints/ + aws s3 sync checkpoints/ s3://pl-public-data/legacy/checkpoints/ zip -r checkpoints.zip checkpoints aws s3 cp checkpoints.zip s3://pl-public-data/legacy/ --acl public-read diff --git a/.github/workflows/release-pypi.yml b/.github/workflows/release-pypi.yml index d7398e8e142e2..eac219281b52f 100644 --- a/.github/workflows/release-pypi.yml +++ b/.github/workflows/release-pypi.yml @@ -123,8 +123,9 @@ jobs: path: dist - name: Pull files from S3 + working-directory: ./tests/legacy run: | - aws s3 cp --recursive s3://pl-public-data/legacy/checkpoints/ legacy/checkpoints/ # --acl public-read + aws s3 cp --recursive s3://pl-public-data/legacy/checkpoints/ checkpoints/ # --acl public-read ls -l legacy/checkpoints/ - name: Generate checkpoint @@ -137,7 +138,7 @@ jobs: bash legacy/generate_checkpoints.sh $pl_ver - name: Push files to S3 - working-directory: ./legacy + working-directory: ./tests/legacy run: | aws s3 sync legacy/checkpoints/ s3://pl-public-data/legacy/checkpoints/ zip -r checkpoints.zip checkpoints diff --git a/dockers/tpu-tests/tpu_test_cases.jsonnet b/dockers/tpu-tests/tpu_test_cases.jsonnet index 8e04db27e5da2..f9a508236e2d2 100644 --- a/dockers/tpu-tests/tpu_test_cases.jsonnet +++ b/dockers/tpu-tests/tpu_test_cases.jsonnet @@ -32,13 +32,13 @@ local tputests = base.BaseTest { pip install -e . echo $KUBE_GOOGLE_CLOUD_TPU_ENDPOINTS export XRT_TPU_CONFIG="tpu_worker;0;${KUBE_GOOGLE_CLOUD_TPU_ENDPOINTS:7}" + cd tests/tests_pytorch # TODO (@kaushikb11): Add device stats tests here coverage run --source=pytorch_lightning -m pytest -v --capture=no \ - tests/strategies/test_tpu_spawn.py \ - tests/profiler/test_xla_profiler.py \ - src/pytorch_lightning/utilities/xla_device.py \ - tests/accelerators/test_tpu.py \ - tests/models/test_tpu.py + strategies/test_tpu_spawn.py \ + profiler/test_xla_profiler.py \ + accelerators/test_tpu.py \ + models/test_tpu.py test_exit_code=$? echo "\n||| END PYTEST LOGS |||\n" coverage xml diff --git a/pyproject.toml b/pyproject.toml index 7b2e8cc873e85..4b9f45068e089 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,10 +7,9 @@ requires = [ [tool.isort] known_first_party = [ - "docs", "pl_examples", "pytorch_lightning", - "tests", + "tests_pytorch", ] profile = "black" line_length = 120 diff --git a/src/pytorch_lightning/demos/mnist_datamodule.py b/src/pytorch_lightning/demos/mnist_datamodule.py index fc8a8bb2e9c70..fac70a378f23f 100644 --- a/src/pytorch_lightning/demos/mnist_datamodule.py +++ b/src/pytorch_lightning/demos/mnist_datamodule.py @@ -35,7 +35,7 @@ class _MNIST(Dataset): - """Carbon copy of ``unittests_pl.helpers.datasets.MNIST``. + """Carbon copy of ``tests_pytorch.helpers.datasets.MNIST``. We cannot import the tests as they are not distributed with the package. See https://github.com/PyTorchLightning/pytorch-lightning/pull/7614#discussion_r671183652 for more context. diff --git a/tests/README.md b/tests/README.md index 606bc799db94f..1527522afdfc4 100644 --- a/tests/README.md +++ b/tests/README.md @@ -41,13 +41,13 @@ This is useful if you do not test against all required dependency versions. **Docker:** Another option is to utilize the [pytorch lightning cuda base docker image](https://hub.docker.com/repository/docker/pytorchlightning/pytorch_lightning/tags?page=1&name=cuda). You can then run: ```bash -python -m pytest src/pytorch_lightning test/unitests_pl -v +python -m pytest src/pytorch_lightning tests/tests_pytorch -v ``` You can also run a single test as follows: ```bash -python -m pytest -v tests/trainer/test_trainer_cli.py::test_default_args +python -m pytest -v tests/tests_pytorch/trainer/test_trainer_cli.py::test_default_args ``` ### Conditional Tests @@ -64,9 +64,9 @@ You can rely on our CI to make sure all these tests pass. There are certain standalone tests, which you can run using: ```bash -PL_RUN_STANDALONE_TESTS=1 python -m pytest -v tests/trainer/ +PL_RUN_STANDALONE_TESTS=1 python -m pytest -v tests/tests_pytorch/trainer/ # or -./tests/standalone_tests.sh tests/trainer +./tests/run_standalone_tests.sh tests/tests_pytorch/trainer/ ``` ## Running Coverage @@ -77,7 +77,7 @@ Make sure to run coverage on a GPU machine with at least 2 GPUs and NVIDIA apex cd pytorch-lightning # generate coverage (coverage is also installed as part of dev dependencies under requirements/devel.txt) -coverage run --source pytorch_lightning -m pytest pytorch_lightning tests pl_examples -v +coverage run --source pytorch_lightning -m pytest src/pytorch_lightning tests/tests_pytorch pl_examples -v # print coverage stats coverage report -m diff --git a/legacy/README.md b/tests/legacy/README.md similarity index 100% rename from legacy/README.md rename to tests/legacy/README.md diff --git a/legacy/back-compatible-versions.txt b/tests/legacy/back-compatible-versions.txt similarity index 100% rename from legacy/back-compatible-versions.txt rename to tests/legacy/back-compatible-versions.txt diff --git a/legacy/checkpoints/.gitkeep b/tests/legacy/checkpoints/.gitkeep similarity index 100% rename from legacy/checkpoints/.gitkeep rename to tests/legacy/checkpoints/.gitkeep diff --git a/legacy/generate_checkpoints.sh b/tests/legacy/generate_checkpoints.sh similarity index 100% rename from legacy/generate_checkpoints.sh rename to tests/legacy/generate_checkpoints.sh diff --git a/legacy/simple_classif_training.py b/tests/legacy/simple_classif_training.py similarity index 100% rename from legacy/simple_classif_training.py rename to tests/legacy/simple_classif_training.py diff --git a/tests/__init__.py b/tests/tests_pytorch/__init__.py similarity index 100% rename from tests/__init__.py rename to tests/tests_pytorch/__init__.py diff --git a/tests/accelerators/__init__.py b/tests/tests_pytorch/accelerators/__init__.py similarity index 100% rename from tests/accelerators/__init__.py rename to tests/tests_pytorch/accelerators/__init__.py diff --git a/tests/accelerators/test_accelerator_connector.py b/tests/tests_pytorch/accelerators/test_accelerator_connector.py similarity index 99% rename from tests/accelerators/test_accelerator_connector.py rename to tests/tests_pytorch/accelerators/test_accelerator_connector.py index e2d10e0b32551..c5480fad089fc 100644 --- a/tests/accelerators/test_accelerator_connector.py +++ b/tests/tests_pytorch/accelerators/test_accelerator_connector.py @@ -45,7 +45,7 @@ SingleDeviceStrategy, ) from pytorch_lightning.utilities.exceptions import MisconfigurationException -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.runif import RunIf def test_accelerator_choice_cpu(tmpdir): diff --git a/tests/accelerators/test_accelerator_registry.py b/tests/tests_pytorch/accelerators/test_accelerator_registry.py similarity index 100% rename from tests/accelerators/test_accelerator_registry.py rename to tests/tests_pytorch/accelerators/test_accelerator_registry.py diff --git a/tests/accelerators/test_common.py b/tests/tests_pytorch/accelerators/test_common.py similarity index 100% rename from tests/accelerators/test_common.py rename to tests/tests_pytorch/accelerators/test_common.py diff --git a/tests/accelerators/test_cpu.py b/tests/tests_pytorch/accelerators/test_cpu.py similarity index 100% rename from tests/accelerators/test_cpu.py rename to tests/tests_pytorch/accelerators/test_cpu.py diff --git a/tests/accelerators/test_gpu.py b/tests/tests_pytorch/accelerators/test_gpu.py similarity index 98% rename from tests/accelerators/test_gpu.py rename to tests/tests_pytorch/accelerators/test_gpu.py index 2a2e6ea1759f2..f6334780d75a5 100644 --- a/tests/accelerators/test_gpu.py +++ b/tests/tests_pytorch/accelerators/test_gpu.py @@ -20,7 +20,7 @@ from pytorch_lightning.accelerators import GPUAccelerator from pytorch_lightning.accelerators.gpu import get_nvidia_gpu_stats from pytorch_lightning.demos.boring_classes import BoringModel -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.runif import RunIf @RunIf(min_cuda_gpus=1) diff --git a/tests/accelerators/test_hpu.py b/tests/tests_pytorch/accelerators/test_hpu.py similarity index 97% rename from tests/accelerators/test_hpu.py rename to tests/tests_pytorch/accelerators/test_hpu.py index 45c1ea2350b28..d89ce67e5fb6b 100644 --- a/tests/accelerators/test_hpu.py +++ b/tests/tests_pytorch/accelerators/test_hpu.py @@ -23,9 +23,9 @@ from pytorch_lightning.strategies.single_hpu import SingleHPUStrategy from pytorch_lightning.utilities import _HPU_AVAILABLE from pytorch_lightning.utilities.exceptions import MisconfigurationException -from tests.helpers.datamodules import ClassifDataModule -from tests.helpers.runif import RunIf -from tests.helpers.simple_models import ClassificationModel +from tests_pytorch.helpers.datamodules import ClassifDataModule +from tests_pytorch.helpers.runif import RunIf +from tests_pytorch.helpers.simple_models import ClassificationModel @RunIf(hpu=True) diff --git a/tests/accelerators/test_ipu.py b/tests/tests_pytorch/accelerators/test_ipu.py similarity index 99% rename from tests/accelerators/test_ipu.py rename to tests/tests_pytorch/accelerators/test_ipu.py index 1fe388d13ab3e..97f374a40d6c3 100644 --- a/tests/accelerators/test_ipu.py +++ b/tests/tests_pytorch/accelerators/test_ipu.py @@ -30,9 +30,9 @@ from pytorch_lightning.trainer.supporters import CombinedLoader from pytorch_lightning.utilities import _IPU_AVAILABLE from pytorch_lightning.utilities.exceptions import MisconfigurationException -from tests.helpers.datamodules import ClassifDataModule -from tests.helpers.runif import RunIf -from tests.helpers.simple_models import ClassificationModel +from tests_pytorch.helpers.datamodules import ClassifDataModule +from tests_pytorch.helpers.runif import RunIf +from tests_pytorch.helpers.simple_models import ClassificationModel if _IPU_AVAILABLE: import poptorch diff --git a/tests/accelerators/test_tpu.py b/tests/tests_pytorch/accelerators/test_tpu.py similarity index 99% rename from tests/accelerators/test_tpu.py rename to tests/tests_pytorch/accelerators/test_tpu.py index 9c41d6812529e..8e0eb52a9a424 100644 --- a/tests/accelerators/test_tpu.py +++ b/tests/tests_pytorch/accelerators/test_tpu.py @@ -27,8 +27,8 @@ from pytorch_lightning.plugins import PrecisionPlugin, TPUPrecisionPlugin, XLACheckpointIO from pytorch_lightning.strategies import DDPStrategy, TPUSpawnStrategy from pytorch_lightning.utilities import find_shared_parameters -from tests.helpers.runif import RunIf -from tests.helpers.utils import pl_multi_process_test +from tests_pytorch.helpers.runif import RunIf +from tests_pytorch.helpers.utils import pl_multi_process_test class WeightSharingModule(BoringModel): diff --git a/tests/benchmarks/__init__.py b/tests/tests_pytorch/benchmarks/__init__.py similarity index 100% rename from tests/benchmarks/__init__.py rename to tests/tests_pytorch/benchmarks/__init__.py diff --git a/tests/benchmarks/generate_comparison.py b/tests/tests_pytorch/benchmarks/generate_comparison.py similarity index 93% rename from tests/benchmarks/generate_comparison.py rename to tests/tests_pytorch/benchmarks/generate_comparison.py index 984ffdd19c163..6c92eb795e63c 100644 --- a/tests/benchmarks/generate_comparison.py +++ b/tests/tests_pytorch/benchmarks/generate_comparison.py @@ -13,8 +13,8 @@ # limitations under the License. import os -from tests.benchmarks.test_basic_parity import measure_loops -from tests.helpers.advanced_models import ParityModuleMNIST, ParityModuleRNN +from tests_pytorch.benchmarks.test_basic_parity import measure_loops +from tests_pytorch.helpers.advanced_models import ParityModuleMNIST, ParityModuleRNN NUM_EPOCHS = 20 NUM_RUNS = 50 diff --git a/tests/benchmarks/test_basic_parity.py b/tests/tests_pytorch/benchmarks/test_basic_parity.py similarity index 98% rename from tests/benchmarks/test_basic_parity.py rename to tests/tests_pytorch/benchmarks/test_basic_parity.py index d893262148561..16a1dc0d1a2d7 100644 --- a/tests/benchmarks/test_basic_parity.py +++ b/tests/tests_pytorch/benchmarks/test_basic_parity.py @@ -21,7 +21,7 @@ from tqdm import tqdm from pytorch_lightning import LightningModule, seed_everything, Trainer -from tests.helpers.advanced_models import ParityModuleCIFAR, ParityModuleMNIST, ParityModuleRNN +from tests_pytorch.helpers.advanced_models import ParityModuleCIFAR, ParityModuleMNIST, ParityModuleRNN _EXTEND_BENCHMARKS = os.getenv("PL_RUNNING_BENCHMARKS", "0") == "1" _SHORT_BENCHMARKS = not _EXTEND_BENCHMARKS diff --git a/tests/benchmarks/test_sharded_parity.py b/tests/tests_pytorch/benchmarks/test_sharded_parity.py similarity index 99% rename from tests/benchmarks/test_sharded_parity.py rename to tests/tests_pytorch/benchmarks/test_sharded_parity.py index a40e1e8bb8455..b02428758f169 100644 --- a/tests/benchmarks/test_sharded_parity.py +++ b/tests/tests_pytorch/benchmarks/test_sharded_parity.py @@ -21,7 +21,7 @@ from pytorch_lightning import seed_everything, Trainer from pytorch_lightning.demos.boring_classes import BoringModel, RandomDataset from pytorch_lightning.strategies import DDPSpawnShardedStrategy -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.runif import RunIf class SeedTrainLoaderModel(BoringModel): diff --git a/tests/benchmarks/test_sync_batchnorm_parity.py b/tests/tests_pytorch/benchmarks/test_sync_batchnorm_parity.py similarity index 98% rename from tests/benchmarks/test_sync_batchnorm_parity.py rename to tests/tests_pytorch/benchmarks/test_sync_batchnorm_parity.py index f80a2a1a67eb2..187a46671528b 100644 --- a/tests/benchmarks/test_sync_batchnorm_parity.py +++ b/tests/tests_pytorch/benchmarks/test_sync_batchnorm_parity.py @@ -17,7 +17,7 @@ from torch.utils.data import DataLoader, DistributedSampler from pytorch_lightning import LightningModule, seed_everything, Trainer -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.runif import RunIf class SyncBNModule(LightningModule): diff --git a/tests/callbacks/__init__.py b/tests/tests_pytorch/callbacks/__init__.py similarity index 100% rename from tests/callbacks/__init__.py rename to tests/tests_pytorch/callbacks/__init__.py diff --git a/tests/callbacks/test_callback_hook_outputs.py b/tests/tests_pytorch/callbacks/test_callback_hook_outputs.py similarity index 100% rename from tests/callbacks/test_callback_hook_outputs.py rename to tests/tests_pytorch/callbacks/test_callback_hook_outputs.py diff --git a/tests/callbacks/test_callbacks.py b/tests/tests_pytorch/callbacks/test_callbacks.py similarity index 99% rename from tests/callbacks/test_callbacks.py rename to tests/tests_pytorch/callbacks/test_callbacks.py index 9c58768bd2b09..a6b64d87fdec6 100644 --- a/tests/callbacks/test_callbacks.py +++ b/tests/tests_pytorch/callbacks/test_callbacks.py @@ -20,7 +20,7 @@ from pytorch_lightning import Callback, Trainer from pytorch_lightning.callbacks import ModelCheckpoint from pytorch_lightning.demos.boring_classes import BoringModel -from tests.helpers.utils import no_warning_call +from tests_pytorch.helpers.utils import no_warning_call def test_callbacks_configured_in_model(tmpdir): diff --git a/tests/callbacks/test_device_stats_monitor.py b/tests/tests_pytorch/callbacks/test_device_stats_monitor.py similarity index 99% rename from tests/callbacks/test_device_stats_monitor.py rename to tests/tests_pytorch/callbacks/test_device_stats_monitor.py index 0bf1c71f9150d..0da6e5c32b9c4 100644 --- a/tests/callbacks/test_device_stats_monitor.py +++ b/tests/tests_pytorch/callbacks/test_device_stats_monitor.py @@ -26,7 +26,7 @@ from pytorch_lightning.loggers import CSVLogger from pytorch_lightning.utilities.exceptions import MisconfigurationException from pytorch_lightning.utilities.rank_zero import rank_zero_only -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.runif import RunIf @RunIf(min_cuda_gpus=1) diff --git a/tests/callbacks/test_early_stopping.py b/tests/tests_pytorch/callbacks/test_early_stopping.py similarity index 98% rename from tests/callbacks/test_early_stopping.py rename to tests/tests_pytorch/callbacks/test_early_stopping.py index dc6933f0f0c05..f9e55e059d226 100644 --- a/tests/callbacks/test_early_stopping.py +++ b/tests/tests_pytorch/callbacks/test_early_stopping.py @@ -27,9 +27,9 @@ from pytorch_lightning.callbacks import EarlyStopping, ModelCheckpoint from pytorch_lightning.demos.boring_classes import BoringModel from pytorch_lightning.utilities.exceptions import MisconfigurationException -from tests.helpers.datamodules import ClassifDataModule -from tests.helpers.runif import RunIf -from tests.helpers.simple_models import ClassificationModel +from tests_pytorch.helpers.datamodules import ClassifDataModule +from tests_pytorch.helpers.runif import RunIf +from tests_pytorch.helpers.simple_models import ClassificationModel _logger = logging.getLogger(__name__) diff --git a/tests/callbacks/test_finetuning_callback.py b/tests/tests_pytorch/callbacks/test_finetuning_callback.py similarity index 100% rename from tests/callbacks/test_finetuning_callback.py rename to tests/tests_pytorch/callbacks/test_finetuning_callback.py diff --git a/tests/callbacks/test_gradient_accumulation_scheduler.py b/tests/tests_pytorch/callbacks/test_gradient_accumulation_scheduler.py similarity index 100% rename from tests/callbacks/test_gradient_accumulation_scheduler.py rename to tests/tests_pytorch/callbacks/test_gradient_accumulation_scheduler.py diff --git a/tests/callbacks/test_lambda_function.py b/tests/tests_pytorch/callbacks/test_lambda_function.py similarity index 97% rename from tests/callbacks/test_lambda_function.py rename to tests/tests_pytorch/callbacks/test_lambda_function.py index ee3b58d2de555..df71295566095 100644 --- a/tests/callbacks/test_lambda_function.py +++ b/tests/tests_pytorch/callbacks/test_lambda_function.py @@ -18,7 +18,7 @@ from pytorch_lightning import seed_everything, Trainer from pytorch_lightning.callbacks import Callback, LambdaCallback from pytorch_lightning.demos.boring_classes import BoringModel -from tests.models.test_hooks import get_members +from tests_pytorch.models.test_hooks import get_members def test_lambda_call(tmpdir): diff --git a/tests/callbacks/test_lr_monitor.py b/tests/tests_pytorch/callbacks/test_lr_monitor.py similarity index 99% rename from tests/callbacks/test_lr_monitor.py rename to tests/tests_pytorch/callbacks/test_lr_monitor.py index 9fca0629ed731..f80aeb12a2aa2 100644 --- a/tests/callbacks/test_lr_monitor.py +++ b/tests/tests_pytorch/callbacks/test_lr_monitor.py @@ -15,15 +15,15 @@ import torch from torch import optim -import tests.helpers.utils as tutils +import tests_pytorch.helpers.utils as tutils from pytorch_lightning import Trainer from pytorch_lightning.callbacks import LearningRateMonitor from pytorch_lightning.callbacks.callback import Callback from pytorch_lightning.callbacks.finetuning import BackboneFinetuning from pytorch_lightning.demos.boring_classes import BoringModel from pytorch_lightning.utilities.exceptions import MisconfigurationException -from tests.helpers.datamodules import ClassifDataModule -from tests.helpers.simple_models import ClassificationModel +from tests_pytorch.helpers.datamodules import ClassifDataModule +from tests_pytorch.helpers.simple_models import ClassificationModel def test_lr_monitor_single_lr(tmpdir): diff --git a/tests/callbacks/test_model_summary.py b/tests/tests_pytorch/callbacks/test_model_summary.py similarity index 100% rename from tests/callbacks/test_model_summary.py rename to tests/tests_pytorch/callbacks/test_model_summary.py diff --git a/tests/callbacks/test_prediction_writer.py b/tests/tests_pytorch/callbacks/test_prediction_writer.py similarity index 99% rename from tests/callbacks/test_prediction_writer.py rename to tests/tests_pytorch/callbacks/test_prediction_writer.py index 1bdf97e8e5f52..3bfba41a39015 100644 --- a/tests/callbacks/test_prediction_writer.py +++ b/tests/tests_pytorch/callbacks/test_prediction_writer.py @@ -22,7 +22,7 @@ from pytorch_lightning.demos.boring_classes import BoringModel, RandomDataset from pytorch_lightning.trainer.supporters import CombinedLoader from pytorch_lightning.utilities.exceptions import MisconfigurationException -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.runif import RunIf class DummyPredictionWriter(BasePredictionWriter): diff --git a/tests/callbacks/test_pruning.py b/tests/tests_pytorch/callbacks/test_pruning.py similarity index 99% rename from tests/callbacks/test_pruning.py rename to tests/tests_pytorch/callbacks/test_pruning.py index 1d0ce3a901910..ccadaca5f8c75 100644 --- a/tests/callbacks/test_pruning.py +++ b/tests/tests_pytorch/callbacks/test_pruning.py @@ -26,7 +26,7 @@ from pytorch_lightning.callbacks import ModelCheckpoint, ModelPruning from pytorch_lightning.demos.boring_classes import BoringModel from pytorch_lightning.utilities.exceptions import MisconfigurationException -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.runif import RunIf class TestModel(BoringModel): diff --git a/tests/callbacks/test_quantization.py b/tests/tests_pytorch/callbacks/test_quantization.py similarity index 98% rename from tests/callbacks/test_quantization.py rename to tests/tests_pytorch/callbacks/test_quantization.py index 6599d87933711..2970b20617d4e 100644 --- a/tests/callbacks/test_quantization.py +++ b/tests/tests_pytorch/callbacks/test_quantization.py @@ -25,9 +25,9 @@ from pytorch_lightning.demos.boring_classes import RandomDataset from pytorch_lightning.utilities.exceptions import MisconfigurationException from pytorch_lightning.utilities.memory import get_model_size_mb -from tests.helpers.datamodules import RegressDataModule -from tests.helpers.runif import RunIf -from tests.helpers.simple_models import RegressionModel +from tests_pytorch.helpers.datamodules import RegressDataModule +from tests_pytorch.helpers.runif import RunIf +from tests_pytorch.helpers.simple_models import RegressionModel @pytest.mark.parametrize("observe", ["average", "histogram"]) diff --git a/tests/callbacks/test_rich_model_summary.py b/tests/tests_pytorch/callbacks/test_rich_model_summary.py similarity index 98% rename from tests/callbacks/test_rich_model_summary.py rename to tests/tests_pytorch/callbacks/test_rich_model_summary.py index 1ba96aa3f3a45..6ce7fba85b535 100644 --- a/tests/callbacks/test_rich_model_summary.py +++ b/tests/tests_pytorch/callbacks/test_rich_model_summary.py @@ -21,7 +21,7 @@ from pytorch_lightning.callbacks import RichModelSummary, RichProgressBar from pytorch_lightning.demos.boring_classes import BoringModel from pytorch_lightning.utilities.model_summary import summarize -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.runif import RunIf @RunIf(rich=True) diff --git a/tests/callbacks/test_rich_progress_bar.py b/tests/tests_pytorch/callbacks/test_rich_progress_bar.py similarity index 99% rename from tests/callbacks/test_rich_progress_bar.py rename to tests/tests_pytorch/callbacks/test_rich_progress_bar.py index 1ae99d4e504ae..e9374f8ea4be1 100644 --- a/tests/callbacks/test_rich_progress_bar.py +++ b/tests/tests_pytorch/callbacks/test_rich_progress_bar.py @@ -22,8 +22,8 @@ from pytorch_lightning.callbacks import ProgressBarBase, RichProgressBar from pytorch_lightning.callbacks.progress.rich_progress import RichProgressBarTheme from pytorch_lightning.demos.boring_classes import BoringModel, RandomDataset -from tests.helpers.datasets import RandomIterableDataset -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.datasets import RandomIterableDataset +from tests_pytorch.helpers.runif import RunIf @RunIf(rich=True) diff --git a/tests/callbacks/test_stochastic_weight_avg.py b/tests/tests_pytorch/callbacks/test_stochastic_weight_avg.py similarity index 98% rename from tests/callbacks/test_stochastic_weight_avg.py rename to tests/tests_pytorch/callbacks/test_stochastic_weight_avg.py index 49379384b8a5a..8ffefb9bda3f8 100644 --- a/tests/callbacks/test_stochastic_weight_avg.py +++ b/tests/tests_pytorch/callbacks/test_stochastic_weight_avg.py @@ -25,8 +25,8 @@ from pytorch_lightning.demos.boring_classes import BoringModel, RandomDataset from pytorch_lightning.strategies import DDPSpawnStrategy, Strategy from pytorch_lightning.utilities.exceptions import MisconfigurationException -from tests.helpers.datasets import RandomIterableDataset -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.datasets import RandomIterableDataset +from tests_pytorch.helpers.runif import RunIf class SwaTestModel(BoringModel): diff --git a/tests/callbacks/test_timer.py b/tests/tests_pytorch/callbacks/test_timer.py similarity index 99% rename from tests/callbacks/test_timer.py rename to tests/tests_pytorch/callbacks/test_timer.py index 3404179f1391b..3b7e951ef723d 100644 --- a/tests/callbacks/test_timer.py +++ b/tests/tests_pytorch/callbacks/test_timer.py @@ -23,7 +23,7 @@ from pytorch_lightning.callbacks.timer import Timer from pytorch_lightning.demos.boring_classes import BoringModel from pytorch_lightning.utilities.exceptions import MisconfigurationException -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.runif import RunIf def test_trainer_flag(caplog): diff --git a/tests/callbacks/test_tqdm_progress_bar.py b/tests/tests_pytorch/callbacks/test_tqdm_progress_bar.py similarity index 99% rename from tests/callbacks/test_tqdm_progress_bar.py rename to tests/tests_pytorch/callbacks/test_tqdm_progress_bar.py index 68253d313df97..43e68011dbc56 100644 --- a/tests/callbacks/test_tqdm_progress_bar.py +++ b/tests/tests_pytorch/callbacks/test_tqdm_progress_bar.py @@ -30,7 +30,7 @@ from pytorch_lightning.core.module import LightningModule from pytorch_lightning.demos.boring_classes import BoringModel, RandomDataset from pytorch_lightning.utilities.exceptions import MisconfigurationException -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.runif import RunIf class MockTqdm(Tqdm): diff --git a/tests/checkpointing/__init__.py b/tests/tests_pytorch/checkpointing/__init__.py similarity index 100% rename from tests/checkpointing/__init__.py rename to tests/tests_pytorch/checkpointing/__init__.py diff --git a/tests/checkpointing/test_checkpoint_callback_frequency.py b/tests/tests_pytorch/checkpointing/test_checkpoint_callback_frequency.py similarity index 99% rename from tests/checkpointing/test_checkpoint_callback_frequency.py rename to tests/tests_pytorch/checkpointing/test_checkpoint_callback_frequency.py index 85ab0b94628a3..8d582117591b0 100644 --- a/tests/checkpointing/test_checkpoint_callback_frequency.py +++ b/tests/tests_pytorch/checkpointing/test_checkpoint_callback_frequency.py @@ -19,7 +19,7 @@ from pytorch_lightning import callbacks, Trainer from pytorch_lightning.demos.boring_classes import BoringModel -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.runif import RunIf def test_disabled_checkpointing(tmpdir): diff --git a/tests/checkpointing/test_legacy_checkpoints.py b/tests/tests_pytorch/checkpointing/test_legacy_checkpoints.py similarity index 98% rename from tests/checkpointing/test_legacy_checkpoints.py rename to tests/tests_pytorch/checkpointing/test_legacy_checkpoints.py index ac2806cbf3811..316381e61d4d8 100644 --- a/tests/checkpointing/test_legacy_checkpoints.py +++ b/tests/tests_pytorch/checkpointing/test_legacy_checkpoints.py @@ -22,7 +22,7 @@ import pytorch_lightning as pl from pytorch_lightning import Callback, Trainer -from tests import _PATH_LEGACY, _PROJECT_ROOT +from tests_pytorch import _PATH_LEGACY, _PROJECT_ROOT LEGACY_CHECKPOINTS_PATH = os.path.join(_PATH_LEGACY, "checkpoints") CHECKPOINT_EXTENSION = ".ckpt" diff --git a/tests/checkpointing/test_model_checkpoint.py b/tests/tests_pytorch/checkpointing/test_model_checkpoint.py similarity index 99% rename from tests/checkpointing/test_model_checkpoint.py rename to tests/tests_pytorch/checkpointing/test_model_checkpoint.py index f7b89cb211e24..60ec4ec0f23de 100644 --- a/tests/checkpointing/test_model_checkpoint.py +++ b/tests/tests_pytorch/checkpointing/test_model_checkpoint.py @@ -31,7 +31,7 @@ from torch import optim import pytorch_lightning as pl -import tests.helpers.utils as tutils +import tests_pytorch.helpers.utils as tutils from pytorch_lightning import seed_everything, Trainer from pytorch_lightning.callbacks import ModelCheckpoint from pytorch_lightning.demos.boring_classes import BoringModel @@ -39,7 +39,7 @@ from pytorch_lightning.utilities.cloud_io import load as pl_load from pytorch_lightning.utilities.exceptions import MisconfigurationException from pytorch_lightning.utilities.imports import _OMEGACONF_AVAILABLE -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.runif import RunIf if _OMEGACONF_AVAILABLE: from omegaconf import Container, OmegaConf diff --git a/tests/checkpointing/test_torch_saving.py b/tests/tests_pytorch/checkpointing/test_torch_saving.py similarity index 97% rename from tests/checkpointing/test_torch_saving.py rename to tests/tests_pytorch/checkpointing/test_torch_saving.py index 84db5ffdb9888..3439ccc91ff90 100644 --- a/tests/checkpointing/test_torch_saving.py +++ b/tests/tests_pytorch/checkpointing/test_torch_saving.py @@ -17,7 +17,7 @@ from pytorch_lightning import Trainer from pytorch_lightning.demos.boring_classes import BoringModel -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.runif import RunIf def test_model_torch_save(tmpdir): diff --git a/tests/checkpointing/test_trainer_checkpoint.py b/tests/tests_pytorch/checkpointing/test_trainer_checkpoint.py similarity index 100% rename from tests/checkpointing/test_trainer_checkpoint.py rename to tests/tests_pytorch/checkpointing/test_trainer_checkpoint.py diff --git a/tests/conftest.py b/tests/tests_pytorch/conftest.py similarity index 99% rename from tests/conftest.py rename to tests/tests_pytorch/conftest.py index fac9c6de26297..c5c15cd6f5619 100644 --- a/tests/conftest.py +++ b/tests/tests_pytorch/conftest.py @@ -24,7 +24,7 @@ from pytorch_lightning.plugins.environments.lightning_environment import find_free_network_port from pytorch_lightning.trainer.connectors.signal_connector import SignalConnector from pytorch_lightning.utilities.imports import _IS_WINDOWS -from tests import _PATH_DATASETS +from tests_pytorch import _PATH_DATASETS @pytest.fixture(scope="session") diff --git a/tests/core/__init__.py b/tests/tests_pytorch/core/__init__.py similarity index 100% rename from tests/core/__init__.py rename to tests/tests_pytorch/core/__init__.py diff --git a/tests/core/test_datamodules.py b/tests/tests_pytorch/core/test_datamodules.py similarity index 98% rename from tests/core/test_datamodules.py rename to tests/tests_pytorch/core/test_datamodules.py index 9f946554dc3fa..2c6625ac0772d 100644 --- a/tests/core/test_datamodules.py +++ b/tests/tests_pytorch/core/test_datamodules.py @@ -28,10 +28,10 @@ from pytorch_lightning.trainer.states import TrainerFn from pytorch_lightning.utilities import _OMEGACONF_AVAILABLE, AttributeDict from pytorch_lightning.utilities.exceptions import MisconfigurationException -from tests.helpers.datamodules import ClassifDataModule -from tests.helpers.runif import RunIf -from tests.helpers.simple_models import ClassificationModel -from tests.helpers.utils import reset_seed +from tests_pytorch.helpers.datamodules import ClassifDataModule +from tests_pytorch.helpers.runif import RunIf +from tests_pytorch.helpers.simple_models import ClassificationModel +from tests_pytorch.helpers.utils import reset_seed if _OMEGACONF_AVAILABLE: from omegaconf import OmegaConf diff --git a/tests/core/test_lightning_module.py b/tests/tests_pytorch/core/test_lightning_module.py similarity index 99% rename from tests/core/test_lightning_module.py rename to tests/tests_pytorch/core/test_lightning_module.py index ce0ea21ea2cb8..639863f4c1c72 100644 --- a/tests/core/test_lightning_module.py +++ b/tests/tests_pytorch/core/test_lightning_module.py @@ -24,7 +24,7 @@ from pytorch_lightning.loggers import TensorBoardLogger from pytorch_lightning.utilities.exceptions import MisconfigurationException from pytorch_lightning.utilities.imports import _TORCH_GREATER_EQUAL_1_11 -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.runif import RunIf def test_lightning_module_not_abstract(): diff --git a/tests/core/test_lightning_optimizer.py b/tests/tests_pytorch/core/test_lightning_optimizer.py similarity index 100% rename from tests/core/test_lightning_optimizer.py rename to tests/tests_pytorch/core/test_lightning_optimizer.py diff --git a/tests/core/test_metric_result_integration.py b/tests/tests_pytorch/core/test_metric_result_integration.py similarity index 99% rename from tests/core/test_metric_result_integration.py rename to tests/tests_pytorch/core/test_metric_result_integration.py index e708c126e8ff1..78e2d6fa2541b 100644 --- a/tests/core/test_metric_result_integration.py +++ b/tests/tests_pytorch/core/test_metric_result_integration.py @@ -24,7 +24,7 @@ from torch.nn import ModuleDict, ModuleList from torchmetrics import Metric, MetricCollection -import tests.helpers.utils as tutils +import tests_pytorch.helpers.utils as tutils from pytorch_lightning import Trainer from pytorch_lightning.callbacks import ModelCheckpoint from pytorch_lightning.demos.boring_classes import BoringModel @@ -34,7 +34,7 @@ _ResultMetric, _Sync, ) -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.runif import RunIf class DummyMetric(Metric): diff --git a/tests/core/test_results.py b/tests/tests_pytorch/core/test_results.py similarity index 94% rename from tests/core/test_results.py rename to tests/tests_pytorch/core/test_results.py index a39ce51788ff9..dc4c2ac065f2d 100644 --- a/tests/core/test_results.py +++ b/tests/tests_pytorch/core/test_results.py @@ -15,10 +15,10 @@ import torch.distributed as dist import torch.multiprocessing as mp -import tests.helpers.utils as tutils +import tests_pytorch.helpers.utils as tutils from pytorch_lightning.trainer.connectors.logger_connector.result import _Sync from pytorch_lightning.utilities.distributed import sync_ddp_if_available -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.runif import RunIf def _setup_ddp(rank, worldsize): diff --git a/tests/deprecated_api/__init__.py b/tests/tests_pytorch/deprecated_api/__init__.py similarity index 95% rename from tests/deprecated_api/__init__.py rename to tests/tests_pytorch/deprecated_api/__init__.py index 5480f398da341..611637d543a7e 100644 --- a/tests/deprecated_api/__init__.py +++ b/tests/tests_pytorch/deprecated_api/__init__.py @@ -16,7 +16,7 @@ from contextlib import contextmanager from typing import Optional -from tests.helpers.utils import no_warning_call +from tests_pytorch.helpers.utils import no_warning_call def _soft_unimport_module(str_module): diff --git a/tests/deprecated_api/test_remove_1-7.py b/tests/tests_pytorch/deprecated_api/test_remove_1-7.py similarity index 98% rename from tests/deprecated_api/test_remove_1-7.py rename to tests/tests_pytorch/deprecated_api/test_remove_1-7.py index c38903e6ad6bb..55030c14ec5b3 100644 --- a/tests/deprecated_api/test_remove_1-7.py +++ b/tests/tests_pytorch/deprecated_api/test_remove_1-7.py @@ -32,8 +32,8 @@ TorchElasticEnvironment, ) from pytorch_lightning.strategies import SingleDeviceStrategy -from tests.deprecated_api import _soft_unimport_module -from tests.plugins.environments.test_lsf_environment import _make_rankfile +from tests_pytorch.deprecated_api import _soft_unimport_module +from tests_pytorch.plugins.environments.test_lsf_environment import _make_rankfile def test_v1_7_0_on_interrupt(tmpdir): diff --git a/tests/deprecated_api/test_remove_1-8.py b/tests/tests_pytorch/deprecated_api/test_remove_1-8.py similarity index 99% rename from tests/deprecated_api/test_remove_1-8.py rename to tests/tests_pytorch/deprecated_api/test_remove_1-8.py index 441638504f823..54292a7d32013 100644 --- a/tests/deprecated_api/test_remove_1-8.py +++ b/tests/tests_pytorch/deprecated_api/test_remove_1-8.py @@ -48,9 +48,9 @@ from pytorch_lightning.utilities.enums import DeviceType, DistributedType from pytorch_lightning.utilities.imports import _TORCHTEXT_LEGACY from pytorch_lightning.utilities.rank_zero import rank_zero_only, rank_zero_warn -from tests.deprecated_api import no_deprecated_call -from tests.helpers.runif import RunIf -from tests.helpers.torchtext_utils import get_dummy_torchtext_data_iterator +from tests_pytorch.deprecated_api import no_deprecated_call +from tests_pytorch.helpers.runif import RunIf +from tests_pytorch.helpers.torchtext_utils import get_dummy_torchtext_data_iterator def test_v1_8_0_deprecated_distributed_type_enum(): diff --git a/tests/deprecated_api/test_remove_1-9.py b/tests/tests_pytorch/deprecated_api/test_remove_1-9.py similarity index 100% rename from tests/deprecated_api/test_remove_1-9.py rename to tests/tests_pytorch/deprecated_api/test_remove_1-9.py diff --git a/tests/deprecated_api/test_remove_2-0.py b/tests/tests_pytorch/deprecated_api/test_remove_2-0.py similarity index 98% rename from tests/deprecated_api/test_remove_2-0.py rename to tests/tests_pytorch/deprecated_api/test_remove_2-0.py index 0a2729e046613..c54afd0931cff 100644 --- a/tests/deprecated_api/test_remove_2-0.py +++ b/tests/tests_pytorch/deprecated_api/test_remove_2-0.py @@ -19,7 +19,7 @@ import pytorch_lightning from pytorch_lightning import Trainer from pytorch_lightning.demos.boring_classes import BoringModel -from tests.callbacks.test_callbacks import OldStatefulCallback +from tests_pytorch.callbacks.test_callbacks import OldStatefulCallback def test_v2_0_0_deprecated_num_processes(): diff --git a/tests/tests_pytorch/helpers/__init__.py b/tests/tests_pytorch/helpers/__init__.py new file mode 100644 index 0000000000000..3c214ea789497 --- /dev/null +++ b/tests/tests_pytorch/helpers/__init__.py @@ -0,0 +1,7 @@ +from pytorch_lightning.demos.boring_classes import ( # noqa: F401 + BoringDataModule, + BoringModel, + ManualOptimBoringModel, + RandomDataset, +) +from tests_pytorch.helpers.datasets import TrialMNIST # noqa: F401 diff --git a/tests/helpers/advanced_models.py b/tests/tests_pytorch/helpers/advanced_models.py similarity index 98% rename from tests/helpers/advanced_models.py rename to tests/tests_pytorch/helpers/advanced_models.py index ba69c22286408..a305fe04e62d9 100644 --- a/tests/helpers/advanced_models.py +++ b/tests/tests_pytorch/helpers/advanced_models.py @@ -20,8 +20,8 @@ from pytorch_lightning.core.module import LightningModule from pytorch_lightning.utilities.imports import _TORCHVISION_AVAILABLE -from tests import _PATH_DATASETS -from tests.helpers.datasets import AverageDataset, MNIST, TrialMNIST +from tests_pytorch import _PATH_DATASETS +from tests_pytorch.helpers.datasets import AverageDataset, MNIST, TrialMNIST if _TORCHVISION_AVAILABLE: from torchvision import models, transforms diff --git a/tests/helpers/dataloaders.py b/tests/tests_pytorch/helpers/dataloaders.py similarity index 100% rename from tests/helpers/dataloaders.py rename to tests/tests_pytorch/helpers/dataloaders.py diff --git a/tests/helpers/datamodules.py b/tests/tests_pytorch/helpers/datamodules.py similarity index 98% rename from tests/helpers/datamodules.py rename to tests/tests_pytorch/helpers/datamodules.py index 2d2d1190472c5..6ad3151f3aadb 100644 --- a/tests/helpers/datamodules.py +++ b/tests/tests_pytorch/helpers/datamodules.py @@ -19,7 +19,7 @@ from pytorch_lightning.core.datamodule import LightningDataModule from pytorch_lightning.utilities import _module_available -from tests.helpers.datasets import MNIST, SklearnDataset, TrialMNIST +from tests_pytorch.helpers.datasets import MNIST, SklearnDataset, TrialMNIST _SKLEARN_AVAILABLE = _module_available("sklearn") if _SKLEARN_AVAILABLE: diff --git a/tests/helpers/datasets.py b/tests/tests_pytorch/helpers/datasets.py similarity index 100% rename from tests/helpers/datasets.py rename to tests/tests_pytorch/helpers/datasets.py diff --git a/tests/helpers/deterministic_model.py b/tests/tests_pytorch/helpers/deterministic_model.py similarity index 100% rename from tests/helpers/deterministic_model.py rename to tests/tests_pytorch/helpers/deterministic_model.py diff --git a/tests/helpers/imports.py b/tests/tests_pytorch/helpers/imports.py similarity index 100% rename from tests/helpers/imports.py rename to tests/tests_pytorch/helpers/imports.py diff --git a/tests/helpers/pipelines.py b/tests/tests_pytorch/helpers/pipelines.py similarity index 97% rename from tests/helpers/pipelines.py rename to tests/tests_pytorch/helpers/pipelines.py index 8c2aa3d527ac5..3de3d75563fb4 100644 --- a/tests/helpers/pipelines.py +++ b/tests/tests_pytorch/helpers/pipelines.py @@ -16,7 +16,7 @@ from pytorch_lightning import LightningDataModule, LightningModule, Trainer from pytorch_lightning.demos.boring_classes import BoringModel -from tests.helpers.utils import get_default_logger, load_model_from_checkpoint, reset_seed +from tests_pytorch.helpers.utils import get_default_logger, load_model_from_checkpoint, reset_seed def run_model_test_without_loggers( diff --git a/tests/helpers/runif.py b/tests/tests_pytorch/helpers/runif.py similarity index 100% rename from tests/helpers/runif.py rename to tests/tests_pytorch/helpers/runif.py diff --git a/tests/helpers/simple_models.py b/tests/tests_pytorch/helpers/simple_models.py similarity index 100% rename from tests/helpers/simple_models.py rename to tests/tests_pytorch/helpers/simple_models.py diff --git a/tests/helpers/test_datasets.py b/tests/tests_pytorch/helpers/test_datasets.py similarity index 90% rename from tests/helpers/test_datasets.py rename to tests/tests_pytorch/helpers/test_datasets.py index 76669ae0e480d..0d3a93301ae28 100644 --- a/tests/helpers/test_datasets.py +++ b/tests/tests_pytorch/helpers/test_datasets.py @@ -16,8 +16,8 @@ import cloudpickle import pytest -from tests import _PATH_DATASETS -from tests.helpers.datasets import AverageDataset, MNIST, TrialMNIST +from tests_pytorch import _PATH_DATASETS +from tests_pytorch.helpers.datasets import AverageDataset, MNIST, TrialMNIST @pytest.mark.parametrize( diff --git a/tests/helpers/test_models.py b/tests/tests_pytorch/helpers/test_models.py similarity index 84% rename from tests/helpers/test_models.py rename to tests/tests_pytorch/helpers/test_models.py index 93d745aa4ad9d..0b38e31e0a219 100644 --- a/tests/helpers/test_models.py +++ b/tests/tests_pytorch/helpers/test_models.py @@ -17,9 +17,9 @@ from pytorch_lightning import Trainer from pytorch_lightning.demos.boring_classes import BoringModel -from tests.helpers.advanced_models import BasicGAN, ParityModuleMNIST, ParityModuleRNN -from tests.helpers.datamodules import ClassifDataModule, RegressDataModule -from tests.helpers.simple_models import ClassificationModel, RegressionModel +from tests_pytorch.helpers.advanced_models import BasicGAN, ParityModuleMNIST, ParityModuleRNN +from tests_pytorch.helpers.datamodules import ClassifDataModule, RegressDataModule +from tests_pytorch.helpers.simple_models import ClassificationModel, RegressionModel @pytest.mark.parametrize( diff --git a/tests/helpers/torchtext_utils.py b/tests/tests_pytorch/helpers/torchtext_utils.py similarity index 95% rename from tests/helpers/torchtext_utils.py rename to tests/tests_pytorch/helpers/torchtext_utils.py index c166ba8c8df7e..3c18005636bf1 100644 --- a/tests/helpers/torchtext_utils.py +++ b/tests/tests_pytorch/helpers/torchtext_utils.py @@ -14,7 +14,7 @@ import random import string -from tests.helpers.imports import Dataset, Example, Field, Iterator +from tests_pytorch.helpers.imports import Dataset, Example, Field, Iterator def _generate_random_string(length: int = 10): diff --git a/tests/helpers/utils.py b/tests/tests_pytorch/helpers/utils.py similarity index 97% rename from tests/helpers/utils.py rename to tests/tests_pytorch/helpers/utils.py index 2f7ff7e45c981..6da53e7b54b20 100644 --- a/tests/helpers/utils.py +++ b/tests/tests_pytorch/helpers/utils.py @@ -24,7 +24,7 @@ from pytorch_lightning.callbacks import ModelCheckpoint from pytorch_lightning.demos.boring_classes import BoringModel from pytorch_lightning.loggers import TensorBoardLogger -from tests import _TEMP_PATH, RANDOM_PORTS +from tests_pytorch import _TEMP_PATH, RANDOM_PORTS def get_default_logger(save_dir, version=None): @@ -81,7 +81,7 @@ def init_checkpoint_callback(logger): def pl_multi_process_test(func): - """Wrapper for running multi-processing tests.""" + """Wrapper for running multi-processing tests_pytorch.""" @functools.wraps(func) def wrapper(*args, **kwargs): diff --git a/tests/lite/__init__.py b/tests/tests_pytorch/lite/__init__.py similarity index 100% rename from tests/lite/__init__.py rename to tests/tests_pytorch/lite/__init__.py diff --git a/tests/lite/test_lite.py b/tests/tests_pytorch/lite/test_lite.py similarity index 99% rename from tests/lite/test_lite.py rename to tests/tests_pytorch/lite/test_lite.py index d59d87bdede40..40d8f79ae75e2 100644 --- a/tests/lite/test_lite.py +++ b/tests/tests_pytorch/lite/test_lite.py @@ -30,7 +30,7 @@ from pytorch_lightning.utilities import _StrategyType from pytorch_lightning.utilities.exceptions import MisconfigurationException from pytorch_lightning.utilities.seed import pl_worker_init_function -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.runif import RunIf class EmptyLite(LightningLite): diff --git a/tests/lite/test_parity.py b/tests/tests_pytorch/lite/test_parity.py similarity index 99% rename from tests/lite/test_parity.py rename to tests/tests_pytorch/lite/test_parity.py index 036cb2f118e47..8a9f8d5abb5e5 100644 --- a/tests/lite/test_parity.py +++ b/tests/tests_pytorch/lite/test_parity.py @@ -33,7 +33,7 @@ from pytorch_lightning.strategies.ddp_spawn import DDPSpawnStrategy from pytorch_lightning.utilities.apply_func import apply_to_collection, move_data_to_device from pytorch_lightning.utilities.cloud_io import atomic_save -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.runif import RunIf class BoringModel(nn.Module): diff --git a/tests/lite/test_wrappers.py b/tests/tests_pytorch/lite/test_wrappers.py similarity index 99% rename from tests/lite/test_wrappers.py rename to tests/tests_pytorch/lite/test_wrappers.py index 23b179d30b237..953d6bb9a7372 100644 --- a/tests/lite/test_wrappers.py +++ b/tests/tests_pytorch/lite/test_wrappers.py @@ -20,7 +20,7 @@ from pytorch_lightning.core.mixins import DeviceDtypeModuleMixin from pytorch_lightning.lite import LightningLite from pytorch_lightning.lite.wrappers import _LiteDataLoader, _LiteModule, _LiteOptimizer -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.runif import RunIf class EmptyLite(LightningLite): diff --git a/tests/loggers/__init__.py b/tests/tests_pytorch/loggers/__init__.py similarity index 100% rename from tests/loggers/__init__.py rename to tests/tests_pytorch/loggers/__init__.py diff --git a/tests/loggers/test_all.py b/tests/tests_pytorch/loggers/test_all.py similarity index 98% rename from tests/loggers/test_all.py rename to tests/tests_pytorch/loggers/test_all.py index e2688afa79689..f9372c0a27670 100644 --- a/tests/loggers/test_all.py +++ b/tests/tests_pytorch/loggers/test_all.py @@ -21,7 +21,7 @@ import pytest import torch -import tests.helpers.utils as tutils +import tests_pytorch.helpers.utils as tutils from pytorch_lightning import Callback, Trainer from pytorch_lightning.demos.boring_classes import BoringModel from pytorch_lightning.loggers import ( @@ -33,10 +33,10 @@ WandbLogger, ) from pytorch_lightning.loggers.logger import DummyExperiment -from tests.helpers.runif import RunIf -from tests.loggers.test_comet import _patch_comet_atexit -from tests.loggers.test_mlflow import mock_mlflow_run_creation -from tests.loggers.test_neptune import create_neptune_mock +from tests_pytorch.helpers.runif import RunIf +from tests_pytorch.loggers.test_comet import _patch_comet_atexit +from tests_pytorch.loggers.test_mlflow import mock_mlflow_run_creation +from tests_pytorch.loggers.test_neptune import create_neptune_mock LOGGER_CTX_MANAGERS = ( mock.patch("pytorch_lightning.loggers.comet.comet_ml"), diff --git a/tests/loggers/test_comet.py b/tests/tests_pytorch/loggers/test_comet.py similarity index 100% rename from tests/loggers/test_comet.py rename to tests/tests_pytorch/loggers/test_comet.py diff --git a/tests/loggers/test_csv.py b/tests/tests_pytorch/loggers/test_csv.py similarity index 96% rename from tests/loggers/test_csv.py rename to tests/tests_pytorch/loggers/test_csv.py index bd859ad1f5ebb..6b579367006c3 100644 --- a/tests/loggers/test_csv.py +++ b/tests/tests_pytorch/loggers/test_csv.py @@ -21,8 +21,8 @@ from pytorch_lightning.core.saving import load_hparams_from_yaml from pytorch_lightning.loggers import CSVLogger from pytorch_lightning.loggers.csv_logs import ExperimentWriter -from tests.helpers.datamodules import ClassifDataModule -from tests.helpers.simple_models import ClassificationModel +from tests_pytorch.helpers.datamodules import ClassifDataModule +from tests_pytorch.helpers.simple_models import ClassificationModel def test_file_logger_automatic_versioning(tmpdir): diff --git a/tests/loggers/test_logger.py b/tests/tests_pytorch/loggers/test_logger.py similarity index 100% rename from tests/loggers/test_logger.py rename to tests/tests_pytorch/loggers/test_logger.py diff --git a/tests/loggers/test_mlflow.py b/tests/tests_pytorch/loggers/test_mlflow.py similarity index 100% rename from tests/loggers/test_mlflow.py rename to tests/tests_pytorch/loggers/test_mlflow.py diff --git a/tests/loggers/test_neptune.py b/tests/tests_pytorch/loggers/test_neptune.py similarity index 100% rename from tests/loggers/test_neptune.py rename to tests/tests_pytorch/loggers/test_neptune.py diff --git a/tests/loggers/test_tensorboard.py b/tests/tests_pytorch/loggers/test_tensorboard.py similarity index 99% rename from tests/loggers/test_tensorboard.py rename to tests/tests_pytorch/loggers/test_tensorboard.py index d2d2258ec5a88..86070d886296b 100644 --- a/tests/loggers/test_tensorboard.py +++ b/tests/tests_pytorch/loggers/test_tensorboard.py @@ -26,7 +26,7 @@ from pytorch_lightning.demos.boring_classes import BoringModel from pytorch_lightning.loggers import TensorBoardLogger from pytorch_lightning.utilities.imports import _compare_version, _OMEGACONF_AVAILABLE -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.runif import RunIf if _OMEGACONF_AVAILABLE: from omegaconf import OmegaConf diff --git a/tests/loggers/test_wandb.py b/tests/tests_pytorch/loggers/test_wandb.py similarity index 99% rename from tests/loggers/test_wandb.py rename to tests/tests_pytorch/loggers/test_wandb.py index 4bd2ec882b81b..907d66c163ec0 100644 --- a/tests/loggers/test_wandb.py +++ b/tests/tests_pytorch/loggers/test_wandb.py @@ -21,7 +21,7 @@ from pytorch_lightning.demos.boring_classes import BoringModel from pytorch_lightning.loggers import WandbLogger from pytorch_lightning.utilities.exceptions import MisconfigurationException -from tests.helpers.utils import no_warning_call +from tests_pytorch.helpers.utils import no_warning_call @mock.patch("pytorch_lightning.loggers.wandb.wandb") diff --git a/tests/loops/__init__.py b/tests/tests_pytorch/loops/__init__.py similarity index 100% rename from tests/loops/__init__.py rename to tests/tests_pytorch/loops/__init__.py diff --git a/tests/loops/batch/__init__.py b/tests/tests_pytorch/loops/batch/__init__.py similarity index 100% rename from tests/loops/batch/__init__.py rename to tests/tests_pytorch/loops/batch/__init__.py diff --git a/tests/loops/batch/test_truncated_bptt.py b/tests/tests_pytorch/loops/batch/test_truncated_bptt.py similarity index 100% rename from tests/loops/batch/test_truncated_bptt.py rename to tests/tests_pytorch/loops/batch/test_truncated_bptt.py diff --git a/tests/loops/epoch/__init__.py b/tests/tests_pytorch/loops/epoch/__init__.py similarity index 100% rename from tests/loops/epoch/__init__.py rename to tests/tests_pytorch/loops/epoch/__init__.py diff --git a/tests/loops/epoch/test_training_epoch_loop.py b/tests/tests_pytorch/loops/epoch/test_training_epoch_loop.py similarity index 99% rename from tests/loops/epoch/test_training_epoch_loop.py rename to tests/tests_pytorch/loops/epoch/test_training_epoch_loop.py index 41b5738f371be..d53871116e8b7 100644 --- a/tests/loops/epoch/test_training_epoch_loop.py +++ b/tests/tests_pytorch/loops/epoch/test_training_epoch_loop.py @@ -20,7 +20,7 @@ from pytorch_lightning.demos.boring_classes import BoringModel from pytorch_lightning.loops import TrainingEpochLoop from pytorch_lightning.trainer.trainer import Trainer -from tests.deprecated_api import no_deprecated_call +from tests_pytorch.deprecated_api import no_deprecated_call _out00 = {"loss": 0.0} _out01 = {"loss": 0.1} diff --git a/tests/loops/optimization/__init__.py b/tests/tests_pytorch/loops/optimization/__init__.py similarity index 100% rename from tests/loops/optimization/__init__.py rename to tests/tests_pytorch/loops/optimization/__init__.py diff --git a/tests/loops/optimization/test_closure.py b/tests/tests_pytorch/loops/optimization/test_closure.py similarity index 100% rename from tests/loops/optimization/test_closure.py rename to tests/tests_pytorch/loops/optimization/test_closure.py diff --git a/tests/loops/optimization/test_manual_loop.py b/tests/tests_pytorch/loops/optimization/test_manual_loop.py similarity index 100% rename from tests/loops/optimization/test_manual_loop.py rename to tests/tests_pytorch/loops/optimization/test_manual_loop.py diff --git a/tests/loops/optimization/test_optimizer_loop.py b/tests/tests_pytorch/loops/optimization/test_optimizer_loop.py similarity index 100% rename from tests/loops/optimization/test_optimizer_loop.py rename to tests/tests_pytorch/loops/optimization/test_optimizer_loop.py diff --git a/tests/loops/test_all.py b/tests/tests_pytorch/loops/test_all.py similarity index 98% rename from tests/loops/test_all.py rename to tests/tests_pytorch/loops/test_all.py index fd0ded8c64c27..dabaa81c489cc 100644 --- a/tests/loops/test_all.py +++ b/tests/tests_pytorch/loops/test_all.py @@ -13,7 +13,7 @@ # limitations under the License. from pytorch_lightning import Callback, Trainer from pytorch_lightning.demos.boring_classes import BoringModel -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.runif import RunIf class BatchHookObserverCallback(Callback): diff --git a/tests/loops/test_evaluation_loop.py b/tests/tests_pytorch/loops/test_evaluation_loop.py similarity index 99% rename from tests/loops/test_evaluation_loop.py rename to tests/tests_pytorch/loops/test_evaluation_loop.py index 83424f34feace..cd531aaa2f80b 100644 --- a/tests/loops/test_evaluation_loop.py +++ b/tests/tests_pytorch/loops/test_evaluation_loop.py @@ -22,7 +22,7 @@ from pytorch_lightning.demos.boring_classes import BoringModel, RandomDataset from pytorch_lightning.loops import EvaluationEpochLoop from pytorch_lightning.utilities.model_helpers import is_overridden -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.runif import RunIf @mock.patch("pytorch_lightning.loops.dataloader.evaluation_loop.EvaluationLoop._on_evaluation_epoch_end") diff --git a/tests/loops/test_evaluation_loop_flow.py b/tests/tests_pytorch/loops/test_evaluation_loop_flow.py similarity index 99% rename from tests/loops/test_evaluation_loop_flow.py rename to tests/tests_pytorch/loops/test_evaluation_loop_flow.py index 07a24ee3e20b0..59a511933b32b 100644 --- a/tests/loops/test_evaluation_loop_flow.py +++ b/tests/tests_pytorch/loops/test_evaluation_loop_flow.py @@ -18,7 +18,7 @@ from pytorch_lightning import Trainer from pytorch_lightning.core.module import LightningModule from pytorch_lightning.trainer.states import RunningStage -from tests.helpers.deterministic_model import DeterministicModel +from tests_pytorch.helpers.deterministic_model import DeterministicModel def test__eval_step__flow(tmpdir): diff --git a/tests/loops/test_flow_warnings.py b/tests/tests_pytorch/loops/test_flow_warnings.py similarity index 100% rename from tests/loops/test_flow_warnings.py rename to tests/tests_pytorch/loops/test_flow_warnings.py diff --git a/tests/loops/test_loop_state_dict.py b/tests/tests_pytorch/loops/test_loop_state_dict.py similarity index 100% rename from tests/loops/test_loop_state_dict.py rename to tests/tests_pytorch/loops/test_loop_state_dict.py diff --git a/tests/loops/test_loops.py b/tests/tests_pytorch/loops/test_loops.py similarity index 99% rename from tests/loops/test_loops.py rename to tests/tests_pytorch/loops/test_loops.py index ee85083bd81ff..a980d99964823 100644 --- a/tests/loops/test_loops.py +++ b/tests/tests_pytorch/loops/test_loops.py @@ -28,7 +28,7 @@ from pytorch_lightning.loops import EvaluationLoop, Loop, TrainingBatchLoop, TrainingEpochLoop from pytorch_lightning.trainer.progress import BaseProgress from pytorch_lightning.utilities.exceptions import MisconfigurationException -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.runif import RunIf class NestedLoop(Loop): diff --git a/tests/loops/test_training_loop.py b/tests/tests_pytorch/loops/test_training_loop.py similarity index 100% rename from tests/loops/test_training_loop.py rename to tests/tests_pytorch/loops/test_training_loop.py diff --git a/tests/loops/test_training_loop_flow_dict.py b/tests/tests_pytorch/loops/test_training_loop_flow_dict.py similarity index 98% rename from tests/loops/test_training_loop_flow_dict.py rename to tests/tests_pytorch/loops/test_training_loop_flow_dict.py index e04ca4c55c6fc..e82519ad6021f 100644 --- a/tests/loops/test_training_loop_flow_dict.py +++ b/tests/tests_pytorch/loops/test_training_loop_flow_dict.py @@ -17,7 +17,7 @@ from pytorch_lightning import Trainer from pytorch_lightning.core.module import LightningModule -from tests.helpers.deterministic_model import DeterministicModel +from tests_pytorch.helpers.deterministic_model import DeterministicModel def test__training_step__flow_dict(tmpdir): diff --git a/tests/loops/test_training_loop_flow_scalar.py b/tests/tests_pytorch/loops/test_training_loop_flow_scalar.py similarity index 98% rename from tests/loops/test_training_loop_flow_scalar.py rename to tests/tests_pytorch/loops/test_training_loop_flow_scalar.py index 0a8a7088be32c..45b372d0020e6 100644 --- a/tests/loops/test_training_loop_flow_scalar.py +++ b/tests/tests_pytorch/loops/test_training_loop_flow_scalar.py @@ -21,8 +21,8 @@ from pytorch_lightning.demos.boring_classes import BoringModel, RandomDataset from pytorch_lightning.loops.optimization.optimizer_loop import Closure from pytorch_lightning.trainer.states import RunningStage -from tests.helpers.deterministic_model import DeterministicModel -from tests.helpers.utils import no_warning_call +from tests_pytorch.helpers.deterministic_model import DeterministicModel +from tests_pytorch.helpers.utils import no_warning_call def test__training_step__flow_scalar(tmpdir): diff --git a/tests/loops/test_utilities.py b/tests/tests_pytorch/loops/test_utilities.py similarity index 100% rename from tests/loops/test_utilities.py rename to tests/tests_pytorch/loops/test_utilities.py diff --git a/tests/models/__init__.py b/tests/tests_pytorch/models/__init__.py similarity index 100% rename from tests/models/__init__.py rename to tests/tests_pytorch/models/__init__.py diff --git a/tests/models/conf/config.yaml b/tests/tests_pytorch/models/conf/config.yaml similarity index 100% rename from tests/models/conf/config.yaml rename to tests/tests_pytorch/models/conf/config.yaml diff --git a/tests/models/conf/training/default.yaml b/tests/tests_pytorch/models/conf/training/default.yaml similarity index 100% rename from tests/models/conf/training/default.yaml rename to tests/tests_pytorch/models/conf/training/default.yaml diff --git a/tests/models/data/__init__.py b/tests/tests_pytorch/models/data/__init__.py similarity index 100% rename from tests/models/data/__init__.py rename to tests/tests_pytorch/models/data/__init__.py diff --git a/tests/models/data/horovod/__init__.py b/tests/tests_pytorch/models/data/horovod/__init__.py similarity index 100% rename from tests/models/data/horovod/__init__.py rename to tests/tests_pytorch/models/data/horovod/__init__.py diff --git a/tests/models/data/horovod/test_train_script.py b/tests/tests_pytorch/models/data/horovod/test_train_script.py similarity index 92% rename from tests/models/data/horovod/test_train_script.py rename to tests/tests_pytorch/models/data/horovod/test_train_script.py index 1d32b9ce9d29a..f0f731c5fe6e2 100644 --- a/tests/models/data/horovod/test_train_script.py +++ b/tests/tests_pytorch/models/data/horovod/test_train_script.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from tests.models.data.horovod.train_default_model import run_test_from_config +from tests_pytorch.models.data.horovod.train_default_model import run_test_from_config def test_horovod_model_script(tmpdir): diff --git a/tests/models/data/horovod/train_default_model.py b/tests/tests_pytorch/models/data/horovod/train_default_model.py similarity index 97% rename from tests/models/data/horovod/train_default_model.py rename to tests/tests_pytorch/models/data/horovod/train_default_model.py index a899a84767bda..d21aa752e41b1 100644 --- a/tests/models/data/horovod/train_default_model.py +++ b/tests/tests_pytorch/models/data/horovod/train_default_model.py @@ -37,7 +37,7 @@ print("You requested to import Horovod which is missing or not supported for your OS.") from pytorch_lightning.demos.boring_classes import BoringModel # noqa: E402 -from tests.helpers.utils import reset_seed, set_random_main_port # noqa: E402 +from tests_pytorch.helpers.utils import reset_seed, set_random_main_port # noqa: E402 parser = argparse.ArgumentParser() parser.add_argument("--trainer-options", required=True) diff --git a/tests/models/test_amp.py b/tests/tests_pytorch/models/test_amp.py similarity index 98% rename from tests/models/test_amp.py rename to tests/tests_pytorch/models/test_amp.py index f2d7f71be6ea2..159a3767c1df2 100644 --- a/tests/models/test_amp.py +++ b/tests/tests_pytorch/models/test_amp.py @@ -19,11 +19,11 @@ from torch import optim from torch.utils.data import DataLoader -import tests.helpers.utils as tutils +import tests_pytorch.helpers.utils as tutils from pytorch_lightning import Trainer from pytorch_lightning.demos.boring_classes import BoringModel, RandomDataset from pytorch_lightning.plugins.environments import SLURMEnvironment -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.runif import RunIf class AMPTestModel(BoringModel): diff --git a/tests/models/test_cpu.py b/tests/tests_pytorch/models/test_cpu.py similarity index 97% rename from tests/models/test_cpu.py rename to tests/tests_pytorch/models/test_cpu.py index 187b32b4345d5..16f5508ab5e69 100644 --- a/tests/models/test_cpu.py +++ b/tests/tests_pytorch/models/test_cpu.py @@ -15,14 +15,14 @@ import torch -import tests.helpers.pipelines as tpipes -import tests.helpers.utils as tutils +import tests_pytorch.helpers.pipelines as tpipes +import tests_pytorch.helpers.utils as tutils from pytorch_lightning import Trainer from pytorch_lightning.callbacks import Callback, EarlyStopping, ModelCheckpoint from pytorch_lightning.demos.boring_classes import BoringModel -from tests.helpers.datamodules import ClassifDataModule -from tests.helpers.runif import RunIf -from tests.helpers.simple_models import ClassificationModel +from tests_pytorch.helpers.datamodules import ClassifDataModule +from tests_pytorch.helpers.runif import RunIf +from tests_pytorch.helpers.simple_models import ClassificationModel def test_cpu_slurm_save_load(tmpdir): diff --git a/tests/models/test_gpu.py b/tests/tests_pytorch/models/test_gpu.py similarity index 97% rename from tests/models/test_gpu.py rename to tests/tests_pytorch/models/test_gpu.py index b49eb2421edd9..5868ff2079228 100644 --- a/tests/models/test_gpu.py +++ b/tests/tests_pytorch/models/test_gpu.py @@ -20,8 +20,8 @@ import pytest import torch -import tests.helpers.pipelines as tpipes -import tests.helpers.utils as tutils +import tests_pytorch.helpers.pipelines as tpipes +import tests_pytorch.helpers.utils as tutils from pytorch_lightning import Trainer from pytorch_lightning.accelerators import CPUAccelerator, GPUAccelerator from pytorch_lightning.demos.boring_classes import BoringModel @@ -29,10 +29,10 @@ from pytorch_lightning.utilities import device_parser from pytorch_lightning.utilities.exceptions import MisconfigurationException from pytorch_lightning.utilities.imports import _compare_version, _TORCHTEXT_LEGACY -from tests.helpers.datamodules import ClassifDataModule -from tests.helpers.imports import Batch, Dataset, Example, Field, LabelField -from tests.helpers.runif import RunIf -from tests.helpers.simple_models import ClassificationModel +from tests_pytorch.helpers.datamodules import ClassifDataModule +from tests_pytorch.helpers.imports import Batch, Dataset, Example, Field, LabelField +from tests_pytorch.helpers.runif import RunIf +from tests_pytorch.helpers.simple_models import ClassificationModel PL_VERSION_LT_1_5 = _compare_version("pytorch_lightning", operator.lt, "1.5") PRETEND_N_OF_GPUS = 16 diff --git a/tests/models/test_grad_norm.py b/tests/tests_pytorch/models/test_grad_norm.py similarity index 98% rename from tests/models/test_grad_norm.py rename to tests/tests_pytorch/models/test_grad_norm.py index 437897b5bf94f..ebdc2f7c5cf8e 100644 --- a/tests/models/test_grad_norm.py +++ b/tests/tests_pytorch/models/test_grad_norm.py @@ -18,7 +18,7 @@ from pytorch_lightning import Trainer from pytorch_lightning.demos.boring_classes import BoringModel -from tests.helpers.utils import reset_seed +from tests_pytorch.helpers.utils import reset_seed class ModelWithManualGradTracker(BoringModel): diff --git a/tests/models/test_hooks.py b/tests/tests_pytorch/models/test_hooks.py similarity index 99% rename from tests/models/test_hooks.py rename to tests/tests_pytorch/models/test_hooks.py index ced7b4ce5e772..39b18cf0d2ad4 100644 --- a/tests/models/test_hooks.py +++ b/tests/tests_pytorch/models/test_hooks.py @@ -22,7 +22,7 @@ from pytorch_lightning import __version__, Callback, LightningDataModule, LightningModule, Trainer from pytorch_lightning.demos.boring_classes import BoringDataModule, BoringModel, RandomDataset -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.runif import RunIf @pytest.mark.parametrize("max_steps", [1, 2, 3]) diff --git a/tests/models/test_horovod.py b/tests/tests_pytorch/models/test_horovod.py similarity index 98% rename from tests/models/test_horovod.py rename to tests/tests_pytorch/models/test_horovod.py index 15161b46d7496..244a3e3d885c3 100644 --- a/tests/models/test_horovod.py +++ b/tests/tests_pytorch/models/test_horovod.py @@ -25,15 +25,15 @@ from torch import optim from torchmetrics.classification.accuracy import Accuracy -import tests.helpers.pipelines as tpipes -import tests.helpers.utils as tutils +import tests_pytorch.helpers.pipelines as tpipes +import tests_pytorch.helpers.utils as tutils from pytorch_lightning import Trainer from pytorch_lightning.accelerators import CPUAccelerator from pytorch_lightning.demos.boring_classes import BoringModel from pytorch_lightning.utilities import _HOROVOD_AVAILABLE from pytorch_lightning.utilities.exceptions import MisconfigurationException -from tests.helpers.advanced_models import BasicGAN -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.advanced_models import BasicGAN +from tests_pytorch.helpers.runif import RunIf if _HOROVOD_AVAILABLE: import horovod @@ -42,7 +42,7 @@ @RunIf(min_cuda_gpus=1, horovod=True) def test_nccl_is_available_on_gpu_environment(): - from tests.helpers.runif import _HOROVOD_NCCL_AVAILABLE + from tests_pytorch.helpers.runif import _HOROVOD_NCCL_AVAILABLE # the GPU environment should always install Horovod NCCL assert _HOROVOD_NCCL_AVAILABLE diff --git a/tests/models/test_hparams.py b/tests/tests_pytorch/models/test_hparams.py similarity index 99% rename from tests/models/test_hparams.py rename to tests/tests_pytorch/models/test_hparams.py index a0066d45f50cc..c064d0f8c055e 100644 --- a/tests/models/test_hparams.py +++ b/tests/tests_pytorch/models/test_hparams.py @@ -33,8 +33,8 @@ from pytorch_lightning.demos.boring_classes import BoringDataModule, BoringModel, RandomDataset from pytorch_lightning.utilities import _HYDRA_EXPERIMENTAL_AVAILABLE, _OMEGACONF_AVAILABLE, AttributeDict, is_picklable from pytorch_lightning.utilities.exceptions import MisconfigurationException -from tests.helpers.runif import RunIf -from tests.helpers.utils import no_warning_call +from tests_pytorch.helpers.runif import RunIf +from tests_pytorch.helpers.utils import no_warning_call if _HYDRA_EXPERIMENTAL_AVAILABLE: from hydra.experimental import compose, initialize diff --git a/tests/models/test_onnx.py b/tests/tests_pytorch/models/test_onnx.py similarity index 96% rename from tests/models/test_onnx.py rename to tests/tests_pytorch/models/test_onnx.py index bfa98a3f3f373..7428b4b976ad9 100644 --- a/tests/models/test_onnx.py +++ b/tests/tests_pytorch/models/test_onnx.py @@ -18,12 +18,12 @@ import pytest import torch -import tests.helpers.pipelines as tpipes -import tests.helpers.utils as tutils +import tests_pytorch.helpers.pipelines as tpipes +import tests_pytorch.helpers.utils as tutils from pytorch_lightning import Trainer from pytorch_lightning.demos.boring_classes import BoringModel -from tests.helpers.runif import RunIf -from tests.utilities.test_model_summary import UnorderedModel +from tests_pytorch.helpers.runif import RunIf +from tests_pytorch.utilities.test_model_summary import UnorderedModel def test_model_saves_with_input_sample(tmpdir): diff --git a/tests/models/test_restore.py b/tests/tests_pytorch/models/test_restore.py similarity index 98% rename from tests/models/test_restore.py rename to tests/tests_pytorch/models/test_restore.py index dae1f8426655f..77f45928dd907 100644 --- a/tests/models/test_restore.py +++ b/tests/tests_pytorch/models/test_restore.py @@ -24,16 +24,16 @@ import torch import torch.nn.functional as F -import tests.helpers.pipelines as tpipes -import tests.helpers.utils as tutils +import tests_pytorch.helpers.pipelines as tpipes +import tests_pytorch.helpers.utils as tutils from pytorch_lightning import Callback, Trainer from pytorch_lightning.callbacks import ModelCheckpoint from pytorch_lightning.demos.boring_classes import BoringModel from pytorch_lightning.trainer.states import TrainerFn -from tests.helpers.datamodules import ClassifDataModule -from tests.helpers.runif import RunIf -from tests.helpers.simple_models import ClassificationModel -from tests.loops.test_loops import CustomException +from tests_pytorch.helpers.datamodules import ClassifDataModule +from tests_pytorch.helpers.runif import RunIf +from tests_pytorch.helpers.simple_models import ClassificationModel +from tests_pytorch.loops.test_loops import CustomException class ModelTrainerPropertyParity(Callback): diff --git a/tests/models/test_torchscript.py b/tests/tests_pytorch/models/test_torchscript.py similarity index 97% rename from tests/models/test_torchscript.py rename to tests/tests_pytorch/models/test_torchscript.py index d48c8e2c37e5b..127664af332ca 100644 --- a/tests/models/test_torchscript.py +++ b/tests/tests_pytorch/models/test_torchscript.py @@ -21,8 +21,8 @@ from pytorch_lightning.demos.boring_classes import BoringModel from pytorch_lightning.utilities.cloud_io import get_filesystem -from tests.helpers.advanced_models import BasicGAN, ParityModuleRNN -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.advanced_models import BasicGAN, ParityModuleRNN +from tests_pytorch.helpers.runif import RunIf @pytest.mark.parametrize("modelclass", [BoringModel, ParityModuleRNN, BasicGAN]) diff --git a/tests/models/test_tpu.py b/tests/tests_pytorch/models/test_tpu.py similarity index 98% rename from tests/models/test_tpu.py rename to tests/tests_pytorch/models/test_tpu.py index b42aa4a3f34a0..b6829d444701d 100644 --- a/tests/models/test_tpu.py +++ b/tests/tests_pytorch/models/test_tpu.py @@ -19,8 +19,8 @@ import torch from torch.utils.data import DataLoader -import tests.helpers.pipelines as tpipes -import tests.helpers.utils as tutils +import tests_pytorch.helpers.pipelines as tpipes +import tests_pytorch.helpers.utils as tutils from pytorch_lightning import Trainer from pytorch_lightning.accelerators import TPUAccelerator from pytorch_lightning.callbacks import EarlyStopping @@ -30,8 +30,8 @@ from pytorch_lightning.utilities import _TPU_AVAILABLE from pytorch_lightning.utilities.distributed import ReduceOp from pytorch_lightning.utilities.exceptions import MisconfigurationException -from tests.helpers.runif import RunIf -from tests.helpers.utils import pl_multi_process_test +from tests_pytorch.helpers.runif import RunIf +from tests_pytorch.helpers.utils import pl_multi_process_test if _TPU_AVAILABLE: import torch_xla diff --git a/tests/overrides/__init__.py b/tests/tests_pytorch/overrides/__init__.py similarity index 100% rename from tests/overrides/__init__.py rename to tests/tests_pytorch/overrides/__init__.py diff --git a/tests/overrides/test_base.py b/tests/tests_pytorch/overrides/test_base.py similarity index 100% rename from tests/overrides/test_base.py rename to tests/tests_pytorch/overrides/test_base.py diff --git a/tests/overrides/test_data_parallel.py b/tests/tests_pytorch/overrides/test_data_parallel.py similarity index 99% rename from tests/overrides/test_data_parallel.py rename to tests/tests_pytorch/overrides/test_data_parallel.py index 3561fa99dca5c..47212a6b45962 100644 --- a/tests/overrides/test_data_parallel.py +++ b/tests/tests_pytorch/overrides/test_data_parallel.py @@ -27,7 +27,7 @@ unsqueeze_scalar_tensor, ) from pytorch_lightning.trainer.states import RunningStage -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.runif import RunIf @pytest.mark.parametrize("wrapper_class", [LightningParallelModule, LightningDistributedModule]) diff --git a/tests/overrides/test_distributed.py b/tests/tests_pytorch/overrides/test_distributed.py similarity index 100% rename from tests/overrides/test_distributed.py rename to tests/tests_pytorch/overrides/test_distributed.py diff --git a/tests/plugins/__init__.py b/tests/tests_pytorch/plugins/__init__.py similarity index 100% rename from tests/plugins/__init__.py rename to tests/tests_pytorch/plugins/__init__.py diff --git a/tests/plugins/environments/__init__.py b/tests/tests_pytorch/plugins/environments/__init__.py similarity index 100% rename from tests/plugins/environments/__init__.py rename to tests/tests_pytorch/plugins/environments/__init__.py diff --git a/tests/plugins/environments/test_kubeflow_environment.py b/tests/tests_pytorch/plugins/environments/test_kubeflow_environment.py similarity index 100% rename from tests/plugins/environments/test_kubeflow_environment.py rename to tests/tests_pytorch/plugins/environments/test_kubeflow_environment.py diff --git a/tests/plugins/environments/test_lightning_environment.py b/tests/tests_pytorch/plugins/environments/test_lightning_environment.py similarity index 100% rename from tests/plugins/environments/test_lightning_environment.py rename to tests/tests_pytorch/plugins/environments/test_lightning_environment.py diff --git a/tests/plugins/environments/test_lsf_environment.py b/tests/tests_pytorch/plugins/environments/test_lsf_environment.py similarity index 100% rename from tests/plugins/environments/test_lsf_environment.py rename to tests/tests_pytorch/plugins/environments/test_lsf_environment.py diff --git a/tests/plugins/environments/test_slurm_environment.py b/tests/tests_pytorch/plugins/environments/test_slurm_environment.py similarity index 100% rename from tests/plugins/environments/test_slurm_environment.py rename to tests/tests_pytorch/plugins/environments/test_slurm_environment.py diff --git a/tests/plugins/environments/test_torchelastic_environment.py b/tests/tests_pytorch/plugins/environments/test_torchelastic_environment.py similarity index 98% rename from tests/plugins/environments/test_torchelastic_environment.py rename to tests/tests_pytorch/plugins/environments/test_torchelastic_environment.py index 9b9d83a4d84e5..10468d7a02a1f 100644 --- a/tests/plugins/environments/test_torchelastic_environment.py +++ b/tests/tests_pytorch/plugins/environments/test_torchelastic_environment.py @@ -18,7 +18,7 @@ import pytest from pytorch_lightning.plugins.environments import TorchElasticEnvironment -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.runif import RunIf @mock.patch.dict(os.environ, {}, clear=True) diff --git a/tests/plugins/environments/torch_elastic_deadlock.py b/tests/tests_pytorch/plugins/environments/torch_elastic_deadlock.py similarity index 100% rename from tests/plugins/environments/torch_elastic_deadlock.py rename to tests/tests_pytorch/plugins/environments/torch_elastic_deadlock.py diff --git a/tests/plugins/precision/__init__.py b/tests/tests_pytorch/plugins/precision/__init__.py similarity index 100% rename from tests/plugins/precision/__init__.py rename to tests/tests_pytorch/plugins/precision/__init__.py diff --git a/tests/plugins/precision/hpu/ops_bf16.txt b/tests/tests_pytorch/plugins/precision/hpu/ops_bf16.txt similarity index 100% rename from tests/plugins/precision/hpu/ops_bf16.txt rename to tests/tests_pytorch/plugins/precision/hpu/ops_bf16.txt diff --git a/tests/plugins/precision/hpu/ops_fp32.txt b/tests/tests_pytorch/plugins/precision/hpu/ops_fp32.txt similarity index 100% rename from tests/plugins/precision/hpu/ops_fp32.txt rename to tests/tests_pytorch/plugins/precision/hpu/ops_fp32.txt diff --git a/tests/plugins/precision/hpu/test_hpu.py b/tests/tests_pytorch/plugins/precision/hpu/test_hpu.py similarity index 98% rename from tests/plugins/precision/hpu/test_hpu.py rename to tests/tests_pytorch/plugins/precision/hpu/test_hpu.py index 4dc2aa22674b9..5ca366f5162e8 100644 --- a/tests/plugins/precision/hpu/test_hpu.py +++ b/tests/tests_pytorch/plugins/precision/hpu/test_hpu.py @@ -20,7 +20,7 @@ from pytorch_lightning.demos.boring_classes import BoringModel from pytorch_lightning.plugins import HPUPrecisionPlugin from pytorch_lightning.strategies.single_hpu import SingleHPUStrategy -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.runif import RunIf @pytest.fixture diff --git a/tests/plugins/precision/test_deepspeed_precision.py b/tests/tests_pytorch/plugins/precision/test_deepspeed_precision.py similarity index 100% rename from tests/plugins/precision/test_deepspeed_precision.py rename to tests/tests_pytorch/plugins/precision/test_deepspeed_precision.py diff --git a/tests/plugins/precision/test_sharded_precision.py b/tests/tests_pytorch/plugins/precision/test_sharded_precision.py similarity index 96% rename from tests/plugins/precision/test_sharded_precision.py rename to tests/tests_pytorch/plugins/precision/test_sharded_precision.py index 754095912fb53..6dac89911f8c0 100644 --- a/tests/plugins/precision/test_sharded_precision.py +++ b/tests/tests_pytorch/plugins/precision/test_sharded_precision.py @@ -17,7 +17,7 @@ from pytorch_lightning.plugins import ShardedNativeMixedPrecisionPlugin from pytorch_lightning.utilities import _FAIRSCALE_AVAILABLE -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.runif import RunIf ShardedGradScaler = None if _FAIRSCALE_AVAILABLE: diff --git a/tests/plugins/precision/test_tpu_bf16_plugin.py b/tests/tests_pytorch/plugins/precision/test_tpu_bf16_plugin.py similarity index 100% rename from tests/plugins/precision/test_tpu_bf16_plugin.py rename to tests/tests_pytorch/plugins/precision/test_tpu_bf16_plugin.py diff --git a/tests/plugins/test_amp_plugins.py b/tests/tests_pytorch/plugins/test_amp_plugins.py similarity index 99% rename from tests/plugins/test_amp_plugins.py rename to tests/tests_pytorch/plugins/test_amp_plugins.py index 3d0ad9d837008..4f990e74b20aa 100644 --- a/tests/plugins/test_amp_plugins.py +++ b/tests/tests_pytorch/plugins/test_amp_plugins.py @@ -22,7 +22,7 @@ from pytorch_lightning.demos.boring_classes import BoringModel from pytorch_lightning.plugins import ApexMixedPrecisionPlugin, NativeMixedPrecisionPlugin from pytorch_lightning.utilities.exceptions import MisconfigurationException -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.runif import RunIf class MyNativeAMP(NativeMixedPrecisionPlugin): diff --git a/tests/plugins/test_checkpoint_io_plugin.py b/tests/tests_pytorch/plugins/test_checkpoint_io_plugin.py similarity index 100% rename from tests/plugins/test_checkpoint_io_plugin.py rename to tests/tests_pytorch/plugins/test_checkpoint_io_plugin.py diff --git a/tests/plugins/test_cluster_integration.py b/tests/tests_pytorch/plugins/test_cluster_integration.py similarity index 99% rename from tests/plugins/test_cluster_integration.py rename to tests/tests_pytorch/plugins/test_cluster_integration.py index ad99087fd8b5b..10ed1d6a4a650 100644 --- a/tests/plugins/test_cluster_integration.py +++ b/tests/tests_pytorch/plugins/test_cluster_integration.py @@ -21,7 +21,7 @@ from pytorch_lightning.plugins.environments import LightningEnvironment, SLURMEnvironment, TorchElasticEnvironment from pytorch_lightning.strategies import DDP2Strategy, DDPShardedStrategy, DDPStrategy, DeepSpeedStrategy from pytorch_lightning.utilities.rank_zero import rank_zero_only -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.runif import RunIf def environment_combinations(): diff --git a/tests/plugins/test_double_plugin.py b/tests/tests_pytorch/plugins/test_double_plugin.py similarity index 99% rename from tests/plugins/test_double_plugin.py rename to tests/tests_pytorch/plugins/test_double_plugin.py index 26e09dde65795..839bcd7c212a7 100644 --- a/tests/plugins/test_double_plugin.py +++ b/tests/tests_pytorch/plugins/test_double_plugin.py @@ -21,7 +21,7 @@ from pytorch_lightning import Trainer from pytorch_lightning.demos.boring_classes import BoringModel, RandomDataset from pytorch_lightning.plugins import DoublePrecisionPlugin -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.runif import RunIf class RandomFloatIntDataset(Dataset): diff --git a/tests/profiler/__init__.py b/tests/tests_pytorch/profiler/__init__.py similarity index 100% rename from tests/profiler/__init__.py rename to tests/tests_pytorch/profiler/__init__.py diff --git a/tests/profiler/test_profiler.py b/tests/tests_pytorch/profiler/test_profiler.py similarity index 99% rename from tests/profiler/test_profiler.py rename to tests/tests_pytorch/profiler/test_profiler.py index 090dea820cbcd..a74c2cde222a6 100644 --- a/tests/profiler/test_profiler.py +++ b/tests/tests_pytorch/profiler/test_profiler.py @@ -30,7 +30,7 @@ from pytorch_lightning.profiler.pytorch import RegisterRecordFunction, warning_cache from pytorch_lightning.utilities.exceptions import MisconfigurationException from pytorch_lightning.utilities.imports import _KINETO_AVAILABLE -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.runif import RunIf PROFILER_OVERHEAD_MAX_TOLERANCE = 0.0005 diff --git a/tests/profiler/test_xla_profiler.py b/tests/tests_pytorch/profiler/test_xla_profiler.py similarity index 97% rename from tests/profiler/test_xla_profiler.py rename to tests/tests_pytorch/profiler/test_xla_profiler.py index 5b7adb9c7ff4f..c28b829535b4c 100644 --- a/tests/profiler/test_xla_profiler.py +++ b/tests/tests_pytorch/profiler/test_xla_profiler.py @@ -20,7 +20,7 @@ from pytorch_lightning.demos.boring_classes import BoringModel from pytorch_lightning.profiler import XLAProfiler from pytorch_lightning.utilities import _TPU_AVAILABLE -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.runif import RunIf if _TPU_AVAILABLE: import torch_xla.debug.profiler as xp diff --git a/tests/standalone_tests.sh b/tests/tests_pytorch/run_standalone_tests.sh old mode 100755 new mode 100644 similarity index 69% rename from tests/standalone_tests.sh rename to tests/tests_pytorch/run_standalone_tests.sh index db9b950f0824a..3dd80324539ce --- a/tests/standalone_tests.sh +++ b/tests/tests_pytorch/run_standalone_tests.sh @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. set -e +# THIS FILE ASSUMES IT IS RUN INSIDE THE tests/tests_pytorch DIRECTORY # this environment variable allows special tests to run export PL_RUN_STANDALONE_TESTS=1 @@ -20,7 +21,7 @@ export PL_RUN_STANDALONE_TESTS=1 defaults='-m coverage run --source pytorch_lightning --append -m pytest --capture=no' # find tests marked as `@RunIf(standalone=True)`. done manually instead of with pytest because it is faster -grep_output=$(grep --recursive --word-regexp 'tests' --regexp 'standalone=True' --include '*.py' --exclude 'tests/conftest.py') +grep_output=$(grep --recursive --word-regexp . --regexp 'standalone=True' --include '*.py' --exclude 'conftest.py') # file paths, remove duplicates files=$(echo "$grep_output" | cut -f1 -d: | sort | uniq) @@ -32,10 +33,12 @@ if [[ "$OSTYPE" == "darwin"* ]]; then else parametrizations=$(python -m pytest $files --collect-only --quiet "$@" | head -n -2) fi +# remove the "tests/tests_pytorch" path suffixes +parametrizations=${parametrizations//"tests/tests_pytorch/"/} parametrizations_arr=($parametrizations) # tests to skip - space separated -blocklist='tests/profiler/test_profiler.py::test_pytorch_profiler_nested_emit_nvtx tests/utilities/test_warnings.py' +blocklist='profiler/test_profiler.py::test_pytorch_profiler_nested_emit_nvtx utilities/test_warnings.py' report='' for i in "${!parametrizations_arr[@]}"; do @@ -48,34 +51,34 @@ for i in "${!parametrizations_arr[@]}"; do fi # run the test - echo "Running ${parametrization}" - python ${defaults} "${parametrization}" + echo "Running $parametrization" + python ${defaults} "$parametrization" report+="Ran\t$parametrization\n" done if nvcc --version; then - nvprof --profile-from-start off -o trace_name.prof -- python ${defaults} tests/profiler/test_profiler.py::test_pytorch_profiler_nested_emit_nvtx + nvprof --profile-from-start off -o trace_name.prof -- python ${defaults} profiler/test_profiler.py::test_pytorch_profiler_nested_emit_nvtx fi # needs to run outside of `pytest` -python tests/utilities/test_warnings.py +python utilities/test_warnings.py if [ $? -eq 0 ]; then - report+="Ran\ttests/utilities/test_warnings.py\n" + report+="Ran\tutilities/test_warnings.py\n" fi # test deadlock is properly handled with TorchElastic. -LOGS=$(PL_RUN_STANDALONE_TESTS=1 PL_RECONCILE_PROCESS=1 python -m torch.distributed.run --nproc_per_node=2 --max_restarts 0 -m coverage run --source pytorch_lightning -a tests/plugins/environments/torch_elastic_deadlock.py | grep "SUCCEEDED") +LOGS=$(PL_RUN_STANDALONE_TESTS=1 PL_RECONCILE_PROCESS=1 python -m torch.distributed.run --nproc_per_node=2 --max_restarts 0 -m coverage run --source pytorch_lightning -a plugins/environments/torch_elastic_deadlock.py | grep "SUCCEEDED") if [ -z "$LOGS" ]; then exit 1 fi -report+="Ran\ttests/plugins/environments/torch_elastic_deadlock.py\n" +report+="Ran\tplugins/environments/torch_elastic_deadlock.py\n" # test that a user can manually launch individual processes export PYTHONPATH="${PYTHONPATH}:$(pwd)" args="--trainer.gpus 2 --trainer.strategy ddp --trainer.max_epochs=1 --trainer.limit_train_batches=1 --trainer.limit_val_batches=1 --trainer.limit_test_batches=1" -MASTER_ADDR="localhost" MASTER_PORT=1234 LOCAL_RANK=1 python pl_examples/basic_examples/mnist_examples/image_classifier_5_lightning_datamodule.py ${args} & -MASTER_ADDR="localhost" MASTER_PORT=1234 LOCAL_RANK=0 python pl_examples/basic_examples/mnist_examples/image_classifier_5_lightning_datamodule.py ${args} +MASTER_ADDR="localhost" MASTER_PORT=1234 LOCAL_RANK=1 python ../../examples/convert_from_pt_to_pl/image_classifier_5_lightning_datamodule.py ${args} & +MASTER_ADDR="localhost" MASTER_PORT=1234 LOCAL_RANK=0 python ../../examples/convert_from_pt_to_pl/image_classifier_5_lightning_datamodule.py ${args} report+="Ran\tmanual ddp launch test\n" # echo test report diff --git a/tests/strategies/__init__.py b/tests/tests_pytorch/strategies/__init__.py similarity index 100% rename from tests/strategies/__init__.py rename to tests/tests_pytorch/strategies/__init__.py diff --git a/tests/strategies/ddp_model.py b/tests/tests_pytorch/strategies/ddp_model.py similarity index 93% rename from tests/strategies/ddp_model.py rename to tests/tests_pytorch/strategies/ddp_model.py index c35e1475de309..76d1f3f2f6866 100644 --- a/tests/strategies/ddp_model.py +++ b/tests/tests_pytorch/strategies/ddp_model.py @@ -18,8 +18,8 @@ import torch from pytorch_lightning import seed_everything, Trainer -from tests.helpers.datamodules import ClassifDataModule -from tests.helpers.simple_models import ClassificationModel +from tests_pytorch.helpers.datamodules import ClassifDataModule +from tests_pytorch.helpers.simple_models import ClassificationModel def main(): diff --git a/tests/strategies/test_bagua_strategy.py b/tests/tests_pytorch/strategies/test_bagua_strategy.py similarity index 98% rename from tests/strategies/test_bagua_strategy.py rename to tests/tests_pytorch/strategies/test_bagua_strategy.py index 3f5c486d6cb83..c9ccae43edbf3 100644 --- a/tests/strategies/test_bagua_strategy.py +++ b/tests/tests_pytorch/strategies/test_bagua_strategy.py @@ -21,7 +21,7 @@ from pytorch_lightning.strategies import BaguaStrategy from pytorch_lightning.trainer.states import TrainerFn from pytorch_lightning.utilities.exceptions import MisconfigurationException -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.runif import RunIf class BoringModel4QAdam(BoringModel): diff --git a/tests/strategies/test_collaborative.py b/tests/tests_pytorch/strategies/test_collaborative.py similarity index 99% rename from tests/strategies/test_collaborative.py rename to tests/tests_pytorch/strategies/test_collaborative.py index 9d64cb30f9538..fefb5c13e0db1 100644 --- a/tests/strategies/test_collaborative.py +++ b/tests/tests_pytorch/strategies/test_collaborative.py @@ -18,7 +18,7 @@ from pytorch_lightning.utilities import _HIVEMIND_AVAILABLE from pytorch_lightning.utilities.exceptions import MisconfigurationException from pytorch_lightning.utilities.types import STEP_OUTPUT -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.runif import RunIf if _HIVEMIND_AVAILABLE: import hivemind diff --git a/tests/strategies/test_common.py b/tests/tests_pytorch/strategies/test_common.py similarity index 92% rename from tests/strategies/test_common.py rename to tests/tests_pytorch/strategies/test_common.py index f61be03a72fee..489ecaed2968d 100644 --- a/tests/strategies/test_common.py +++ b/tests/tests_pytorch/strategies/test_common.py @@ -14,14 +14,14 @@ import pytest import torch -import tests.helpers.utils as tutils +import tests_pytorch.helpers.utils as tutils from pytorch_lightning import Trainer from pytorch_lightning.demos.boring_classes import BoringModel from pytorch_lightning.strategies import DDPStrategy from pytorch_lightning.utilities.seed import seed_everything -from tests.helpers.datamodules import ClassifDataModule -from tests.helpers.runif import RunIf -from tests.strategies.test_dp import CustomClassificationModelDP +from tests_pytorch.helpers.datamodules import ClassifDataModule +from tests_pytorch.helpers.runif import RunIf +from tests_pytorch.strategies.test_dp import CustomClassificationModelDP @pytest.mark.parametrize( diff --git a/tests/strategies/test_custom_plugin.py b/tests/tests_pytorch/strategies/test_custom_plugin.py similarity index 100% rename from tests/strategies/test_custom_plugin.py rename to tests/tests_pytorch/strategies/test_custom_plugin.py diff --git a/tests/strategies/test_ddp.py b/tests/tests_pytorch/strategies/test_ddp.py similarity index 97% rename from tests/strategies/test_ddp.py rename to tests/tests_pytorch/strategies/test_ddp.py index 75652d8e3d693..58fa28559b97f 100644 --- a/tests/strategies/test_ddp.py +++ b/tests/tests_pytorch/strategies/test_ddp.py @@ -25,9 +25,9 @@ from pytorch_lightning.callbacks import Callback from pytorch_lightning.demos.boring_classes import BoringModel from pytorch_lightning.strategies import DDPStrategy -from tests.helpers.runif import RunIf -from tests.strategies import ddp_model -from tests.utilities.distributed import call_training_script +from tests_pytorch.helpers.runif import RunIf +from tests_pytorch.strategies import ddp_model +from tests_pytorch.utilities.distributed import call_training_script CLI_ARGS = "--max_epochs 1 --accelerator gpu --devices 2 --strategy ddp" diff --git a/tests/strategies/test_ddp_fully_sharded_native.py b/tests/tests_pytorch/strategies/test_ddp_fully_sharded_native.py similarity index 99% rename from tests/strategies/test_ddp_fully_sharded_native.py rename to tests/tests_pytorch/strategies/test_ddp_fully_sharded_native.py index 5df507457e187..b6dbff1792668 100644 --- a/tests/strategies/test_ddp_fully_sharded_native.py +++ b/tests/tests_pytorch/strategies/test_ddp_fully_sharded_native.py @@ -11,7 +11,7 @@ from pytorch_lightning.strategies import DDPFullyShardedNativeStrategy from pytorch_lightning.utilities.exceptions import MisconfigurationException from pytorch_lightning.utilities.imports import _TORCH_GREATER_EQUAL_1_12 -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.runif import RunIf if _TORCH_GREATER_EQUAL_1_12: from torch.distributed.fsdp.fully_sharded_data_parallel import FullyShardedDataParallel diff --git a/tests/strategies/test_ddp_fully_sharded_with_full_state_dict.py b/tests/tests_pytorch/strategies/test_ddp_fully_sharded_with_full_state_dict.py similarity index 99% rename from tests/strategies/test_ddp_fully_sharded_with_full_state_dict.py rename to tests/tests_pytorch/strategies/test_ddp_fully_sharded_with_full_state_dict.py index d03bcecdfd148..c1120fa4e2be9 100644 --- a/tests/strategies/test_ddp_fully_sharded_with_full_state_dict.py +++ b/tests/tests_pytorch/strategies/test_ddp_fully_sharded_with_full_state_dict.py @@ -12,7 +12,7 @@ from pytorch_lightning.strategies import DDPFullyShardedStrategy from pytorch_lightning.utilities import _FAIRSCALE_FULLY_SHARDED_AVAILABLE from pytorch_lightning.utilities.exceptions import MisconfigurationException -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.runif import RunIf if _FAIRSCALE_FULLY_SHARDED_AVAILABLE: from fairscale.nn import FullyShardedDataParallel, wrap diff --git a/tests/strategies/test_ddp_spawn.py b/tests/tests_pytorch/strategies/test_ddp_spawn.py similarity index 89% rename from tests/strategies/test_ddp_spawn.py rename to tests/tests_pytorch/strategies/test_ddp_spawn.py index 1cc4f7deea600..e226a48712c07 100644 --- a/tests/strategies/test_ddp_spawn.py +++ b/tests/tests_pytorch/strategies/test_ddp_spawn.py @@ -11,14 +11,14 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -import tests.helpers.pipelines as tpipes -import tests.helpers.utils as tutils +import tests_pytorch.helpers.pipelines as tpipes +import tests_pytorch.helpers.utils as tutils from pytorch_lightning.callbacks import EarlyStopping from pytorch_lightning.demos.boring_classes import BoringModel from pytorch_lightning.trainer import Trainer -from tests.helpers.datamodules import ClassifDataModule -from tests.helpers.runif import RunIf -from tests.helpers.simple_models import ClassificationModel +from tests_pytorch.helpers.datamodules import ClassifDataModule +from tests_pytorch.helpers.runif import RunIf +from tests_pytorch.helpers.simple_models import ClassificationModel @RunIf(min_cuda_gpus=2) diff --git a/tests/strategies/test_ddp_spawn_strategy.py b/tests/tests_pytorch/strategies/test_ddp_spawn_strategy.py similarity index 99% rename from tests/strategies/test_ddp_spawn_strategy.py rename to tests/tests_pytorch/strategies/test_ddp_spawn_strategy.py index 3f471366bcd6d..073eef6069132 100644 --- a/tests/strategies/test_ddp_spawn_strategy.py +++ b/tests/tests_pytorch/strategies/test_ddp_spawn_strategy.py @@ -23,7 +23,7 @@ from pytorch_lightning.strategies import DDPSpawnStrategy from pytorch_lightning.strategies.launchers.spawn import _SpawnLauncher from pytorch_lightning.trainer.states import TrainerFn -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.runif import RunIf class BoringModelDDPCPU(BoringModel): diff --git a/tests/strategies/test_ddp_strategy.py b/tests/tests_pytorch/strategies/test_ddp_strategy.py similarity index 99% rename from tests/strategies/test_ddp_strategy.py rename to tests/tests_pytorch/strategies/test_ddp_strategy.py index 91372ca945055..c51cecb77df26 100644 --- a/tests/strategies/test_ddp_strategy.py +++ b/tests/tests_pytorch/strategies/test_ddp_strategy.py @@ -23,7 +23,7 @@ from pytorch_lightning.plugins.environments import ClusterEnvironment, LightningEnvironment from pytorch_lightning.strategies import DDPStrategy from pytorch_lightning.trainer.states import TrainerFn -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.runif import RunIf class BoringModelGPU(BoringModel): diff --git a/tests/strategies/test_ddp_strategy_with_comm_hook.py b/tests/tests_pytorch/strategies/test_ddp_strategy_with_comm_hook.py similarity index 99% rename from tests/strategies/test_ddp_strategy_with_comm_hook.py rename to tests/tests_pytorch/strategies/test_ddp_strategy_with_comm_hook.py index 39fae166149a3..a77b3558b991b 100644 --- a/tests/strategies/test_ddp_strategy_with_comm_hook.py +++ b/tests/tests_pytorch/strategies/test_ddp_strategy_with_comm_hook.py @@ -20,7 +20,7 @@ from pytorch_lightning.demos.boring_classes import BoringModel from pytorch_lightning.strategies import DDPSpawnStrategy, DDPStrategy from pytorch_lightning.utilities import _TORCH_GREATER_EQUAL_1_10 -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.runif import RunIf if torch.distributed.is_available(): from torch.distributed.algorithms.ddp_comm_hooks import default_hooks as default diff --git a/tests/strategies/test_deepspeed_strategy.py b/tests/tests_pytorch/strategies/test_deepspeed_strategy.py similarity index 99% rename from tests/strategies/test_deepspeed_strategy.py rename to tests/tests_pytorch/strategies/test_deepspeed_strategy.py index 0ee90035bda9c..2306aeb045c20 100644 --- a/tests/strategies/test_deepspeed_strategy.py +++ b/tests/tests_pytorch/strategies/test_deepspeed_strategy.py @@ -39,9 +39,9 @@ _DEEPSPEED_GREATER_EQUAL_0_6, ) from pytorch_lightning.utilities.meta import init_meta_context -from tests.helpers.datamodules import ClassifDataModule -from tests.helpers.datasets import RandomIterableDataset -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.datamodules import ClassifDataModule +from tests_pytorch.helpers.datasets import RandomIterableDataset +from tests_pytorch.helpers.runif import RunIf if _DEEPSPEED_AVAILABLE: import deepspeed diff --git a/tests/strategies/test_dp.py b/tests/tests_pytorch/strategies/test_dp.py similarity index 96% rename from tests/strategies/test_dp.py rename to tests/tests_pytorch/strategies/test_dp.py index 9118a48c89a24..4a1c504e12bf8 100644 --- a/tests/strategies/test_dp.py +++ b/tests/tests_pytorch/strategies/test_dp.py @@ -19,15 +19,15 @@ from torch.utils.data import DataLoader import pytorch_lightning as pl -import tests.helpers.pipelines as tpipes -import tests.helpers.utils as tutils +import tests_pytorch.helpers.pipelines as tpipes +import tests_pytorch.helpers.utils as tutils from pytorch_lightning import Trainer from pytorch_lightning.callbacks import EarlyStopping from pytorch_lightning.demos.boring_classes import BoringModel, RandomDataset from pytorch_lightning.utilities.exceptions import MisconfigurationException -from tests.helpers.datamodules import ClassifDataModule -from tests.helpers.runif import RunIf -from tests.helpers.simple_models import ClassificationModel +from tests_pytorch.helpers.datamodules import ClassifDataModule +from tests_pytorch.helpers.runif import RunIf +from tests_pytorch.helpers.simple_models import ClassificationModel class CustomClassificationModelDP(ClassificationModel): diff --git a/tests/strategies/test_sharded_strategy.py b/tests/tests_pytorch/strategies/test_sharded_strategy.py similarity index 99% rename from tests/strategies/test_sharded_strategy.py rename to tests/tests_pytorch/strategies/test_sharded_strategy.py index 10454308ff4e8..92132a1f634d1 100644 --- a/tests/strategies/test_sharded_strategy.py +++ b/tests/tests_pytorch/strategies/test_sharded_strategy.py @@ -10,7 +10,7 @@ from pytorch_lightning.strategies import DDPShardedStrategy, DDPSpawnShardedStrategy from pytorch_lightning.trainer.states import TrainerFn from pytorch_lightning.utilities import _FAIRSCALE_AVAILABLE -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.runif import RunIf if _FAIRSCALE_AVAILABLE: from fairscale.nn.data_parallel.sharded_ddp import ShardedDataParallel diff --git a/tests/strategies/test_single_device_strategy.py b/tests/tests_pytorch/strategies/test_single_device_strategy.py similarity index 98% rename from tests/strategies/test_single_device_strategy.py rename to tests/tests_pytorch/strategies/test_single_device_strategy.py index 871cf2d1f9788..65933e30a87d7 100644 --- a/tests/strategies/test_single_device_strategy.py +++ b/tests/tests_pytorch/strategies/test_single_device_strategy.py @@ -19,7 +19,7 @@ from pytorch_lightning.core.optimizer import LightningOptimizer from pytorch_lightning.demos.boring_classes import BoringModel from pytorch_lightning.strategies import SingleDeviceStrategy -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.runif import RunIf def test_single_cpu(): diff --git a/tests/strategies/test_strategy_registry.py b/tests/tests_pytorch/strategies/test_strategy_registry.py similarity index 99% rename from tests/strategies/test_strategy_registry.py rename to tests/tests_pytorch/strategies/test_strategy_registry.py index 89422b3719a29..5f9e6208c4fa5 100644 --- a/tests/strategies/test_strategy_registry.py +++ b/tests/tests_pytorch/strategies/test_strategy_registry.py @@ -25,7 +25,7 @@ StrategyRegistry, TPUSpawnStrategy, ) -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.runif import RunIf def test_strategy_registry_with_new_strategy(): diff --git a/tests/strategies/test_tpu_spawn.py b/tests/tests_pytorch/strategies/test_tpu_spawn.py similarity index 94% rename from tests/strategies/test_tpu_spawn.py rename to tests/tests_pytorch/strategies/test_tpu_spawn.py index ffd4f64eb01f9..246df92c45e46 100644 --- a/tests/strategies/test_tpu_spawn.py +++ b/tests/tests_pytorch/strategies/test_tpu_spawn.py @@ -23,9 +23,9 @@ from pytorch_lightning.demos.boring_classes import BoringModel, RandomDataset from pytorch_lightning.strategies import TPUSpawnStrategy from pytorch_lightning.utilities.exceptions import MisconfigurationException -from tests.helpers.dataloaders import CustomNotImplementedErrorDataloader -from tests.helpers.runif import RunIf -from tests.helpers.utils import pl_multi_process_test +from tests_pytorch.helpers.dataloaders import CustomNotImplementedErrorDataloader +from tests_pytorch.helpers.runif import RunIf +from tests_pytorch.helpers.utils import pl_multi_process_test class BoringModelNoDataloaders(BoringModel): diff --git a/tests/trainer/__init__.py b/tests/tests_pytorch/trainer/__init__.py similarity index 100% rename from tests/trainer/__init__.py rename to tests/tests_pytorch/trainer/__init__.py diff --git a/tests/trainer/connectors/__init__.py b/tests/tests_pytorch/trainer/connectors/__init__.py similarity index 100% rename from tests/trainer/connectors/__init__.py rename to tests/tests_pytorch/trainer/connectors/__init__.py diff --git a/tests/trainer/connectors/test_callback_connector.py b/tests/tests_pytorch/trainer/connectors/test_callback_connector.py similarity index 100% rename from tests/trainer/connectors/test_callback_connector.py rename to tests/tests_pytorch/trainer/connectors/test_callback_connector.py diff --git a/tests/trainer/connectors/test_checkpoint_connector.py b/tests/tests_pytorch/trainer/connectors/test_checkpoint_connector.py similarity index 100% rename from tests/trainer/connectors/test_checkpoint_connector.py rename to tests/tests_pytorch/trainer/connectors/test_checkpoint_connector.py diff --git a/tests/trainer/connectors/test_data_connector.py b/tests/tests_pytorch/trainer/connectors/test_data_connector.py similarity index 99% rename from tests/trainer/connectors/test_data_connector.py rename to tests/tests_pytorch/trainer/connectors/test_data_connector.py index 293101e83fde2..c24b088b7673c 100644 --- a/tests/trainer/connectors/test_data_connector.py +++ b/tests/tests_pytorch/trainer/connectors/test_data_connector.py @@ -28,8 +28,8 @@ from pytorch_lightning.utilities.data import _update_dataloader from pytorch_lightning.utilities.exceptions import MisconfigurationException from pytorch_lightning.utilities.warnings import PossibleUserWarning -from tests.helpers.runif import RunIf -from tests.helpers.utils import no_warning_call +from tests_pytorch.helpers.runif import RunIf +from tests_pytorch.helpers.utils import no_warning_call @RunIf(skip_windows=True) diff --git a/tests/trainer/connectors/test_signal_connector.py b/tests/tests_pytorch/trainer/connectors/test_signal_connector.py similarity index 99% rename from tests/trainer/connectors/test_signal_connector.py rename to tests/tests_pytorch/trainer/connectors/test_signal_connector.py index ff878a2325557..d83faa3cec6aa 100644 --- a/tests/trainer/connectors/test_signal_connector.py +++ b/tests/tests_pytorch/trainer/connectors/test_signal_connector.py @@ -24,7 +24,7 @@ from pytorch_lightning.plugins.environments import SLURMEnvironment from pytorch_lightning.trainer.connectors.signal_connector import SignalConnector from pytorch_lightning.utilities.exceptions import ExitGracefullyException -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.runif import RunIf @RunIf(skip_windows=True) diff --git a/tests/trainer/dynamic_args/__init__.py b/tests/tests_pytorch/trainer/dynamic_args/__init__.py similarity index 100% rename from tests/trainer/dynamic_args/__init__.py rename to tests/tests_pytorch/trainer/dynamic_args/__init__.py diff --git a/tests/trainer/dynamic_args/test_multiple_eval_dataloaders.py b/tests/tests_pytorch/trainer/dynamic_args/test_multiple_eval_dataloaders.py similarity index 100% rename from tests/trainer/dynamic_args/test_multiple_eval_dataloaders.py rename to tests/tests_pytorch/trainer/dynamic_args/test_multiple_eval_dataloaders.py diff --git a/tests/trainer/flags/__init__.py b/tests/tests_pytorch/trainer/flags/__init__.py similarity index 100% rename from tests/trainer/flags/__init__.py rename to tests/tests_pytorch/trainer/flags/__init__.py diff --git a/tests/trainer/flags/test_check_val_every_n_epoch.py b/tests/tests_pytorch/trainer/flags/test_check_val_every_n_epoch.py similarity index 100% rename from tests/trainer/flags/test_check_val_every_n_epoch.py rename to tests/tests_pytorch/trainer/flags/test_check_val_every_n_epoch.py diff --git a/tests/trainer/flags/test_env_vars.py b/tests/tests_pytorch/trainer/flags/test_env_vars.py similarity index 100% rename from tests/trainer/flags/test_env_vars.py rename to tests/tests_pytorch/trainer/flags/test_env_vars.py diff --git a/tests/trainer/flags/test_fast_dev_run.py b/tests/tests_pytorch/trainer/flags/test_fast_dev_run.py similarity index 100% rename from tests/trainer/flags/test_fast_dev_run.py rename to tests/tests_pytorch/trainer/flags/test_fast_dev_run.py diff --git a/tests/trainer/flags/test_limit_batches.py b/tests/tests_pytorch/trainer/flags/test_limit_batches.py similarity index 100% rename from tests/trainer/flags/test_limit_batches.py rename to tests/tests_pytorch/trainer/flags/test_limit_batches.py diff --git a/tests/trainer/flags/test_min_max_epochs.py b/tests/tests_pytorch/trainer/flags/test_min_max_epochs.py similarity index 100% rename from tests/trainer/flags/test_min_max_epochs.py rename to tests/tests_pytorch/trainer/flags/test_min_max_epochs.py diff --git a/tests/trainer/flags/test_overfit_batches.py b/tests/tests_pytorch/trainer/flags/test_overfit_batches.py similarity index 99% rename from tests/trainer/flags/test_overfit_batches.py rename to tests/tests_pytorch/trainer/flags/test_overfit_batches.py index 9d028d07807eb..32f0b8938caf6 100644 --- a/tests/trainer/flags/test_overfit_batches.py +++ b/tests/tests_pytorch/trainer/flags/test_overfit_batches.py @@ -13,13 +13,13 @@ # limitations under the License. import pytest import torch +from legacy.simple_classif_training import ClassifDataModule, ClassificationModel from torch.utils.data import DataLoader, DistributedSampler, RandomSampler, Sampler, SequentialSampler -from legacy.simple_classif_training import ClassifDataModule, ClassificationModel from pytorch_lightning import Trainer from pytorch_lightning.demos.boring_classes import BoringModel, RandomDataset from pytorch_lightning.trainer.states import RunningStage -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.runif import RunIf @pytest.mark.parametrize("overfit_batches", [1, 2, 0.1, 0.25, 1.0]) diff --git a/tests/trainer/flags/test_val_check_interval.py b/tests/tests_pytorch/trainer/flags/test_val_check_interval.py similarity index 98% rename from tests/trainer/flags/test_val_check_interval.py rename to tests/tests_pytorch/trainer/flags/test_val_check_interval.py index eb75ed8d0db4b..b0559b9daa11f 100644 --- a/tests/trainer/flags/test_val_check_interval.py +++ b/tests/tests_pytorch/trainer/flags/test_val_check_interval.py @@ -19,7 +19,7 @@ from pytorch_lightning.demos.boring_classes import BoringModel, RandomDataset from pytorch_lightning.trainer.trainer import Trainer from pytorch_lightning.utilities.exceptions import MisconfigurationException -from tests.helpers.datasets import RandomIterableDataset +from tests_pytorch.helpers.datasets import RandomIterableDataset @pytest.mark.parametrize("max_epochs", [1, 2, 3]) diff --git a/tests/trainer/logging_/__init__.py b/tests/tests_pytorch/trainer/logging_/__init__.py similarity index 100% rename from tests/trainer/logging_/__init__.py rename to tests/tests_pytorch/trainer/logging_/__init__.py diff --git a/tests/trainer/logging_/test_distributed_logging.py b/tests/tests_pytorch/trainer/logging_/test_distributed_logging.py similarity index 99% rename from tests/trainer/logging_/test_distributed_logging.py rename to tests/tests_pytorch/trainer/logging_/test_distributed_logging.py index fe67daf2e4b15..ff950f7a8f679 100644 --- a/tests/trainer/logging_/test_distributed_logging.py +++ b/tests/tests_pytorch/trainer/logging_/test_distributed_logging.py @@ -19,7 +19,7 @@ from pytorch_lightning import Callback, Trainer from pytorch_lightning.demos.boring_classes import BoringModel from pytorch_lightning.loggers.logger import Logger -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.runif import RunIf class AllRankLogger(Logger): diff --git a/tests/trainer/logging_/test_eval_loop_logging.py b/tests/tests_pytorch/trainer/logging_/test_eval_loop_logging.py similarity index 99% rename from tests/trainer/logging_/test_eval_loop_logging.py rename to tests/tests_pytorch/trainer/logging_/test_eval_loop_logging.py index ff6ebce8d4ac4..b21abf51e8464 100644 --- a/tests/trainer/logging_/test_eval_loop_logging.py +++ b/tests/tests_pytorch/trainer/logging_/test_eval_loop_logging.py @@ -31,7 +31,7 @@ from pytorch_lightning.trainer.states import RunningStage from pytorch_lightning.utilities.exceptions import MisconfigurationException from pytorch_lightning.utilities.imports import _PYTHON_GREATER_EQUAL_3_8_0, _RICH_AVAILABLE -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.runif import RunIf if _RICH_AVAILABLE: from rich import get_console diff --git a/tests/trainer/logging_/test_logger_connector.py b/tests/tests_pytorch/trainer/logging_/test_logger_connector.py similarity index 99% rename from tests/trainer/logging_/test_logger_connector.py rename to tests/tests_pytorch/trainer/logging_/test_logger_connector.py index 5290e39c384e0..681c4a7732f3d 100644 --- a/tests/trainer/logging_/test_logger_connector.py +++ b/tests/tests_pytorch/trainer/logging_/test_logger_connector.py @@ -26,8 +26,8 @@ from pytorch_lightning.trainer.connectors.logger_connector.fx_validator import _FxValidator from pytorch_lightning.trainer.connectors.logger_connector.result import _ResultCollection from pytorch_lightning.utilities.exceptions import MisconfigurationException -from tests.helpers.runif import RunIf -from tests.models.test_hooks import get_members +from tests_pytorch.helpers.runif import RunIf +from tests_pytorch.models.test_hooks import get_members def test_fx_validator(): diff --git a/tests/trainer/logging_/test_loop_logging.py b/tests/tests_pytorch/trainer/logging_/test_loop_logging.py similarity index 100% rename from tests/trainer/logging_/test_loop_logging.py rename to tests/tests_pytorch/trainer/logging_/test_loop_logging.py diff --git a/tests/trainer/logging_/test_progress_bar_logging.py b/tests/tests_pytorch/trainer/logging_/test_progress_bar_logging.py similarity index 100% rename from tests/trainer/logging_/test_progress_bar_logging.py rename to tests/tests_pytorch/trainer/logging_/test_progress_bar_logging.py diff --git a/tests/trainer/logging_/test_train_loop_logging.py b/tests/tests_pytorch/trainer/logging_/test_train_loop_logging.py similarity index 99% rename from tests/trainer/logging_/test_train_loop_logging.py rename to tests/tests_pytorch/trainer/logging_/test_train_loop_logging.py index 47dea02a6e42f..1d5f10f571339 100644 --- a/tests/trainer/logging_/test_train_loop_logging.py +++ b/tests/tests_pytorch/trainer/logging_/test_train_loop_logging.py @@ -30,8 +30,8 @@ from pytorch_lightning.core.module import LightningModule from pytorch_lightning.demos.boring_classes import BoringModel, RandomDataset from pytorch_lightning.utilities.exceptions import MisconfigurationException -from tests.helpers.datasets import RandomDictDataset -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.datasets import RandomDictDataset +from tests_pytorch.helpers.runif import RunIf def test__training_step__log(tmpdir): diff --git a/tests/trainer/optimization/__init__.py b/tests/tests_pytorch/trainer/optimization/__init__.py similarity index 100% rename from tests/trainer/optimization/__init__.py rename to tests/tests_pytorch/trainer/optimization/__init__.py diff --git a/tests/trainer/optimization/test_backward_calls.py b/tests/tests_pytorch/trainer/optimization/test_backward_calls.py similarity index 100% rename from tests/trainer/optimization/test_backward_calls.py rename to tests/tests_pytorch/trainer/optimization/test_backward_calls.py diff --git a/tests/trainer/optimization/test_manual_optimization.py b/tests/tests_pytorch/trainer/optimization/test_manual_optimization.py similarity index 99% rename from tests/trainer/optimization/test_manual_optimization.py rename to tests/tests_pytorch/trainer/optimization/test_manual_optimization.py index 7d4d60fcbde90..fd44184645b12 100644 --- a/tests/trainer/optimization/test_manual_optimization.py +++ b/tests/tests_pytorch/trainer/optimization/test_manual_optimization.py @@ -24,7 +24,7 @@ from pytorch_lightning import seed_everything, Trainer from pytorch_lightning.demos.boring_classes import BoringModel from pytorch_lightning.strategies import Strategy -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.runif import RunIf class ManualOptModel(BoringModel): diff --git a/tests/trainer/optimization/test_multiple_optimizers.py b/tests/tests_pytorch/trainer/optimization/test_multiple_optimizers.py similarity index 100% rename from tests/trainer/optimization/test_multiple_optimizers.py rename to tests/tests_pytorch/trainer/optimization/test_multiple_optimizers.py diff --git a/tests/trainer/optimization/test_optimizers.py b/tests/tests_pytorch/trainer/optimization/test_optimizers.py similarity index 99% rename from tests/trainer/optimization/test_optimizers.py rename to tests/tests_pytorch/trainer/optimization/test_optimizers.py index cbd76f9bc5593..e7554fa2e6422 100644 --- a/tests/trainer/optimization/test_optimizers.py +++ b/tests/tests_pytorch/trainer/optimization/test_optimizers.py @@ -28,7 +28,7 @@ from pytorch_lightning.demos.boring_classes import BoringDataModule, BoringModel from pytorch_lightning.utilities.exceptions import MisconfigurationException from pytorch_lightning.utilities.types import LRSchedulerConfig -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.runif import RunIf def test_optimizer_with_scheduling(tmpdir): diff --git a/tests/trainer/properties/__init__.py b/tests/tests_pytorch/trainer/properties/__init__.py similarity index 100% rename from tests/trainer/properties/__init__.py rename to tests/tests_pytorch/trainer/properties/__init__.py diff --git a/tests/trainer/properties/test_auto_gpu_select.py b/tests/tests_pytorch/trainer/properties/test_auto_gpu_select.py similarity index 98% rename from tests/trainer/properties/test_auto_gpu_select.py rename to tests/tests_pytorch/trainer/properties/test_auto_gpu_select.py index 4413666ae3972..3800f5bc8c529 100644 --- a/tests/trainer/properties/test_auto_gpu_select.py +++ b/tests/tests_pytorch/trainer/properties/test_auto_gpu_select.py @@ -20,7 +20,7 @@ from pytorch_lightning import Trainer from pytorch_lightning.tuner.auto_gpu_select import pick_multiple_gpus from pytorch_lightning.utilities.exceptions import MisconfigurationException -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.runif import RunIf @RunIf(min_cuda_gpus=2) diff --git a/tests/trainer/properties/test_estimated_stepping_batches.py b/tests/tests_pytorch/trainer/properties/test_estimated_stepping_batches.py similarity index 97% rename from tests/trainer/properties/test_estimated_stepping_batches.py rename to tests/tests_pytorch/trainer/properties/test_estimated_stepping_batches.py index f1e8b6dad1b1c..ab19002d751a2 100644 --- a/tests/trainer/properties/test_estimated_stepping_batches.py +++ b/tests/tests_pytorch/trainer/properties/test_estimated_stepping_batches.py @@ -24,9 +24,9 @@ from pytorch_lightning.demos.boring_classes import BoringModel from pytorch_lightning.strategies.ipu import IPUStrategy from pytorch_lightning.utilities.exceptions import MisconfigurationException -from tests.helpers.datasets import RandomIterableDataset -from tests.helpers.runif import RunIf -from tests.helpers.utils import pl_multi_process_test +from tests_pytorch.helpers.datasets import RandomIterableDataset +from tests_pytorch.helpers.runif import RunIf +from tests_pytorch.helpers.utils import pl_multi_process_test def test_num_stepping_batches_basic(): diff --git a/tests/trainer/properties/test_get_model.py b/tests/tests_pytorch/trainer/properties/test_get_model.py similarity index 97% rename from tests/trainer/properties/test_get_model.py rename to tests/tests_pytorch/trainer/properties/test_get_model.py index 65b6d6a5fa1db..f6aec2210adaa 100644 --- a/tests/trainer/properties/test_get_model.py +++ b/tests/tests_pytorch/trainer/properties/test_get_model.py @@ -14,7 +14,7 @@ from pytorch_lightning import Trainer from pytorch_lightning.demos.boring_classes import BoringModel -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.runif import RunIf class TrainerGetModel(BoringModel): diff --git a/tests/trainer/properties/test_log_dir.py b/tests/tests_pytorch/trainer/properties/test_log_dir.py similarity index 100% rename from tests/trainer/properties/test_log_dir.py rename to tests/tests_pytorch/trainer/properties/test_log_dir.py diff --git a/tests/trainer/properties/test_loggers.py b/tests/tests_pytorch/trainer/properties/test_loggers.py similarity index 98% rename from tests/trainer/properties/test_loggers.py rename to tests/tests_pytorch/trainer/properties/test_loggers.py index ac3a01cba3698..986596fc8b0a3 100644 --- a/tests/trainer/properties/test_loggers.py +++ b/tests/tests_pytorch/trainer/properties/test_loggers.py @@ -16,7 +16,7 @@ from pytorch_lightning import Trainer from pytorch_lightning.loggers import LoggerCollection, TensorBoardLogger -from tests.loggers.test_logger import CustomLogger +from tests_pytorch.loggers.test_logger import CustomLogger def test_trainer_loggers_property(): diff --git a/tests/trainer/test_config_validator.py b/tests/tests_pytorch/trainer/test_config_validator.py similarity index 100% rename from tests/trainer/test_config_validator.py rename to tests/tests_pytorch/trainer/test_config_validator.py diff --git a/tests/trainer/test_dataloaders.py b/tests/tests_pytorch/trainer/test_dataloaders.py similarity index 99% rename from tests/trainer/test_dataloaders.py rename to tests/tests_pytorch/trainer/test_dataloaders.py index b99cb316cd5c2..6b01150c80857 100644 --- a/tests/trainer/test_dataloaders.py +++ b/tests/tests_pytorch/trainer/test_dataloaders.py @@ -29,9 +29,9 @@ from pytorch_lightning.trainer.states import RunningStage from pytorch_lightning.utilities.data import _auto_add_worker_init_fn, has_iterable_dataset, has_len_all_ranks from pytorch_lightning.utilities.exceptions import MisconfigurationException -from tests.helpers.dataloaders import CustomInfDataloader, CustomNotImplementedErrorDataloader -from tests.helpers.datasets import RandomIterableDataset, RandomIterableDatasetWithLen -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.dataloaders import CustomInfDataloader, CustomNotImplementedErrorDataloader +from tests_pytorch.helpers.datasets import RandomIterableDataset, RandomIterableDatasetWithLen +from tests_pytorch.helpers.runif import RunIf class MultiValDataLoaderBoringModel(BoringModel): diff --git a/tests/trainer/test_progress.py b/tests/tests_pytorch/trainer/test_progress.py similarity index 100% rename from tests/trainer/test_progress.py rename to tests/tests_pytorch/trainer/test_progress.py diff --git a/tests/trainer/test_states.py b/tests/tests_pytorch/trainer/test_states.py similarity index 100% rename from tests/trainer/test_states.py rename to tests/tests_pytorch/trainer/test_states.py diff --git a/tests/trainer/test_supporters.py b/tests/tests_pytorch/trainer/test_supporters.py similarity index 99% rename from tests/trainer/test_supporters.py rename to tests/tests_pytorch/trainer/test_supporters.py index a442ff106e354..22b10c8451b70 100644 --- a/tests/trainer/test_supporters.py +++ b/tests/tests_pytorch/trainer/test_supporters.py @@ -37,7 +37,7 @@ from pytorch_lightning.utilities.auto_restart import CaptureMapDataset, FastForwardSampler from pytorch_lightning.utilities.data import get_len from pytorch_lightning.utilities.exceptions import MisconfigurationException -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.runif import RunIf def test_tensor_running_accum_reset(): diff --git a/tests/trainer/test_trainer.py b/tests/tests_pytorch/trainer/test_trainer.py similarity index 99% rename from tests/trainer/test_trainer.py rename to tests/tests_pytorch/trainer/test_trainer.py index a5d64dfbbbc27..3069b589bb448 100644 --- a/tests/trainer/test_trainer.py +++ b/tests/tests_pytorch/trainer/test_trainer.py @@ -33,7 +33,7 @@ from torch.utils.data import DataLoader, IterableDataset import pytorch_lightning -import tests.helpers.utils as tutils +import tests_pytorch.helpers.utils as tutils from pytorch_lightning import Callback, LightningDataModule, LightningModule, Trainer from pytorch_lightning.accelerators import CPUAccelerator, GPUAccelerator from pytorch_lightning.callbacks import EarlyStopping, GradientAccumulationScheduler, ModelCheckpoint, Timer @@ -58,10 +58,10 @@ from pytorch_lightning.utilities.exceptions import DeadlockDetectedException, MisconfigurationException from pytorch_lightning.utilities.imports import _OMEGACONF_AVAILABLE from pytorch_lightning.utilities.seed import seed_everything -from tests.helpers.datamodules import ClassifDataModule -from tests.helpers.datasets import RandomIterableDataset, RandomIterableDatasetWithLen -from tests.helpers.runif import RunIf -from tests.helpers.simple_models import ClassificationModel +from tests_pytorch.helpers.datamodules import ClassifDataModule +from tests_pytorch.helpers.datasets import RandomIterableDataset, RandomIterableDatasetWithLen +from tests_pytorch.helpers.runif import RunIf +from tests_pytorch.helpers.simple_models import ClassificationModel if _OMEGACONF_AVAILABLE: from omegaconf import OmegaConf @@ -401,7 +401,7 @@ def test_model_freeze_unfreeze(): assert param.requires_grad -# TODO: move to `test/models/test_restore.py` +# TODO: move to `tests/tests_pytorch/models/test_restore.py` @pytest.mark.parametrize("url_ckpt", [True, False]) def test_fit_ckpt_path_epoch_restored(monkeypatch, tmpdir, tmpdir_server, url_ckpt): """Verify resuming from checkpoint runs the right number of epochs.""" diff --git a/tests/trainer/test_trainer_cli.py b/tests/tests_pytorch/trainer/test_trainer_cli.py similarity index 99% rename from tests/trainer/test_trainer_cli.py rename to tests/tests_pytorch/trainer/test_trainer_cli.py index 37a02e895d560..989a06f4193ed 100644 --- a/tests/trainer/test_trainer_cli.py +++ b/tests/tests_pytorch/trainer/test_trainer_cli.py @@ -19,7 +19,7 @@ import pytest import torch -import tests.helpers.utils as tutils +import tests_pytorch.helpers.utils as tutils from pytorch_lightning import Trainer from pytorch_lightning.utilities import argparse diff --git a/tests/tuner/__init__.py b/tests/tests_pytorch/tuner/__init__.py similarity index 100% rename from tests/tuner/__init__.py rename to tests/tests_pytorch/tuner/__init__.py diff --git a/tests/tuner/test_lr_finder.py b/tests/tests_pytorch/tuner/test_lr_finder.py similarity index 98% rename from tests/tuner/test_lr_finder.py rename to tests/tests_pytorch/tuner/test_lr_finder.py index 76ade3296e2c6..529ef1c4c08c1 100644 --- a/tests/tuner/test_lr_finder.py +++ b/tests/tests_pytorch/tuner/test_lr_finder.py @@ -20,9 +20,9 @@ from pytorch_lightning import seed_everything, Trainer from pytorch_lightning.demos.boring_classes import BoringModel from pytorch_lightning.utilities.exceptions import MisconfigurationException -from tests.helpers.datamodules import ClassifDataModule -from tests.helpers.simple_models import ClassificationModel -from tests.helpers.utils import no_warning_call +from tests_pytorch.helpers.datamodules import ClassifDataModule +from tests_pytorch.helpers.simple_models import ClassificationModel +from tests_pytorch.helpers.utils import no_warning_call def test_error_on_more_than_1_optimizer(tmpdir): diff --git a/tests/tuner/test_scale_batch_size.py b/tests/tests_pytorch/tuner/test_scale_batch_size.py similarity index 98% rename from tests/tuner/test_scale_batch_size.py rename to tests/tests_pytorch/tuner/test_scale_batch_size.py index 12b216b7cf8c3..d2fc8a61e0107 100644 --- a/tests/tuner/test_scale_batch_size.py +++ b/tests/tests_pytorch/tuner/test_scale_batch_size.py @@ -18,14 +18,14 @@ import torch from torch.utils.data import DataLoader -import tests.helpers.utils as tutils +import tests_pytorch.helpers.utils as tutils from pytorch_lightning import Trainer from pytorch_lightning.demos.boring_classes import BoringDataModule, BoringModel, RandomDataset from pytorch_lightning.tuner.tuning import Tuner from pytorch_lightning.utilities import AMPType from pytorch_lightning.utilities.exceptions import MisconfigurationException -from tests.helpers.runif import RunIf -from tests.helpers.utils import no_warning_call +from tests_pytorch.helpers.runif import RunIf +from tests_pytorch.helpers.utils import no_warning_call class BatchSizeDataModule(BoringDataModule): diff --git a/tests/tuner/test_tuning.py b/tests/tests_pytorch/tuner/test_tuning.py similarity index 100% rename from tests/tuner/test_tuning.py rename to tests/tests_pytorch/tuner/test_tuning.py diff --git a/tests/utilities/__init__.py b/tests/tests_pytorch/utilities/__init__.py similarity index 100% rename from tests/utilities/__init__.py rename to tests/tests_pytorch/utilities/__init__.py diff --git a/tests/utilities/distributed.py b/tests/tests_pytorch/utilities/distributed.py similarity index 100% rename from tests/utilities/distributed.py rename to tests/tests_pytorch/utilities/distributed.py diff --git a/tests/utilities/test_all_gather_grad.py b/tests/tests_pytorch/utilities/test_all_gather_grad.py similarity index 99% rename from tests/utilities/test_all_gather_grad.py rename to tests/tests_pytorch/utilities/test_all_gather_grad.py index 4535555c9f006..49d86aca9cc92 100644 --- a/tests/utilities/test_all_gather_grad.py +++ b/tests/tests_pytorch/utilities/test_all_gather_grad.py @@ -20,7 +20,7 @@ from pytorch_lightning import seed_everything, Trainer from pytorch_lightning.demos.boring_classes import BoringModel from pytorch_lightning.utilities import AllGatherGrad -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.runif import RunIf def setup_ddp(rank, world_size): diff --git a/tests/utilities/test_apply_func.py b/tests/tests_pytorch/utilities/test_apply_func.py similarity index 100% rename from tests/utilities/test_apply_func.py rename to tests/tests_pytorch/utilities/test_apply_func.py diff --git a/tests/utilities/test_apply_func_torchtext.py b/tests/tests_pytorch/utilities/test_apply_func_torchtext.py similarity index 93% rename from tests/utilities/test_apply_func_torchtext.py rename to tests/tests_pytorch/utilities/test_apply_func_torchtext.py index f76c1bf70cced..6c72959b54587 100644 --- a/tests/utilities/test_apply_func_torchtext.py +++ b/tests/tests_pytorch/utilities/test_apply_func_torchtext.py @@ -16,8 +16,8 @@ from pytorch_lightning.utilities.apply_func import move_data_to_device from pytorch_lightning.utilities.imports import _TORCHTEXT_LEGACY -from tests.helpers.runif import RunIf -from tests.helpers.torchtext_utils import get_dummy_torchtext_data_iterator +from tests_pytorch.helpers.runif import RunIf +from tests_pytorch.helpers.torchtext_utils import get_dummy_torchtext_data_iterator @pytest.mark.parametrize("include_lengths", [False, True]) diff --git a/tests/utilities/test_argparse.py b/tests/tests_pytorch/utilities/test_argparse.py similarity index 100% rename from tests/utilities/test_argparse.py rename to tests/tests_pytorch/utilities/test_argparse.py diff --git a/tests/utilities/test_auto_restart.py b/tests/tests_pytorch/utilities/test_auto_restart.py similarity index 99% rename from tests/utilities/test_auto_restart.py rename to tests/tests_pytorch/utilities/test_auto_restart.py index 2d5419a435f28..59d758f7dc6f4 100644 --- a/tests/utilities/test_auto_restart.py +++ b/tests/tests_pytorch/utilities/test_auto_restart.py @@ -36,7 +36,7 @@ from torch.utils.data.dataset import Dataset, IterableDataset from torch.utils.data.sampler import Sampler -import tests.helpers.utils as tutils +import tests_pytorch.helpers.utils as tutils from pytorch_lightning import Callback, LightningModule, seed_everything, Trainer from pytorch_lightning.demos.boring_classes import BoringModel, RandomDataset from pytorch_lightning.trainer.states import RunningStage, TrainerState @@ -60,7 +60,7 @@ from pytorch_lightning.utilities.exceptions import MisconfigurationException from pytorch_lightning.utilities.fetching import DataFetcher from pytorch_lightning.utilities.imports import _fault_tolerant_training -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.runif import RunIf def test_fast_forward_getattr(): diff --git a/tests/utilities/test_cli.py b/tests/tests_pytorch/utilities/test_cli.py similarity index 99% rename from tests/utilities/test_cli.py rename to tests/tests_pytorch/utilities/test_cli.py index b75f0e69525ec..4049e09af885b 100644 --- a/tests/utilities/test_cli.py +++ b/tests/tests_pytorch/utilities/test_cli.py @@ -54,8 +54,8 @@ ) from pytorch_lightning.utilities.exceptions import MisconfigurationException from pytorch_lightning.utilities.imports import _TORCHVISION_AVAILABLE -from tests.helpers.runif import RunIf -from tests.helpers.utils import no_warning_call +from tests_pytorch.helpers.runif import RunIf +from tests_pytorch.helpers.utils import no_warning_call torchvision_version = version.parse("0") if _TORCHVISION_AVAILABLE: @@ -595,7 +595,7 @@ def add_arguments_to_parser(self, parser): parser.link_arguments("data.batch_size", "model.init_args.batch_size") parser.link_arguments("data.num_classes", "model.init_args.num_classes", apply_on="instantiate") - cli_args[-1] = "--model=tests.utilities.test_cli.BoringModelRequiredClasses" + cli_args[-1] = "--model=tests_pytorch.utilities.test_cli.BoringModelRequiredClasses" with mock.patch("sys.argv", ["any.py"] + cli_args): cli = MyLightningCLI( diff --git a/tests/utilities/test_cloud_io.py b/tests/tests_pytorch/utilities/test_cloud_io.py similarity index 100% rename from tests/utilities/test_cloud_io.py rename to tests/tests_pytorch/utilities/test_cloud_io.py diff --git a/tests/utilities/test_data.py b/tests/tests_pytorch/utilities/test_data.py similarity index 98% rename from tests/utilities/test_data.py rename to tests/tests_pytorch/utilities/test_data.py index 2ef08525f24db..3bf709c8e2c69 100644 --- a/tests/utilities/test_data.py +++ b/tests/tests_pytorch/utilities/test_data.py @@ -20,8 +20,8 @@ warning_cache, ) from pytorch_lightning.utilities.exceptions import MisconfigurationException -from tests.helpers.datasets import RandomIterableDataset -from tests.helpers.utils import no_warning_call +from tests_pytorch.helpers.datasets import RandomIterableDataset +from tests_pytorch.helpers.utils import no_warning_call def test_extract_batch_size(): diff --git a/tests/utilities/test_deepspeed_collate_checkpoint.py b/tests/tests_pytorch/utilities/test_deepspeed_collate_checkpoint.py similarity index 98% rename from tests/utilities/test_deepspeed_collate_checkpoint.py rename to tests/tests_pytorch/utilities/test_deepspeed_collate_checkpoint.py index d8c06c5a97c4f..945b45c60a81b 100644 --- a/tests/utilities/test_deepspeed_collate_checkpoint.py +++ b/tests/tests_pytorch/utilities/test_deepspeed_collate_checkpoint.py @@ -19,7 +19,7 @@ from pytorch_lightning.demos.boring_classes import BoringModel from pytorch_lightning.strategies import DeepSpeedStrategy from pytorch_lightning.utilities.deepspeed import convert_zero_checkpoint_to_fp32_state_dict -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.runif import RunIf @RunIf(min_cuda_gpus=2, standalone=True, deepspeed=True) diff --git a/tests/utilities/test_distributed.py b/tests/tests_pytorch/utilities/test_distributed.py similarity index 94% rename from tests/utilities/test_distributed.py rename to tests/tests_pytorch/utilities/test_distributed.py index 269123b6ad4d4..f5ceb96ecbd9b 100644 --- a/tests/utilities/test_distributed.py +++ b/tests/tests_pytorch/utilities/test_distributed.py @@ -16,9 +16,9 @@ import torch import torch.multiprocessing as mp -import tests.helpers.utils as tutils +import tests_pytorch.helpers.utils as tutils from pytorch_lightning.utilities.distributed import _collect_states_on_rank_zero -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.runif import RunIf def _test_collect_states(rank, world_size): diff --git a/tests/utilities/test_dtype_device_mixin.py b/tests/tests_pytorch/utilities/test_dtype_device_mixin.py similarity index 98% rename from tests/utilities/test_dtype_device_mixin.py rename to tests/tests_pytorch/utilities/test_dtype_device_mixin.py index ed778b1e4ef2b..ec53816d2d5fc 100644 --- a/tests/utilities/test_dtype_device_mixin.py +++ b/tests/tests_pytorch/utilities/test_dtype_device_mixin.py @@ -18,7 +18,7 @@ from pytorch_lightning import Callback, Trainer from pytorch_lightning.core.mixins import DeviceDtypeModuleMixin from pytorch_lightning.demos.boring_classes import BoringModel -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.runif import RunIf class SubSubModule(DeviceDtypeModuleMixin): diff --git a/tests/utilities/test_enums.py b/tests/tests_pytorch/utilities/test_enums.py similarity index 100% rename from tests/utilities/test_enums.py rename to tests/tests_pytorch/utilities/test_enums.py diff --git a/tests/utilities/test_fetching.py b/tests/tests_pytorch/utilities/test_fetching.py similarity index 99% rename from tests/utilities/test_fetching.py rename to tests/tests_pytorch/utilities/test_fetching.py index 6ef29d65d604e..a362521bc9c52 100644 --- a/tests/utilities/test_fetching.py +++ b/tests/tests_pytorch/utilities/test_fetching.py @@ -27,7 +27,7 @@ from pytorch_lightning.utilities.exceptions import MisconfigurationException from pytorch_lightning.utilities.fetching import DataFetcher, DataLoaderIterDataFetcher, InterBatchParallelDataFetcher from pytorch_lightning.utilities.types import STEP_OUTPUT -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.runif import RunIf class IterDataset(IterableDataset): diff --git a/tests/utilities/test_finite_checks.py b/tests/tests_pytorch/utilities/test_finite_checks.py similarity index 100% rename from tests/utilities/test_finite_checks.py rename to tests/tests_pytorch/utilities/test_finite_checks.py diff --git a/tests/utilities/test_grads.py b/tests/tests_pytorch/utilities/test_grads.py similarity index 100% rename from tests/utilities/test_grads.py rename to tests/tests_pytorch/utilities/test_grads.py diff --git a/tests/utilities/test_imports.py b/tests/tests_pytorch/utilities/test_imports.py similarity index 100% rename from tests/utilities/test_imports.py rename to tests/tests_pytorch/utilities/test_imports.py diff --git a/tests/utilities/test_logger.py b/tests/tests_pytorch/utilities/test_logger.py similarity index 100% rename from tests/utilities/test_logger.py rename to tests/tests_pytorch/utilities/test_logger.py diff --git a/tests/utilities/test_memory.py b/tests/tests_pytorch/utilities/test_memory.py similarity index 100% rename from tests/utilities/test_memory.py rename to tests/tests_pytorch/utilities/test_memory.py diff --git a/tests/utilities/test_meta.py b/tests/tests_pytorch/utilities/test_meta.py similarity index 98% rename from tests/utilities/test_meta.py rename to tests/tests_pytorch/utilities/test_meta.py index cf19fa18db24d..b19483e29bbe2 100644 --- a/tests/utilities/test_meta.py +++ b/tests/tests_pytorch/utilities/test_meta.py @@ -17,7 +17,7 @@ from pytorch_lightning.core.module import LightningModule from pytorch_lightning.demos.boring_classes import BoringModel from pytorch_lightning.utilities.meta import init_meta_context, is_on_meta_device, materialize_module -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.runif import RunIf class MLP(nn.Module): diff --git a/tests/utilities/test_migration.py b/tests/tests_pytorch/utilities/test_migration.py similarity index 100% rename from tests/utilities/test_migration.py rename to tests/tests_pytorch/utilities/test_migration.py diff --git a/tests/utilities/test_model_helpers.py b/tests/tests_pytorch/utilities/test_model_helpers.py similarity index 100% rename from tests/utilities/test_model_helpers.py rename to tests/tests_pytorch/utilities/test_model_helpers.py diff --git a/tests/utilities/test_model_summary.py b/tests/tests_pytorch/utilities/test_model_summary.py similarity index 99% rename from tests/utilities/test_model_summary.py rename to tests/tests_pytorch/utilities/test_model_summary.py index d7a76c0fb5e2c..e2f903725369b 100644 --- a/tests/utilities/test_model_summary.py +++ b/tests/tests_pytorch/utilities/test_model_summary.py @@ -20,8 +20,8 @@ from pytorch_lightning import LightningModule, Trainer from pytorch_lightning.demos.boring_classes import BoringModel from pytorch_lightning.utilities.model_summary import ModelSummary, summarize, UNKNOWN_SIZE -from tests.helpers.advanced_models import ParityModuleRNN -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.advanced_models import ParityModuleRNN +from tests_pytorch.helpers.runif import RunIf class EmptyModule(LightningModule): diff --git a/tests/utilities/test_optimizer.py b/tests/tests_pytorch/utilities/test_optimizer.py similarity index 100% rename from tests/utilities/test_optimizer.py rename to tests/tests_pytorch/utilities/test_optimizer.py diff --git a/tests/utilities/test_parameter_tying.py b/tests/tests_pytorch/utilities/test_parameter_tying.py similarity index 100% rename from tests/utilities/test_parameter_tying.py rename to tests/tests_pytorch/utilities/test_parameter_tying.py diff --git a/tests/utilities/test_parsing.py b/tests/tests_pytorch/utilities/test_parsing.py similarity index 100% rename from tests/utilities/test_parsing.py rename to tests/tests_pytorch/utilities/test_parsing.py diff --git a/tests/utilities/test_rank_zero.py b/tests/tests_pytorch/utilities/test_rank_zero.py similarity index 100% rename from tests/utilities/test_rank_zero.py rename to tests/tests_pytorch/utilities/test_rank_zero.py diff --git a/tests/utilities/test_remote_filesystem.py b/tests/tests_pytorch/utilities/test_remote_filesystem.py similarity index 100% rename from tests/utilities/test_remote_filesystem.py rename to tests/tests_pytorch/utilities/test_remote_filesystem.py diff --git a/tests/utilities/test_seed.py b/tests/tests_pytorch/utilities/test_seed.py similarity index 100% rename from tests/utilities/test_seed.py rename to tests/tests_pytorch/utilities/test_seed.py diff --git a/tests/utilities/test_types.py b/tests/tests_pytorch/utilities/test_types.py similarity index 100% rename from tests/utilities/test_types.py rename to tests/tests_pytorch/utilities/test_types.py diff --git a/tests/utilities/test_upgrade_checkpoint.py b/tests/tests_pytorch/utilities/test_upgrade_checkpoint.py similarity index 100% rename from tests/utilities/test_upgrade_checkpoint.py rename to tests/tests_pytorch/utilities/test_upgrade_checkpoint.py diff --git a/tests/utilities/test_warnings.py b/tests/tests_pytorch/utilities/test_warnings.py similarity index 100% rename from tests/utilities/test_warnings.py rename to tests/tests_pytorch/utilities/test_warnings.py diff --git a/tests/utilities/test_xla_device_utils.py b/tests/tests_pytorch/utilities/test_xla_device_utils.py similarity index 97% rename from tests/utilities/test_xla_device_utils.py rename to tests/tests_pytorch/utilities/test_xla_device_utils.py index 8c1c92e7021c8..3485a217dfb05 100644 --- a/tests/utilities/test_xla_device_utils.py +++ b/tests/tests_pytorch/utilities/test_xla_device_utils.py @@ -18,7 +18,7 @@ import pytorch_lightning.utilities.xla_device as xla_utils from pytorch_lightning.utilities import _XLA_AVAILABLE -from tests.helpers.runif import RunIf +from tests_pytorch.helpers.runif import RunIf @pytest.mark.skipif(_XLA_AVAILABLE, reason="test requires torch_xla to be absent")