diff --git a/.azure-pipelines/gpu-benchmark.yml b/.azure-pipelines/gpu-benchmark.yml index 451f5b5646dca9..a303663d9758b6 100644 --- a/.azure-pipelines/gpu-benchmark.yml +++ b/.azure-pipelines/gpu-benchmark.yml @@ -34,8 +34,14 @@ jobs: clean: all steps: - - bash: | - python -m pytest tests/benchmarks -v --durations=0 - displayName: 'Testing: benchmarks' - env: - PL_RUNNING_BENCHMARKS: 1 + + - bash: | + pip install -e . -r requirements/strategies.txt + pip list + displayName: 'Install package' + + - bash: | + python -m pytest tests/benchmarks -v --durations=0 + displayName: 'Testing: benchmarks' + env: + PL_RUNNING_BENCHMARKS: 1 diff --git a/.azure-pipelines/gpu-tests.yml b/.azure-pipelines/gpu-tests.yml index 5ec9db1297b43a..108651efdc58f7 100644 --- a/.azure-pipelines/gpu-tests.yml +++ b/.azure-pipelines/gpu-tests.yml @@ -28,15 +28,12 @@ jobs: timeoutInMinutes: "100" # how much time to give 'run always even if cancelled tasks' before stopping them cancelTimeoutInMinutes: "2" - pool: azure-jirka-spot - container: image: $(image) # default shm size is 64m. Increase it to avoid: # 'Error while creating shared memory: unhandled system error, NCCL version 2.7.8' options: "--runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=all --shm-size=512m" - workspace: clean: all @@ -56,8 +53,9 @@ jobs: python -c "fname = 'requirements/strategies.txt' ; lines = [line for line in open(fname).readlines() if 'horovod' not in line] ; open(fname, 'w').writelines(lines)" CUDA_VERSION_MM=$(python -c "import torch ; print(''.join(map(str, torch.version.cuda.split('.')[:2])))") pip install "bagua-cuda$CUDA_VERSION_MM>=0.9.0" - pip install . --requirement requirements/devel.txt - pip install . --requirement requirements/strategies.txt + pip install -e . + pip install --requirement requirements/devel.txt + pip install --requirement requirements/strategies.txt pip list displayName: 'Install dependencies' @@ -72,12 +70,15 @@ jobs: - bash: bash .actions/pull_legacy_checkpoints.sh displayName: 'Get legacy checkpoints' - - bash: | - python -m coverage run --source pytorch_lightning -m pytest pytorch_lightning tests --ignore tests/benchmarks -v --junitxml=$(Build.StagingDirectory)/test-results.xml --durations=50 - displayName: 'Testing: standard' + - bash: python -m coverage run --source pytorch_lightning -m pytest pytorch_lightning + workingDirectory: src + displayName: 'Testing: doctests' - - bash: | - bash tests/standalone_tests.sh + - 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: bash run_standalone_tests.sh + workingDirectory: test env: PL_USE_MOCKED_MNIST: "1" displayName: 'Testing: standalone' diff --git a/.azure-pipelines/hpu-tests.yml b/.azure-pipelines/hpu-tests.yml index c4abbe3c949fd2..cc37259554ee74 100644 --- a/.azure-pipelines/hpu-tests.yml +++ b/.azure-pipelines/hpu-tests.yml @@ -20,9 +20,7 @@ jobs: timeoutInMinutes: "10" # how much time to give 'run always even if cancelled tasks' before stopping them cancelTimeoutInMinutes: "2" - pool: intel-hpus - workspace: clean: all @@ -33,7 +31,7 @@ jobs: displayName: 'Instance HW info' - bash: | - pip install . --requirement requirements/extra.txt + pip install -e .[extra] pip install . --requirement requirements/test.txt displayName: 'Install dependencies' diff --git a/.azure-pipelines/ipu-tests.yml b/.azure-pipelines/ipu-tests.yml index 80d49f9da3e780..7e3a9dcdc4caa4 100644 --- a/.azure-pipelines/ipu-tests.yml +++ b/.azure-pipelines/ipu-tests.yml @@ -21,7 +21,6 @@ jobs: # how long to run the job before automatically cancelling timeoutInMinutes: "15" pool: graphcore-ipus - workspace: clean: all @@ -55,7 +54,7 @@ jobs: export GIT_TERMINAL_PROMPT=1 python ./requirements/adjust-versions.py requirements/extra.txt python ./requirements/adjust-versions.py requirements/examples.txt - pip install . --requirement ./requirements/devel.txt + pip install -e . --requirement ./requirements/devel.txt pip list displayName: 'Install dependencies' @@ -68,16 +67,22 @@ jobs: set -eux source ${{ variables.poplar_sdk }}/poplar-ubuntu*/enable.sh source ${{ variables.poplar_sdk }}/popart-ubuntu*/enable.sh - python -c "import poptorch; print(poptorch.__version__)" displayName: "Check poptorch installation" - bash: | source ${{ variables.poplar_sdk }}/poplar-ubuntu*/enable.sh source ${{ variables.poplar_sdk }}/popart-ubuntu*/enable.sh - export POPTORCH_WAIT_FOR_IPU=1 - export PL_RUN_IPU_TESTS=1 - python -m coverage run --source pytorch_lightning -m pytest tests -vv --junitxml=$(Build.StagingDirectory)/test-results.xml --durations=50 + cd src + python -m pytest pytorch_lightning + displayName: '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 env: MKL_THREADING_LAYER: "GNU" - displayName: 'Testing: standard' + POPTORCH_WAIT_FOR_IPU: 1 + PL_RUN_IPU_TESTS: 1 + displayName: 'UnitTests' diff --git a/.circleci/config.yml b/.circleci/config.yml index 73e658d304c8c4..efbe7f1349543f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -40,7 +40,7 @@ references: # the image uses python 2.7 by default, force a different version pyenv global 3.7.3 python --version - pip install -r requirements/docs.txt + pip install -e . -r requirements/docs.txt pip list cd docs make clean diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index e3d913971c1682..da31fde0f59c0f 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -22,35 +22,35 @@ /docs/source/expertise_levels @williamfalcon @RobertLaurella # Packages -/pytorch_lightning/accelerators @williamfalcon @tchaton @SeanNaren @awaelchli @justusschock @kaushikb11 -/pytorch_lightning/callbacks @williamfalcon @tchaton @carmocca @borda @kaushikb11 -/pytorch_lightning/core @tchaton @SeanNaren @borda @carmocca @justusschock @kaushikb11 -/pytorch_lightning/distributed @williamfalcon @tchaton @awaelchli @kaushikb11 -/pytorch_lightning/lite @tchaton @awaelchli @carmocca -/pytorch_lightning/loggers @tchaton @awaelchli @borda -/pytorch_lightning/loggers/wandb.py @borisdayma -/pytorch_lightning/loggers/neptune.py @shnela @HubertJaworski @pkasprzyk @pitercl @Raalsky @aniezurawski @kamil-kaczmarek -/pytorch_lightning/loops @tchaton @awaelchli @justusschock @carmocca -/pytorch_lightning/overrides @tchaton @SeanNaren @borda -/pytorch_lightning/plugins @tchaton @SeanNaren @awaelchli @justusschock -/pytorch_lightning/profiler @williamfalcon @tchaton @borda @carmocca -/pytorch_lightning/profiler/pytorch.py @nbcsm @guotuofeng -/pytorch_lightning/strategies @tchaton @SeanNaren @awaelchli @justusschock @kaushikb11 -/pytorch_lightning/trainer @williamfalcon @borda @tchaton @SeanNaren @carmocca @awaelchli @justusschock @kaushikb11 -/pytorch_lightning/trainer/connectors @tchaton @SeanNaren @carmocca @borda -/pytorch_lightning/tuner @SkafteNicki @borda @awaelchli -/pytorch_lightning/utilities @borda @tchaton @SeanNaren @carmocca +/src/pytorch_lightning/accelerators @williamfalcon @tchaton @SeanNaren @awaelchli @justusschock @kaushikb11 +/src/pytorch_lightning/callbacks @williamfalcon @tchaton @carmocca @borda @kaushikb11 +/src/pytorch_lightning/core @tchaton @SeanNaren @borda @carmocca @justusschock @kaushikb11 +/src/pytorch_lightning/distributed @williamfalcon @tchaton @awaelchli @kaushikb11 +/src/pytorch_lightning/lite @tchaton @awaelchli @carmocca +/src/pytorch_lightning/loggers @tchaton @awaelchli @borda +/src/pytorch_lightning/loggers/wandb.py @borisdayma +/src/pytorch_lightning/loggers/neptune.py @shnela @HubertJaworski @pkasprzyk @pitercl @Raalsky @aniezurawski @kamil-kaczmarek +/src/pytorch_lightning/loops @tchaton @awaelchli @justusschock @carmocca +/src/pytorch_lightning/overrides @tchaton @SeanNaren @borda +/src/pytorch_lightning/plugins @tchaton @SeanNaren @awaelchli @justusschock +/src/pytorch_lightning/profiler @williamfalcon @tchaton @borda @carmocca +/src/pytorch_lightning/profiler/pytorch.py @nbcsm @guotuofeng +/src/pytorch_lightning/strategies @tchaton @SeanNaren @awaelchli @justusschock @kaushikb11 +/src/pytorch_lightning/trainer @williamfalcon @borda @tchaton @SeanNaren @carmocca @awaelchli @justusschock @kaushikb11 +/src/pytorch_lightning/trainer/connectors @tchaton @SeanNaren @carmocca @borda +/src/pytorch_lightning/tuner @SkafteNicki @borda @awaelchli +/src/pytorch_lightning/utilities @borda @tchaton @SeanNaren @carmocca # Specifics -/pytorch_lightning/trainer/connectors/logger_connector @tchaton @carmocca -/pytorch_lightning/trainer/progress.py @tchaton @awaelchli @carmocca +/src/pytorch_lightning/trainer/connectors/logger_connector @tchaton @carmocca +/src/pytorch_lightning/trainer/progress.py @tchaton @awaelchli @carmocca # API -/pytorch_lightning/callbacks/base.py @williamfalcon @awaelchli @ananthsub @carmocca -/pytorch_lightning/core/datamodule.py @williamFalcon @awaelchli @ananthsub @carmocca -/pytorch_lightning/trainer/trainer.py @williamfalcon @tchaton @awaelchli -/pytorch_lightning/core/hooks.py @williamfalcon @tchaton @awaelchli @ananthsub @carmocca -/pytorch_lightning/core/lightning.py @williamfalcon @tchaton @awaelchli +/src/pytorch_lightning/callbacks/base.py @williamfalcon @awaelchli @ananthsub @carmocca +/src/pytorch_lightning/core/datamodule.py @williamFalcon @awaelchli @ananthsub @carmocca +/src/pytorch_lightning/trainer/trainer.py @williamfalcon @tchaton @awaelchli +/src/pytorch_lightning/core/hooks.py @williamfalcon @tchaton @awaelchli @ananthsub @carmocca +/src/pytorch_lightning/core/lightning.py @williamfalcon @tchaton @awaelchli # Testing /tests/helpers/boring_model.py @williamfalcon @tchaton @borda @@ -60,4 +60,4 @@ /SECURITY.md @williamfalcon /README.md @williamfalcon @edenlightning @borda /setup.py @williamfalcon @borda @carmocca -/pytorch_lightning/__about__.py @williamfalcon @borda @carmocca +/src/pytorch_lightning/__about__.py @williamfalcon @borda @carmocca diff --git a/.github/workflows/ci_pkg-install.yml b/.github/workflows/ci_pkg-install.yml index 3f427ad2e0d760..530e3e9048fa57 100644 --- a/.github/workflows/ci_pkg-install.yml +++ b/.github/workflows/ci_pkg-install.yml @@ -54,8 +54,8 @@ jobs: # install as archive pip install *.tar.gz cd .. - python -c "import pytorch_lightning as pl ; print(pl.__version__)" - pip uninstall -y pytorch-lightning + python -c "import pytorch_lightning ; print(pytorch_lightning.__version__)" + pip uninstall -y pytorch_lightning - name: Install | Uninstall package - wheel working-directory: ./dist @@ -63,5 +63,5 @@ jobs: # install as wheel pip install *.whl cd .. - python -c "import pytorch_lightning as pl ; print(pl.__version__)" - pip uninstall -y pytorch-lightning + python -c "import pytorch_lightning ; print(pytorch_lightning.__version__)" + pip uninstall -y pytorch_lightning diff --git a/.github/workflows/ci_test-conda.yml b/.github/workflows/ci_test-conda.yml index 0466a837603382..6b2e1ff394d11d 100644 --- a/.github/workflows/ci_test-conda.yml +++ b/.github/workflows/ci_test-conda.yml @@ -39,11 +39,12 @@ jobs: run: | conda info conda list + pip install -e . pip install -r requirements/test.txt - name: DocTests - run: | - coverage run --source pytorch_lightning -m pytest pytorch_lightning + working-directory: ./src + run: pytest pytorch_lightning --cov=pytorch_lightning - name: Update all dependencies env: diff --git a/.github/workflows/ci_test-full.yml b/.github/workflows/ci_test-full.yml index bca5699d430291..798bc32e646595 100644 --- a/.github/workflows/ci_test-full.yml +++ b/.github/workflows/ci_test-full.yml @@ -83,13 +83,14 @@ jobs: run: | flag=$(python -c "print('--pre' if '${{matrix.release}}' == 'pre' else '')" 2>&1) url=$(python -c "print('test/cpu/torch_test.html' if '${{matrix.release}}' == 'pre' else 'cpu/torch_stable.html')" 2>&1) - pip install -r requirements.txt --upgrade $flag --find-links "https://download.pytorch.org/whl/${url}" + pip install -e . --upgrade $flag --find-links "https://download.pytorch.org/whl/${url}" pip install -r requirements/test.txt --upgrade pip list shell: bash - name: DocTests - run: coverage run --source pytorch_lightning -m pytest pytorch_lightning + working-directory: ./src + run: pytest pytorch_lightning --cov=pytorch_lightning - name: Install extra dependencies run: | @@ -123,8 +124,7 @@ jobs: key: pl-dataset - name: Sanity check - run: | - python requirements/check-avail-extras.py + run: python requirements/check-avail-extras.py - name: UnitTests run: | diff --git a/.github/workflows/ci_test-slow.yml b/.github/workflows/ci_test-slow.yml index e2b5ca20b2f954..0598fc8216966e 100644 --- a/.github/workflows/ci_test-slow.yml +++ b/.github/workflows/ci_test-slow.yml @@ -49,7 +49,7 @@ jobs: run: | # adjust versions according installed Torch version python ./requirements/adjust-versions.py requirements.txt ${{ matrix.pytorch-version }} - pip install -r requirements.txt --find-links https://download.pytorch.org/whl/cpu/torch_stable.html --upgrade + pip install -e . --find-links https://download.pytorch.org/whl/cpu/torch_stable.html --upgrade pip install -r requirements/test.txt pip list shell: bash diff --git a/.github/workflows/code-checks.yml b/.github/workflows/code-checks.yml index 8f4aa133372fb1..86c76b5a5b8da9 100644 --- a/.github/workflows/code-checks.yml +++ b/.github/workflows/code-checks.yml @@ -37,4 +37,5 @@ jobs: pip list - name: Type check - run: mypy --install-types --non-interactive + working-directory: ./src + run: mypy -p pytorch_lightning --install-types --non-interactive --verbose --config-file ../pyproject.toml --warn-unused-configs diff --git a/.github/workflows/docs-checks.yml b/.github/workflows/docs-checks.yml index d41ad440472944..6b23d852448287 100644 --- a/.github/workflows/docs-checks.yml +++ b/.github/workflows/docs-checks.yml @@ -31,9 +31,9 @@ jobs: uses: actions/cache@v2 with: path: ~/.cache/pip - key: ${{ runner.os }}-pip-td${{ env.TIME_PERIOD }}-${{ hashFiles('requirements/base.txt') }} + key: ${{ runner.os }}-docs-test-pip-td${{ env.TIME_PERIOD }}-${{ hashFiles('requirements/*.txt') }} restore-keys: | - ${{ runner.os }}-pip-td${{ env.TIME_PERIOD }}- + ${{ runner.os }}-docs-test-pip-td${{ env.TIME_PERIOD }}- - name: Install dependencies run: | @@ -42,9 +42,8 @@ jobs: pip --version pip install -q fire # python -m pip install --upgrade --user pip - pip install -r requirements.txt --upgrade-strategy only-if-needed --find-links https://download.pytorch.org/whl/cpu/torch_stable.html --quiet + pip install -e . --quiet -r requirements/docs.txt --find-links https://download.pytorch.org/whl/cpu/torch_stable.html pip install -r requirements/devel.txt - pip install -r requirements/docs.txt pip list shell: bash @@ -74,16 +73,16 @@ jobs: uses: actions/cache@v2 with: path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('requirements/base.txt') }} + key: ${{ runner.os }}-docs-make-pip-${{ hashFiles('requirements/base.txt') }} restore-keys: | - ${{ runner.os }}-pip- + ${{ runner.os }}-docs-make-pip- - name: Install dependencies run: | sudo apt-get update sudo apt-get install -y cmake pandoc pip --version - pip install --requirement requirements/docs.txt + pip install -e . --quiet -r requirements/docs.txt --find-links https://download.pytorch.org/whl/cpu/torch_stable.html # install Texlive, see https://linuxconfig.org/how-to-install-latex-on-ubuntu-20-04-focal-fossa-linux sudo apt-get update && sudo apt-get install -y texlive-latex-extra dvipng texlive-pictures pip list diff --git a/dockers/tpu-tests/Dockerfile b/dockers/tpu-tests/Dockerfile index d4c58c665e7a5b..5005fd0f9ad7e6 100644 --- a/dockers/tpu-tests/Dockerfile +++ b/dockers/tpu-tests/Dockerfile @@ -22,7 +22,8 @@ LABEL maintainer="PyTorchLightning <https://github.com/PyTorchLightning>" COPY ./ ./pytorch-lightning/ # Pull the legacy checkpoints -RUN cd pytorch-lightning && bash .actions/pull_legacy_checkpoints.sh +RUN cd pytorch-lightning && \ + bash .actions/pull_legacy_checkpoints.sh RUN \ pip install -q fire && \