From a989e31bd21875664484ee1671b71c58273e0aaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mochol=C3=AD?= Date: Thu, 3 Nov 2022 02:42:41 +0100 Subject: [PATCH 01/30] Do not modify PACKAGE_NAME on install --- .azure/gpu-benchmark.yml | 2 +- .azure/gpu-tests-pytorch.yml | 2 +- .azure/hpu-tests.yml | 2 +- .azure/ipu-tests.yml | 2 +- .github/workflows/ci-pytorch-tests-slow.yml | 2 +- .github/workflows/ci-pytorch-tests.yml | 2 +- .github/workflows/docs-checks.yml | 2 +- setup.py | 10 ---------- 8 files changed, 7 insertions(+), 17 deletions(-) diff --git a/.azure/gpu-benchmark.yml b/.azure/gpu-benchmark.yml index d8faf43e5d17a..dc99cfef95cb7 100644 --- a/.azure/gpu-benchmark.yml +++ b/.azure/gpu-benchmark.yml @@ -53,7 +53,7 @@ jobs: - bash: | pip install -e . --find-links ${TORCH_URL} - git checkout -- setup.py MANIFEST.in + git checkout -- MANIFEST.in env: PACKAGE_NAME: lite FREEZE_REQUIREMENTS: 1 diff --git a/.azure/gpu-tests-pytorch.yml b/.azure/gpu-tests-pytorch.yml index c3cf3849a5c5b..fbc44ac193519 100644 --- a/.azure/gpu-tests-pytorch.yml +++ b/.azure/gpu-tests-pytorch.yml @@ -95,7 +95,7 @@ jobs: - bash: | pip install -e . --find-links ${TORCH_URL} - git checkout -- setup.py MANIFEST.in + git checkout -- MANIFEST.in env: PACKAGE_NAME: "lite" FREEZE_REQUIREMENTS: "1" diff --git a/.azure/hpu-tests.yml b/.azure/hpu-tests.yml index c29547911a462..77c90a744979b 100644 --- a/.azure/hpu-tests.yml +++ b/.azure/hpu-tests.yml @@ -60,7 +60,7 @@ jobs: - bash: | pip install -e . - git checkout -- setup.py MANIFEST.in + git checkout -- MANIFEST.in env: PACKAGE_NAME: "lite" FREEZE_REQUIREMENTS: "1" diff --git a/.azure/ipu-tests.yml b/.azure/ipu-tests.yml index 690b1acc32b6d..6584c9563d46d 100644 --- a/.azure/ipu-tests.yml +++ b/.azure/ipu-tests.yml @@ -64,7 +64,7 @@ jobs: - bash: | pip install -e . - git checkout -- setup.py MANIFEST.in + git checkout -- MANIFEST.in env: PACKAGE_NAME: "lite" FREEZE_REQUIREMENTS: "1" diff --git a/.github/workflows/ci-pytorch-tests-slow.yml b/.github/workflows/ci-pytorch-tests-slow.yml index 35de255a6b2b5..cd2ec3a484035 100644 --- a/.github/workflows/ci-pytorch-tests-slow.yml +++ b/.github/workflows/ci-pytorch-tests-slow.yml @@ -62,7 +62,7 @@ jobs: PACKAGE_NAME: "lite" run: | pip install -e . --upgrade --find-links https://download.pytorch.org/whl/cpu/torch_stable.html - git checkout -- setup.py MANIFEST.in + git checkout -- MANIFEST.in - name: Install package & dependencies env: diff --git a/.github/workflows/ci-pytorch-tests.yml b/.github/workflows/ci-pytorch-tests.yml index fcd19181f6188..bc71bf80c2dd3 100644 --- a/.github/workflows/ci-pytorch-tests.yml +++ b/.github/workflows/ci-pytorch-tests.yml @@ -131,7 +131,7 @@ jobs: PACKAGE_NAME: "lite" run: | pip install -e . --upgrade --find-links ${TORCH_URL} - git checkout -- setup.py MANIFEST.in + git checkout -- MANIFEST.in - name: Install package & dependencies env: diff --git a/.github/workflows/docs-checks.yml b/.github/workflows/docs-checks.yml index 8ff7330a6780e..42f305d3feaf2 100644 --- a/.github/workflows/docs-checks.yml +++ b/.github/workflows/docs-checks.yml @@ -85,7 +85,7 @@ jobs: if: ${{ matrix.pkg-name== 'app' }} run: | pip install -e . -U --find-links https://download.pytorch.org/whl/cpu/torch_stable.html --find-links pypi - git checkout -- setup.py MANIFEST.in + git checkout -- MANIFEST.in - name: Adjust docs refs if: ${{ matrix.pkg-name == 'app' }} diff --git a/setup.py b/setup.py index b400133b14da1..7b8eba9910f14 100755 --- a/setup.py +++ b/setup.py @@ -68,16 +68,6 @@ _FREEZE_REQUIREMENTS = bool(int(os.environ.get("FREEZE_REQUIREMENTS", 0))) -# Hardcode the env variable from time of package creation, otherwise it fails during installation -with open(__file__) as fp: - lines = fp.readlines() -for i, ln in enumerate(lines): - if ln.startswith("_PACKAGE_NAME = "): - lines[i] = f'_PACKAGE_NAME = "{_PACKAGE_NAME}"{os.linesep}' -with open(__file__, "w") as fp: - fp.writelines(lines) - - def _load_py_module(name: str, location: str) -> ModuleType: spec = spec_from_file_location(name, location) assert spec, f"Failed to load module {name} from {location}" From 3531b0d8b530091b849102cf31419addcd13500d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mochol=C3=AD?= Date: Thu, 3 Nov 2022 03:00:17 +0100 Subject: [PATCH 02/30] Fix ci pkg action --- .github/actions/pkg-install/action.yml | 25 ++++++++----------------- .github/workflows/ci-pkg-install.yml | 1 + 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/.github/actions/pkg-install/action.yml b/.github/actions/pkg-install/action.yml index 155c4edf99997..8a17212e13c28 100644 --- a/.github/actions/pkg-install/action.yml +++ b/.github/actions/pkg-install/action.yml @@ -1,5 +1,5 @@ -name: Install and check package -description: installing and validationg the package +name: Install and validate the package +description: Install and validate the package inputs: pkg-name: @@ -11,32 +11,23 @@ inputs: required: false default: "" +defaults: + run: + shell: bash + runs: using: "composite" steps: - - name: Determine package name - if: ${{ inputs.pkg-import == '' }} - working-directory: ./dist - run: python -c "import glob ; ls = glob.glob('*.tar.gz') ; name = '_'.join(ls[0].split('-')[:-1]) ; print(f'PKG_NAME={name}')" >> $GITHUB_ENV - shell: bash - - - name: Pass package name - if: ${{ inputs.pkg-import != '' }} - run: echo "PKG_NAME=${{ inputs.pkg-name }}" >> $GITHUB_ENV - shell: bash - - name: Install package - archive working-directory: ./dist run: | pip install *.tar.gz ${{ inputs.pip-flags }} pip list | grep lightning - python -c "import ${PKG_NAME} ; print(${PKG_NAME}.__version__)" - shell: bash + python -c "import ${{ inputs.pkg-name }}; print(${{ inputs.pkg-name }}.__version__)" - name: Install package - wheel working-directory: ./dist run: | pip install *.whl ${{ inputs.pip-flags }} pip list | grep lightning - python -c "import ${PKG_NAME} ; print(${PKG_NAME}.__version__)" - shell: bash + python -c "import ${{ inputs.pkg-name }}; print(${{ inputs.pkg-name }}.__version__)" diff --git a/.github/workflows/ci-pkg-install.yml b/.github/workflows/ci-pkg-install.yml index 4128f721b8576..778621f6345df 100644 --- a/.github/workflows/ci-pkg-install.yml +++ b/.github/workflows/ci-pkg-install.yml @@ -95,6 +95,7 @@ jobs: - run: ls -l pypi/ - uses: ./.github/actions/pkg-install with: + pkg-name: ${{ matrix.pkg-name }} pip-flags: "--pre --find-links ../pypi/" - name: Run CLI From 0c036bc6bbb12e31feeae04cd8690ecd65e13b06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mochol=C3=AD?= Date: Thu, 3 Nov 2022 03:03:33 +0100 Subject: [PATCH 03/30] Required --- .github/actions/pkg-install/action.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/actions/pkg-install/action.yml b/.github/actions/pkg-install/action.yml index 8a17212e13c28..27c54acee3b34 100644 --- a/.github/actions/pkg-install/action.yml +++ b/.github/actions/pkg-install/action.yml @@ -4,8 +4,7 @@ description: Install and validate the package inputs: pkg-name: description: package name for import - required: false - default: "" + required: true pip-flags: description: additional pil install flags required: false From c5f888506f62665b85ca93485bf18578876dffe0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mochol=C3=AD?= Date: Thu, 3 Nov 2022 03:04:41 +0100 Subject: [PATCH 04/30] Typos --- .github/actions/pkg-install/action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/actions/pkg-install/action.yml b/.github/actions/pkg-install/action.yml index 27c54acee3b34..a8dd9bc3424e8 100644 --- a/.github/actions/pkg-install/action.yml +++ b/.github/actions/pkg-install/action.yml @@ -3,10 +3,10 @@ description: Install and validate the package inputs: pkg-name: - description: package name for import + description: Package name to import required: true pip-flags: - description: additional pil install flags + description: Additional pip install flags required: false default: "" From f8f1df2808780608bdc3e38d0b0fcf6a2f465b3a Mon Sep 17 00:00:00 2001 From: Jirka Borovec Date: Thu, 3 Nov 2022 03:10:36 +0100 Subject: [PATCH 05/30] Apply suggestions from code review --- .github/actions/pkg-install/action.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/actions/pkg-install/action.yml b/.github/actions/pkg-install/action.yml index a8dd9bc3424e8..5c3b1130bc25b 100644 --- a/.github/actions/pkg-install/action.yml +++ b/.github/actions/pkg-install/action.yml @@ -23,6 +23,7 @@ runs: pip install *.tar.gz ${{ inputs.pip-flags }} pip list | grep lightning python -c "import ${{ inputs.pkg-name }}; print(${{ inputs.pkg-name }}.__version__)" + shell: bash - name: Install package - wheel working-directory: ./dist @@ -30,3 +31,4 @@ runs: pip install *.whl ${{ inputs.pip-flags }} pip list | grep lightning python -c "import ${{ inputs.pkg-name }}; print(${{ inputs.pkg-name }}.__version__)" + shell: bash From 99492cbbc26aac7a7875122a3d694319ee1096a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mochol=C3=AD?= Date: Thu, 3 Nov 2022 03:11:29 +0100 Subject: [PATCH 06/30] Undo defaults --- .github/actions/pkg-install/action.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/actions/pkg-install/action.yml b/.github/actions/pkg-install/action.yml index 5c3b1130bc25b..c10d6d98a1949 100644 --- a/.github/actions/pkg-install/action.yml +++ b/.github/actions/pkg-install/action.yml @@ -10,10 +10,6 @@ inputs: required: false default: "" -defaults: - run: - shell: bash - runs: using: "composite" steps: From 1430b4b16750a8c9d902102168f1ae7b46fc7254 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mochol=C3=AD?= Date: Thu, 3 Nov 2022 03:25:46 +0100 Subject: [PATCH 07/30] Cleanup --- .github/workflows/ci-pkg-install.yml | 4 ++++ setup.py | 34 +++++++++++----------------- 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/.github/workflows/ci-pkg-install.yml b/.github/workflows/ci-pkg-install.yml index 778621f6345df..afafc662a4a8e 100644 --- a/.github/workflows/ci-pkg-install.yml +++ b/.github/workflows/ci-pkg-install.yml @@ -72,6 +72,7 @@ jobs: python-version: ["3.7" , "3.10"] steps: - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} @@ -83,6 +84,7 @@ jobs: python -m pytest setup_tools.py - run: python -c "print('NB_DIRS=' + str(2 if '${{ matrix.pkg-name }}' == 'pytorch' else 1))" >> $GITHUB_ENV + - uses: ./.github/actions/pkg-check with: pkg-name: ${{ matrix.pkg-name }} @@ -92,7 +94,9 @@ jobs: with: name: ci-packages-${{ github.sha }} path: pypi + - run: ls -l pypi/ + - uses: ./.github/actions/pkg-install with: pkg-name: ${{ matrix.pkg-name }} diff --git a/setup.py b/setup.py index 7b8eba9910f14..eaea7e0c3a9da 100755 --- a/setup.py +++ b/setup.py @@ -38,15 +38,6 @@ compared against PyPI registry b) with a parameterization build desired packages in to standard `dist/` folder c) validate packages and publish to PyPI - - -| Installation | PIP version * | Pkg version ** | -| -------------- | ------------------- | --------------- | -| source | calendar + branch | semantic | -| PyPI | semantic | semantic | - -* shown version while calling `pip list | grep lightning` -** shown version in python `from import __version__` """ import os from importlib.util import module_from_spec, spec_from_file_location @@ -54,8 +45,13 @@ from setuptools import setup -_PACKAGE_NAME = os.environ.get("PACKAGE_NAME", "") -_PACKAGE_MAPPING = {"pytorch": "pytorch_lightning", "app": "lightning_app", "lite": "lightning_lite"} +_PACKAGE_NAME = os.environ.get("PACKAGE_NAME", "lightning") +_PACKAGE_MAPPING = { + "pytorch": "pytorch_lightning", + "app": "lightning_app", + "lite": "lightning_lite", + "lightning": "lightning", +} _REAL_PKG_NAME = _PACKAGE_MAPPING.get(_PACKAGE_NAME, _PACKAGE_NAME) # https://packaging.python.org/guides/single-sourcing-package-version/ # http://blog.ionelmc.ro/2014/05/25/python-packaging/ @@ -63,8 +59,6 @@ _PATH_SRC = os.path.join(_PATH_ROOT, "src") _PATH_REQUIRE = os.path.join(_PATH_ROOT, "requirements") _PATH_SETUP = os.path.join(_PATH_SRC, _REAL_PKG_NAME, "__setup__.py") -if not os.path.isfile(_PATH_SETUP): - _PATH_SETUP = os.path.join(_PATH_SRC, "lightning", "__setup__.py") _FREEZE_REQUIREMENTS = bool(int(os.environ.get("FREEZE_REQUIREMENTS", 0))) @@ -77,18 +71,16 @@ def _load_py_module(name: str, location: str) -> ModuleType: return py -# https://packaging.python.org/discussions/install-requires-vs-requirements / -# keep the meta-data here for simplicity in reading this file... it's not obvious -# what happens and to non-engineers they won't know to look in init ... -# the goal of the project is simplicity for researchers, don't want to add too much -# engineer specific practices if __name__ == "__main__": _SETUP_TOOLS = _load_py_module(name="setup_tools", location=os.path.join(".actions", "setup_tools.py")) - if _PACKAGE_NAME not in _PACKAGE_MAPPING: # install everything + print(f"Installing the {_PACKAGE_NAME} package") # requires `-v` to appear + if _PACKAGE_NAME == "lightning": + # install everything _SETUP_TOOLS._load_aggregate_requirements(_PATH_REQUIRE, _FREEZE_REQUIREMENTS) - - _SETUP_TOOLS.create_mirror_package(os.path.join(_PATH_ROOT, "src"), _PACKAGE_MAPPING) + _SETUP_TOOLS.create_mirror_package(_PATH_SRC, _PACKAGE_MAPPING) + elif _PACKAGE_NAME not in _PACKAGE_MAPPING: + raise ValueError(f"Unexpected package name: {_PACKAGE_NAME}") _SETUP_MODULE = _load_py_module(name="pkg_setup", location=_PATH_SETUP) _SETUP_MODULE._adjust_manifest(pkg_name=_REAL_PKG_NAME) From 52c2b5a18984aca7a352da0a47025a81d78b3e56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mochol=C3=AD?= Date: Thu, 3 Nov 2022 03:51:45 +0100 Subject: [PATCH 08/30] Implement idea --- setup.py | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/setup.py b/setup.py index eaea7e0c3a9da..f3cdbba11575a 100755 --- a/setup.py +++ b/setup.py @@ -45,20 +45,18 @@ from setuptools import setup -_PACKAGE_NAME = os.environ.get("PACKAGE_NAME", "lightning") +_PACKAGE_NAME = os.environ.get("PACKAGE_NAME") _PACKAGE_MAPPING = { + "lightning": "lightning", "pytorch": "pytorch_lightning", "app": "lightning_app", "lite": "lightning_lite", - "lightning": "lightning", } -_REAL_PKG_NAME = _PACKAGE_MAPPING.get(_PACKAGE_NAME, _PACKAGE_NAME) # https://packaging.python.org/guides/single-sourcing-package-version/ # http://blog.ionelmc.ro/2014/05/25/python-packaging/ _PATH_ROOT = os.path.dirname(__file__) _PATH_SRC = os.path.join(_PATH_ROOT, "src") _PATH_REQUIRE = os.path.join(_PATH_ROOT, "requirements") -_PATH_SETUP = os.path.join(_PATH_SRC, _REAL_PKG_NAME, "__setup__.py") _FREEZE_REQUIREMENTS = bool(int(os.environ.get("FREEZE_REQUIREMENTS", 0))) @@ -72,16 +70,26 @@ def _load_py_module(name: str, location: str) -> ModuleType: if __name__ == "__main__": - _SETUP_TOOLS = _load_py_module(name="setup_tools", location=os.path.join(".actions", "setup_tools.py")) + setup_tools = _load_py_module(name="setup_tools", location=os.path.join(".actions", "setup_tools.py")) - print(f"Installing the {_PACKAGE_NAME} package") # requires `-v` to appear - if _PACKAGE_NAME == "lightning": + package_to_install = _PACKAGE_NAME or "lightning" + print(f"Installing the {package_to_install} package") # requires `-v` to appear + if package_to_install == "lightning": # install everything - _SETUP_TOOLS._load_aggregate_requirements(_PATH_REQUIRE, _FREEZE_REQUIREMENTS) - _SETUP_TOOLS.create_mirror_package(_PATH_SRC, _PACKAGE_MAPPING) - elif _PACKAGE_NAME not in _PACKAGE_MAPPING: + setup_tools._load_aggregate_requirements(_PATH_REQUIRE, _FREEZE_REQUIREMENTS) + setup_tools.create_mirror_package(_PATH_SRC, _PACKAGE_MAPPING) + elif package_to_install not in _PACKAGE_MAPPING: raise ValueError(f"Unexpected package name: {_PACKAGE_NAME}") - _SETUP_MODULE = _load_py_module(name="pkg_setup", location=_PATH_SETUP) - _SETUP_MODULE._adjust_manifest(pkg_name=_REAL_PKG_NAME) - setup(**_SETUP_MODULE._setup_args(pkg_name=_REAL_PKG_NAME)) + possible_packages = _PACKAGE_MAPPING.values() if _PACKAGE_NAME is None else [_PACKAGE_MAPPING[_PACKAGE_NAME]] + for pkg in possible_packages: + pkg_setup = os.path.join(_PATH_SRC, pkg, "__setup__.py") + if os.path.exists(pkg_setup): + print(f"{pkg_setup} exists. Running `setuptools.setup`") + setup_module = _load_py_module(name=f"{pkg}_setup", location=pkg_setup) + setup_module._adjust_manifest(pkg_name=pkg) + setup_args = setup_module._setup_args(pkg_name=pkg) + setup(**setup_args) + break + else: + raise RuntimeError("Something's wrong, no package was installed.") From 5ee1cdc74b109042004feb9c2078d73ee7a6dd92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mochol=C3=AD?= Date: Thu, 3 Nov 2022 05:04:13 +0100 Subject: [PATCH 09/30] Fuck --- .actions/setup_tools.py | 6 ++++-- .github/actions/pkg-check/action.yml | 4 ++-- .github/actions/pkg-install/action.yml | 6 ++++-- .github/workflows/ci-pkg-install.yml | 9 ++++----- .github/workflows/docs-checks.yml | 7 ++++--- 5 files changed, 18 insertions(+), 14 deletions(-) diff --git a/.actions/setup_tools.py b/.actions/setup_tools.py index a8c00e797598d..62d1400f61220 100644 --- a/.actions/setup_tools.py +++ b/.actions/setup_tools.py @@ -232,8 +232,10 @@ def create_mirror_package(src_folder: str, lit_pkg_mapping: dict) -> None: ... {"pytorch": "pytorch_lightning", "app": "lightning_app", "lite": "lightning_lite"} ... ) """ - for lit_name, pkg_name in lit_pkg_mapping.items(): - copy_adjusted_modules(src_folder, pkg_name, lit_name, lit_pkg_mapping) + mapping = lit_pkg_mapping.copy() + mapping.pop("lightning", None) # pop this key to avoid replacing `lightning` to `lightning.lightning` + for lit_name, pkg_name in mapping.items(): + copy_adjusted_modules(src_folder, pkg_name, lit_name, mapping) def _download_frontend(pkg_path: str): diff --git a/.github/actions/pkg-check/action.yml b/.github/actions/pkg-check/action.yml index 9f86319774585..6680f945d589d 100644 --- a/.github/actions/pkg-check/action.yml +++ b/.github/actions/pkg-check/action.yml @@ -39,13 +39,13 @@ runs: shell: bash - name: Unzip packages - if: ${{ inputs.pkg-name != '' }} + if: ${{ inputs.pkg-name != 'lightning' }} working-directory: dist run: for file in `ls *.gz`; do tar -xzf $file; done shell: bash - name: Check single pkg/folder - if: ${{ inputs.pkg-name != '' }} + if: ${{ inputs.pkg-name != 'lightning' }} working-directory: dist run: | import os, glob, pathlib, shutil diff --git a/.github/actions/pkg-install/action.yml b/.github/actions/pkg-install/action.yml index c10d6d98a1949..53cd0563a8d1a 100644 --- a/.github/actions/pkg-install/action.yml +++ b/.github/actions/pkg-install/action.yml @@ -18,7 +18,8 @@ runs: run: | pip install *.tar.gz ${{ inputs.pip-flags }} pip list | grep lightning - python -c "import ${{ inputs.pkg-name }}; print(${{ inputs.pkg-name }}.__version__)" + PKG_NAME=$(python -c "print({'app': 'lightning_app', 'lite': 'lightning_lite', 'pytorch': 'pytorch_lightning', 'lightning': 'lightning'}['${{matrix.pkg-name}}'])") + python -c "import ${PKG_NAME}; print(${PKG_NAME}.__version__)" shell: bash - name: Install package - wheel @@ -26,5 +27,6 @@ runs: run: | pip install *.whl ${{ inputs.pip-flags }} pip list | grep lightning - python -c "import ${{ inputs.pkg-name }}; print(${{ inputs.pkg-name }}.__version__)" + PKG_NAME=$(python -c "print({'app': 'lightning_app', 'lite': 'lightning_lite', 'pytorch': 'pytorch_lightning', 'lightning': 'lightning'}['${{matrix.pkg-name}}'])") + python -c "import ${PKG_NAME}; print(${PKG_NAME}.__version__)" shell: bash diff --git a/.github/workflows/ci-pkg-install.yml b/.github/workflows/ci-pkg-install.yml index afafc662a4a8e..79d72e9ac27d9 100644 --- a/.github/workflows/ci-pkg-install.yml +++ b/.github/workflows/ci-pkg-install.yml @@ -68,7 +68,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-22.04, macOS-12, windows-2022] - pkg-name: ["app", "lite", "pytorch", ""] + pkg-name: ["app", "lite", "pytorch", "lightning"] python-version: ["3.7" , "3.10"] steps: - uses: actions/checkout@v3 @@ -104,11 +104,10 @@ jobs: - name: Run CLI # todo: add testing for `lightning_app` - if: ${{ matrix.pkg-name == '' }} + if: ${{ matrix.pkg-name == 'lightning' }} run: python -m lightning --version - name: DocTest package run: | - pip list - scope=$(python -c "lut = {'app': 'lightning_app', 'lite': 'lightning_lite', 'pytorch': 'pytorch_lightning'} ; print(lut.get('${{matrix.pkg-name}}', 'lightning'))") - python -m pytest src/${scope} --ignore-glob="**/cli/*-template/**" + PKG_NAME=$(python -c "print({'app': 'lightning_app', 'lite': 'lightning_lite', 'pytorch': 'pytorch_lightning', 'lightning': 'lightning'}['${{matrix.pkg-name}}'])") + python -m pytest src/${PKG_NAME} --ignore-glob="**/cli/*-template/**" diff --git a/.github/workflows/docs-checks.yml b/.github/workflows/docs-checks.yml index 42f305d3feaf2..964ad114069d3 100644 --- a/.github/workflows/docs-checks.yml +++ b/.github/workflows/docs-checks.yml @@ -139,13 +139,14 @@ jobs: ${{ runner.os }}-docs-make-${{ matrix.pkg-name }}- - name: Install package & dependencies - env: - PACKAGE_NAME: ${{ matrix.pkg-name }} run: | sudo apt-get update sudo apt-get install -y cmake pandoc texlive-latex-extra dvipng texlive-pictures pip --version - pip install -e . -r requirements/${{ matrix.pkg-name }}/docs.txt \ + # TODO: lit should be renamed to lightning + PACKAGE_NAME=$(python -c "print('lightning' if '${{matrix.pkg-name}}' == 'lit' else '${{matrix.pkg-name}}')") \ + pip install -e . \ + -r requirements/${{ matrix.pkg-name }}/docs.txt \ --find-links https://download.pytorch.org/whl/cpu/torch_stable.html \ --find-links pypi pip list From 165bb52bdb981aa3285ec27809e2e3ecbe317148 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mochol=C3=AD?= Date: Thu, 3 Nov 2022 05:19:56 +0100 Subject: [PATCH 10/30] Apps mock fix --- .github/workflows/ci-app-examples.yml | 3 +-- src/lightning_app/testing/testing.py | 4 +--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci-app-examples.yml b/.github/workflows/ci-app-examples.yml index d05d272401643..b0b217762a72c 100644 --- a/.github/workflows/ci-app-examples.yml +++ b/.github/workflows/ci-app-examples.yml @@ -98,8 +98,7 @@ jobs: - name: Adjust examples if: ${{ matrix.pkg-name != 'lightning' }} run: | - python .actions/assistant.py copy_replace_imports --source_dir="./examples" --source_import="lightning.app" --target_import="lightning_app" - python .actions/assistant.py copy_replace_imports --source_dir="./examples" --source_import="lightning" --target_import="lightning_app" + python .actions/assistant.py copy_replace_imports --source_dir="./examples" --source_import="lightning.app,lightning" --target_import="lightning_app,lightning_app" - name: Switch coverage scope run: python -c "print('COVERAGE_SCOPE=' + str('lightning' if '${{matrix.pkg-name}}' == 'lightning' else 'lightning_app'))" >> $GITHUB_ENV diff --git a/src/lightning_app/testing/testing.py b/src/lightning_app/testing/testing.py index a7a2b70d474a6..d8739bb85334a 100644 --- a/src/lightning_app/testing/testing.py +++ b/src/lightning_app/testing/testing.py @@ -137,9 +137,7 @@ def application_testing( from click.testing import CliRunner - with mock.patch("lightning.LightningApp", lightning_app_cls), mock.patch( - "lightning_app.LightningApp", lightning_app_cls - ): + with mock.patch("lightning_app.LightningApp", lightning_app_cls): original = sys.argv sys.argv = command_line runner = CliRunner() From 911fb917c39c362fac4bc621921f9b173904bcfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mochol=C3=AD?= Date: Thu, 3 Nov 2022 13:26:50 +0100 Subject: [PATCH 11/30] Fix app-pytest with PKG_NAME=app --- .github/workflows/ci-app-tests.yml | 3 +-- tests/tests_app/cli/test_cli.py | 12 ++++++------ tests/tests_app/cli/test_cmd_react_ui_init.py | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci-app-tests.yml b/.github/workflows/ci-app-tests.yml index f6f479dd1cbd7..c8aa84c760503 100644 --- a/.github/workflows/ci-app-tests.yml +++ b/.github/workflows/ci-app-tests.yml @@ -101,8 +101,7 @@ jobs: - name: Adjust examples if: ${{ matrix.pkg-name != 'lightning' }} run: | - python .actions/assistant.py copy_replace_imports --source_dir="./examples" --source_import="lightning.app" --target_import="lightning_app" - python .actions/assistant.py copy_replace_imports --source_dir="./examples" --source_import="lightning" --target_import="lightning_app" + python .actions/assistant.py copy_replace_imports --source_dir="./examples" --source_import="lightning.app,lightning" --target_import="lightning_app,lightning_app" - name: Switch coverage scope run: python -c "print('COVERAGE_SCOPE=' + str('lightning' if '${{matrix.pkg-name}}' == 'lightning' else 'lightning_app'))" >> $GITHUB_ENV diff --git a/tests/tests_app/cli/test_cli.py b/tests/tests_app/cli/test_cli.py index 044b8542da073..de3d2246527f7 100644 --- a/tests/tests_app/cli/test_cli.py +++ b/tests/tests_app/cli/test_cli.py @@ -52,7 +52,7 @@ def test_commands(command): def test_main_lightning_cli_no_arguments(): """Validate the Lightning CLI without args.""" - res = os.popen("python -m lightning").read() + res = os.popen("lightning").read() assert "login " in res assert "logout " in res assert "run " in res @@ -66,7 +66,7 @@ def test_main_lightning_cli_no_arguments(): def test_main_lightning_cli_help(): """Validate the Lightning CLI.""" - res = os.popen("python -m lightning --help").read() + res = os.popen("lightning --help").read() assert "login " in res assert "logout " in res assert "run " in res @@ -77,7 +77,7 @@ def test_main_lightning_cli_help(): assert "add " in res assert "remove " in res - res = os.popen("python -m lightning run --help").read() + res = os.popen("lightning run --help").read() assert "app " in res # hidden run commands should not appear in the help text @@ -87,12 +87,12 @@ def test_main_lightning_cli_help(): assert "frontend" not in res # inspect show group - res = os.popen("python -m lightning show --help").read() + res = os.popen("lightning show --help").read() assert "logs " in res assert "cluster " in res # inspect show cluster group - res = os.popen("python -m lightning show cluster --help").read() + res = os.popen("lightning show cluster --help").read() assert "logs " in res @@ -185,7 +185,7 @@ def test_cli_logout(exists: mock.MagicMock, unlink: mock.MagicMock, creds: bool) def test_lightning_cli_version(): - res = os.popen("python -m lightning --version").read() + res = os.popen("lightning --version").read() assert __version__ in res diff --git a/tests/tests_app/cli/test_cmd_react_ui_init.py b/tests/tests_app/cli/test_cmd_react_ui_init.py index 6b3bd530a6ccd..0cc84525bb906 100644 --- a/tests/tests_app/cli/test_cmd_react_ui_init.py +++ b/tests/tests_app/cli/test_cmd_react_ui_init.py @@ -32,7 +32,7 @@ def test_missing_yarn(): @_RunIf(skip_windows=True) def test_copy_and_setup_react_ui(tmpdir): dest_dir = os.path.join(tmpdir, "react-ui") - subprocess.Popen(["python", "-m", "lightning", "init", "react-ui", "--dest_dir", dest_dir]).wait() + subprocess.Popen(["lightning", "init", "react-ui", "--dest_dir", dest_dir]).wait() # make sure package is minimal files = sorted(f for f in os.listdir(dest_dir) if f != "__pycache__") From 4fd30c879dcc32817cb2283477d637cfbe2bac84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mochol=C3=AD?= Date: Thu, 3 Nov 2022 14:09:43 +0100 Subject: [PATCH 12/30] Justus suggestion --- src/lightning_app/testing/testing.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/lightning_app/testing/testing.py b/src/lightning_app/testing/testing.py index d8739bb85334a..6bf17707cf512 100644 --- a/src/lightning_app/testing/testing.py +++ b/src/lightning_app/testing/testing.py @@ -7,7 +7,7 @@ import sys import tempfile import time -from contextlib import contextmanager +from contextlib import contextmanager, nullcontext from multiprocessing import Process from subprocess import Popen from time import sleep @@ -137,7 +137,12 @@ def application_testing( from click.testing import CliRunner - with mock.patch("lightning_app.LightningApp", lightning_app_cls): + patch1 = mock.patch("lightning_app.LightningApp", lightning_app_cls) + # we need to patch both only with the mirror package + patch2 = ( + mock.patch("lightning.LightningApp", lightning_app_cls) if "lightning.app" in sys.modules else nullcontext() + ) + with patch1, patch2: original = sys.argv sys.argv = command_line runner = CliRunner() From 9fe3ba366545ba9e308b0757876279b1fff8a553 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mochol=C3=AD?= Date: Thu, 3 Nov 2022 15:04:47 +0100 Subject: [PATCH 13/30] Debug Windows --- tests/tests_app/cli/test_cli.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/tests/tests_app/cli/test_cli.py b/tests/tests_app/cli/test_cli.py index de3d2246527f7..4f9b5f1448121 100644 --- a/tests/tests_app/cli/test_cli.py +++ b/tests/tests_app/cli/test_cli.py @@ -1,4 +1,4 @@ -import os +import subprocess from unittest import mock from unittest.mock import MagicMock @@ -52,7 +52,12 @@ def test_commands(command): def test_main_lightning_cli_no_arguments(): """Validate the Lightning CLI without args.""" - res = os.popen("lightning").read() + # FIXME: + import sys + + if sys.platform == "win32": + print(subprocess.getoutput("where lightning")) + res = subprocess.getoutput("lightning") assert "login " in res assert "logout " in res assert "run " in res @@ -66,7 +71,7 @@ def test_main_lightning_cli_no_arguments(): def test_main_lightning_cli_help(): """Validate the Lightning CLI.""" - res = os.popen("lightning --help").read() + res = subprocess.getoutput("lightning --help") assert "login " in res assert "logout " in res assert "run " in res @@ -77,7 +82,7 @@ def test_main_lightning_cli_help(): assert "add " in res assert "remove " in res - res = os.popen("lightning run --help").read() + res = subprocess.getoutput("lightning run --help") assert "app " in res # hidden run commands should not appear in the help text @@ -87,12 +92,12 @@ def test_main_lightning_cli_help(): assert "frontend" not in res # inspect show group - res = os.popen("lightning show --help").read() + res = subprocess.getoutput("lightning show --help") assert "logs " in res assert "cluster " in res # inspect show cluster group - res = os.popen("lightning show cluster --help").read() + res = subprocess.getoutput("lightning show cluster --help") assert "logs " in res @@ -185,7 +190,7 @@ def test_cli_logout(exists: mock.MagicMock, unlink: mock.MagicMock, creds: bool) def test_lightning_cli_version(): - res = os.popen("lightning --version").read() + res = subprocess.getoutput("lightning --version") assert __version__ in res From 54dcb900b8125991c18e49489e9c27d7f70b143d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mochol=C3=AD?= Date: Thu, 3 Nov 2022 15:53:00 +0100 Subject: [PATCH 14/30] Update setup.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Adrian Wälchli --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index f3cdbba11575a..c1bb7cd0c6ccd 100755 --- a/setup.py +++ b/setup.py @@ -79,7 +79,7 @@ def _load_py_module(name: str, location: str) -> ModuleType: setup_tools._load_aggregate_requirements(_PATH_REQUIRE, _FREEZE_REQUIREMENTS) setup_tools.create_mirror_package(_PATH_SRC, _PACKAGE_MAPPING) elif package_to_install not in _PACKAGE_MAPPING: - raise ValueError(f"Unexpected package name: {_PACKAGE_NAME}") + raise ValueError(f"Unexpected package name: {_PACKAGE_NAME}. Possible choices are: {list(_PACKAGE_MAPPING)}") possible_packages = _PACKAGE_MAPPING.values() if _PACKAGE_NAME is None else [_PACKAGE_MAPPING[_PACKAGE_NAME]] for pkg in possible_packages: From db1329bfbbf1534a678791663c9571be66a7927c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mochol=C3=AD?= Date: Thu, 3 Nov 2022 15:45:13 +0100 Subject: [PATCH 15/30] Revert "Debug Windows" This reverts commit 9fe3ba366545ba9e308b0757876279b1fff8a553. --- tests/tests_app/cli/test_cli.py | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/tests/tests_app/cli/test_cli.py b/tests/tests_app/cli/test_cli.py index 4f9b5f1448121..de3d2246527f7 100644 --- a/tests/tests_app/cli/test_cli.py +++ b/tests/tests_app/cli/test_cli.py @@ -1,4 +1,4 @@ -import subprocess +import os from unittest import mock from unittest.mock import MagicMock @@ -52,12 +52,7 @@ def test_commands(command): def test_main_lightning_cli_no_arguments(): """Validate the Lightning CLI without args.""" - # FIXME: - import sys - - if sys.platform == "win32": - print(subprocess.getoutput("where lightning")) - res = subprocess.getoutput("lightning") + res = os.popen("lightning").read() assert "login " in res assert "logout " in res assert "run " in res @@ -71,7 +66,7 @@ def test_main_lightning_cli_no_arguments(): def test_main_lightning_cli_help(): """Validate the Lightning CLI.""" - res = subprocess.getoutput("lightning --help") + res = os.popen("lightning --help").read() assert "login " in res assert "logout " in res assert "run " in res @@ -82,7 +77,7 @@ def test_main_lightning_cli_help(): assert "add " in res assert "remove " in res - res = subprocess.getoutput("lightning run --help") + res = os.popen("lightning run --help").read() assert "app " in res # hidden run commands should not appear in the help text @@ -92,12 +87,12 @@ def test_main_lightning_cli_help(): assert "frontend" not in res # inspect show group - res = subprocess.getoutput("lightning show --help") + res = os.popen("lightning show --help").read() assert "logs " in res assert "cluster " in res # inspect show cluster group - res = subprocess.getoutput("lightning show cluster --help") + res = os.popen("lightning show cluster --help").read() assert "logs " in res @@ -190,7 +185,7 @@ def test_cli_logout(exists: mock.MagicMock, unlink: mock.MagicMock, creds: bool) def test_lightning_cli_version(): - res = subprocess.getoutput("lightning --version") + res = os.popen("lightning --version").read() assert __version__ in res From 5061e8e7d6fdf47b38c676623b02387cd451d403 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mochol=C3=AD?= Date: Thu, 3 Nov 2022 15:55:29 +0100 Subject: [PATCH 16/30] SSH action --- .github/workflows/ci-app-tests.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-app-tests.yml b/.github/workflows/ci-app-tests.yml index c8aa84c760503..89c5c7771b676 100644 --- a/.github/workflows/ci-app-tests.yml +++ b/.github/workflows/ci-app-tests.yml @@ -43,7 +43,7 @@ jobs: - {os: "windows-2022", pkg-name: "lightning", python-version: "3.8", requires: "latest"} # Timeout: https://stackoverflow.com/a/59076067/4521646 - timeout-minutes: 30 + timeout-minutes: 999 steps: - uses: actions/checkout@v3 @@ -106,6 +106,10 @@ jobs: - name: Switch coverage scope run: python -c "print('COVERAGE_SCOPE=' + str('lightning' if '${{matrix.pkg-name}}' == 'lightning' else 'lightning_app'))" >> $GITHUB_ENV + - name: Setup tmate session + if: ${{ matrix.os == 'windows-2022' && matrix.pkg-name == 'app' }} + uses: mxschmitt/action-tmate@v3 + - name: Tests working-directory: ./tests env: From ff1305ec42576e4e051702fe579bac8d6e0111c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mochol=C3=AD?= Date: Thu, 3 Nov 2022 16:46:31 +0100 Subject: [PATCH 17/30] Crazy bug --- src/lightning_app/utilities/cli_helpers.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lightning_app/utilities/cli_helpers.py b/src/lightning_app/utilities/cli_helpers.py index 4b404ebf56661..eb0c920074d0e 100644 --- a/src/lightning_app/utilities/cli_helpers.py +++ b/src/lightning_app/utilities/cli_helpers.py @@ -299,7 +299,8 @@ def _check_environment_and_redirect(): """ env_executable = shutil.which("python") - if env_executable != sys.executable: + # on windows, the extension might be different, where one uses `.EXE` and the other `.exe` + if env_executable.lower() != sys.executable.lower(): logger.info( "Lightning is running from outside your current environment. Switching to your current environment." ) From ee5097616c70355dec3bf8decc8372fcc2cece29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mochol=C3=AD?= Date: Thu, 3 Nov 2022 16:46:44 +0100 Subject: [PATCH 18/30] Revert "SSH action" This reverts commit 5061e8e7d6fdf47b38c676623b02387cd451d403. --- .github/workflows/ci-app-tests.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/ci-app-tests.yml b/.github/workflows/ci-app-tests.yml index 89c5c7771b676..c8aa84c760503 100644 --- a/.github/workflows/ci-app-tests.yml +++ b/.github/workflows/ci-app-tests.yml @@ -43,7 +43,7 @@ jobs: - {os: "windows-2022", pkg-name: "lightning", python-version: "3.8", requires: "latest"} # Timeout: https://stackoverflow.com/a/59076067/4521646 - timeout-minutes: 999 + timeout-minutes: 30 steps: - uses: actions/checkout@v3 @@ -106,10 +106,6 @@ jobs: - name: Switch coverage scope run: python -c "print('COVERAGE_SCOPE=' + str('lightning' if '${{matrix.pkg-name}}' == 'lightning' else 'lightning_app'))" >> $GITHUB_ENV - - name: Setup tmate session - if: ${{ matrix.os == 'windows-2022' && matrix.pkg-name == 'app' }} - uses: mxschmitt/action-tmate@v3 - - name: Tests working-directory: ./tests env: From 4570715d80a948af6f4cf20e54869798c1742684 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mochol=C3=AD?= Date: Fri, 4 Nov 2022 01:07:33 +0100 Subject: [PATCH 19/30] Package import step --- .github/actions/pkg-install/action.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/actions/pkg-install/action.yml b/.github/actions/pkg-install/action.yml index 53cd0563a8d1a..51d6b4fe74bb3 100644 --- a/.github/actions/pkg-install/action.yml +++ b/.github/actions/pkg-install/action.yml @@ -13,13 +13,17 @@ inputs: runs: using: "composite" steps: + - name: Choose package import + run: | + python -c "print('PACKAGE_NAME=' + {'app': 'lightning_app', 'lite': 'lightning_lite', 'pytorch': 'pytorch_lightning', 'lightning': 'lightning'}['${{matrix.pkg-name}}'])" >> $GITHUB_ENV + shell: bash + - name: Install package - archive working-directory: ./dist run: | pip install *.tar.gz ${{ inputs.pip-flags }} pip list | grep lightning - PKG_NAME=$(python -c "print({'app': 'lightning_app', 'lite': 'lightning_lite', 'pytorch': 'pytorch_lightning', 'lightning': 'lightning'}['${{matrix.pkg-name}}'])") - python -c "import ${PKG_NAME}; print(${PKG_NAME}.__version__)" + python -c "import ${{ env.PACKAGE_NAME }}; print(${{ env.PACKAGE_NAME }}.__version__)" shell: bash - name: Install package - wheel @@ -27,6 +31,5 @@ runs: run: | pip install *.whl ${{ inputs.pip-flags }} pip list | grep lightning - PKG_NAME=$(python -c "print({'app': 'lightning_app', 'lite': 'lightning_lite', 'pytorch': 'pytorch_lightning', 'lightning': 'lightning'}['${{matrix.pkg-name}}'])") - python -c "import ${PKG_NAME}; print(${PKG_NAME}.__version__)" + python -c "import ${{ env.PACKAGE_NAME }}; print(${{ env.PACKAGE_NAME }}.__version__)" shell: bash From 79306159ea5829237362d86a485aaacc0e12809c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mochol=C3=AD?= Date: Fri, 4 Nov 2022 01:15:27 +0100 Subject: [PATCH 20/30] Avoid env conflict --- .github/actions/pkg-install/action.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/actions/pkg-install/action.yml b/.github/actions/pkg-install/action.yml index 51d6b4fe74bb3..0e0751c217a95 100644 --- a/.github/actions/pkg-install/action.yml +++ b/.github/actions/pkg-install/action.yml @@ -15,7 +15,7 @@ runs: steps: - name: Choose package import run: | - python -c "print('PACKAGE_NAME=' + {'app': 'lightning_app', 'lite': 'lightning_lite', 'pytorch': 'pytorch_lightning', 'lightning': 'lightning'}['${{matrix.pkg-name}}'])" >> $GITHUB_ENV + python -c "print('PKG_IMPORT=' + {'app': 'lightning_app', 'lite': 'lightning_lite', 'pytorch': 'pytorch_lightning', 'lightning': 'lightning'}['${{matrix.pkg-name}}'])" >> $GITHUB_ENV shell: bash - name: Install package - archive @@ -23,7 +23,7 @@ runs: run: | pip install *.tar.gz ${{ inputs.pip-flags }} pip list | grep lightning - python -c "import ${{ env.PACKAGE_NAME }}; print(${{ env.PACKAGE_NAME }}.__version__)" + python -c "import ${{ env.PKG_IMPORT }}; print(${{ env.PKG_IMPORT }}.__version__)" shell: bash - name: Install package - wheel @@ -31,5 +31,5 @@ runs: run: | pip install *.whl ${{ inputs.pip-flags }} pip list | grep lightning - python -c "import ${{ env.PACKAGE_NAME }}; print(${{ env.PACKAGE_NAME }}.__version__)" + python -c "import ${{ env.PKG_IMPORT }}; print(${{ env.PKG_IMPORT }}.__version__)" shell: bash From 54c26bfa173c744460e9f8f5de210f52f0920c03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mochol=C3=AD?= Date: Fri, 4 Nov 2022 01:40:47 +0100 Subject: [PATCH 21/30] Debug --- .github/workflows/docs-checks.yml | 5 ++++- setup.py | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docs-checks.yml b/.github/workflows/docs-checks.yml index 2b65300d0a71e..23cc8029bd60a 100644 --- a/.github/workflows/docs-checks.yml +++ b/.github/workflows/docs-checks.yml @@ -136,10 +136,12 @@ jobs: with: submodules: true ref: ${{ github.event.pull_request.head.sha }} + - uses: actions/download-artifact@v3 with: name: ci-packages-${{ github.sha }} path: pypi + - uses: actions/setup-python@v4 with: python-version: "3.9" @@ -150,6 +152,7 @@ jobs: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY_ID }} aws-region: us-east-1 + - run: aws s3 sync s3://sphinx-packages/ pypi/ if: ${{ matrix.pkg-name != 'pytorch' }} @@ -169,7 +172,7 @@ jobs: sudo apt-get install -y cmake pandoc texlive-latex-extra dvipng texlive-pictures pip --version # TODO: lit should be renamed to lightning - PACKAGE_NAME=$(python -c "print('lightning' if '${{matrix.pkg-name}}' == 'lit' else '${{matrix.pkg-name}}')") \ + PACKAGE_NAME=$(python -c "print('lightning' if '${{ matrix.pkg-name }}' == 'lit' else '${{ matrix.pkg-name }}')") \ pip install -e . -U \ -r requirements/${{ matrix.pkg-name }}/docs.txt \ -f https://download.pytorch.org/whl/cpu/torch_stable.html \ diff --git a/setup.py b/setup.py index c1bb7cd0c6ccd..ce2505223302c 100755 --- a/setup.py +++ b/setup.py @@ -81,6 +81,9 @@ def _load_py_module(name: str, location: str) -> ModuleType: elif package_to_install not in _PACKAGE_MAPPING: raise ValueError(f"Unexpected package name: {_PACKAGE_NAME}. Possible choices are: {list(_PACKAGE_MAPPING)}") + # if `_PACKAGE_NAME` is not set, iterate over all possible packages until we find one that can be installed. + # this is useful for installing existing wheels, as the user wouldn't set this environment variable, but the wheel + # should have included only the relevant files of the package to install possible_packages = _PACKAGE_MAPPING.values() if _PACKAGE_NAME is None else [_PACKAGE_MAPPING[_PACKAGE_NAME]] for pkg in possible_packages: pkg_setup = os.path.join(_PATH_SRC, pkg, "__setup__.py") @@ -92,4 +95,4 @@ def _load_py_module(name: str, location: str) -> ModuleType: setup(**setup_args) break else: - raise RuntimeError("Something's wrong, no package was installed.") + raise RuntimeError(f"Something's wrong, no package was installed. Package name: {_PACKAGE_NAME}") From 0eab710992cb69345d6eb55d574fe0debfd0fe6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mochol=C3=AD?= Date: Fri, 4 Nov 2022 02:01:05 +0100 Subject: [PATCH 22/30] Whitespace --- .github/workflows/docs-checks.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/docs-checks.yml b/.github/workflows/docs-checks.yml index 23cc8029bd60a..88d4458aa71b4 100644 --- a/.github/workflows/docs-checks.yml +++ b/.github/workflows/docs-checks.yml @@ -34,13 +34,16 @@ jobs: - uses: actions/checkout@v3 with: ref: ${{ github.event.pull_request.head.sha }} + - uses: actions/setup-python@v4 with: python-version: "3.8" + - name: Build package env: PACKAGE_NAME: "lite" run: python setup.py sdist + - uses: actions/upload-artifact@v3 with: name: ci-packages-${{ github.sha }} @@ -61,10 +64,12 @@ jobs: with: submodules: true ref: ${{ github.event.pull_request.head.sha }} + - uses: actions/download-artifact@v3 with: name: ci-packages-${{ github.sha }} path: pypi + - uses: actions/setup-python@v4 with: python-version: "3.9" @@ -75,6 +80,7 @@ jobs: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY_ID }} aws-region: us-east-1 + - run: aws s3 sync s3://sphinx-packages/ pypi/ if: ${{ matrix.pkg-name == 'app' }} From c6b3751185c483d0cd9b5916c3e0dc7c73ab345e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mochol=C3=AD?= Date: Fri, 4 Nov 2022 02:05:20 +0100 Subject: [PATCH 23/30] Try removing existing lite build --- .github/workflows/docs-checks.yml | 26 -------------------------- requirements/pytorch/base.txt | 1 - 2 files changed, 27 deletions(-) diff --git a/.github/workflows/docs-checks.yml b/.github/workflows/docs-checks.yml index 88d4458aa71b4..2f1e731940c0f 100644 --- a/.github/workflows/docs-checks.yml +++ b/.github/workflows/docs-checks.yml @@ -26,33 +26,8 @@ defaults: shell: bash jobs: - - build-pypi: - # This serves to create packages for potential internal dependencies - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v3 - with: - ref: ${{ github.event.pull_request.head.sha }} - - - uses: actions/setup-python@v4 - with: - python-version: "3.8" - - - name: Build package - env: - PACKAGE_NAME: "lite" - run: python setup.py sdist - - - uses: actions/upload-artifact@v3 - with: - name: ci-packages-${{ github.sha }} - path: dist - make-doctest: runs-on: ubuntu-20.04 - # make it depending on build docs to reduce load - needs: build-pypi strategy: fail-fast: false matrix: @@ -129,7 +104,6 @@ jobs: make coverage make-html: - needs: build-pypi runs-on: ubuntu-20.04 strategy: fail-fast: false diff --git a/requirements/pytorch/base.txt b/requirements/pytorch/base.txt index 765be74803fe0..e3eae1cd66ce8 100644 --- a/requirements/pytorch/base.txt +++ b/requirements/pytorch/base.txt @@ -3,7 +3,6 @@ numpy>=1.17.2, <1.23.1 torch>=1.9.*, <1.13.0 -lightning-lite # actual version comes from src tqdm>=4.57.0, <4.65.0 PyYAML>=5.4, <=6.0 fsspec[http]>2021.06.0, <2022.8.0 From fac814a8352d678ed6a8146f83396a109becb5e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mochol=C3=AD?= Date: Fri, 4 Nov 2022 02:19:33 +0100 Subject: [PATCH 24/30] This should be redundant now --- .actions/setup_tools.py | 16 ------- .azure/gpu-benchmark.yml | 10 ----- .azure/gpu-tests-pytorch.yml | 10 ----- .azure/hpu-tests.yml | 10 ----- .azure/ipu-tests.yml | 10 ----- .github/workflows/ci-pkg-install.yml | 48 --------------------- .github/workflows/ci-pytorch-tests-slow.yml | 9 ---- .github/workflows/ci-pytorch-tests.yml | 10 ----- src/pytorch_lightning/__setup__.py | 6 +-- 9 files changed, 2 insertions(+), 127 deletions(-) diff --git a/.actions/setup_tools.py b/.actions/setup_tools.py index 62d1400f61220..77034a9b26580 100644 --- a/.actions/setup_tools.py +++ b/.actions/setup_tools.py @@ -274,19 +274,3 @@ def _load_aggregate_requirements(req_dir: str = "requirements", freeze_requireme requires = list(chain(*requires)) with open(os.path.join(req_dir, "base.txt"), "w") as fp: fp.writelines([ln + os.linesep for ln in requires]) - - -def set_actual_version_from_src(req_path: str, src_root: str, pkg_name: str) -> None: - """Setting actual version from source code for a given package.""" - with open(req_path, encoding="utf-8") as fo: - lines = fo.readlines() - ver = parse_version_from_file(os.path.join(src_root, pkg_name.replace("-", "_"))) - for i, ln in enumerate(lines): - reqs = list(parse_requirements([ln])) - if not reqs: - continue - if reqs[0].name == pkg_name: - lines[i] = f"{pkg_name}=={ver}{os.linesep}" - - with open(req_path, "w", encoding="utf-8") as fw: - fw.writelines(lines) diff --git a/.azure/gpu-benchmark.yml b/.azure/gpu-benchmark.yml index dc99cfef95cb7..8fad0d69c15d1 100644 --- a/.azure/gpu-benchmark.yml +++ b/.azure/gpu-benchmark.yml @@ -51,16 +51,6 @@ jobs: echo "##vso[task.setvariable variable=TORCH_URL]https://download.pytorch.org/whl/cu${cuda_ver}/torch_stable.html" displayName: 'set env. vars' - - bash: | - pip install -e . --find-links ${TORCH_URL} - git checkout -- MANIFEST.in - env: - PACKAGE_NAME: lite - FREEZE_REQUIREMENTS: 1 - # Lite shall have pin version, so to keep development aligned we need to install lite from source not from pypi - # also installing from source not from on-the-fly created package tp prevent accidental interaction with cache - displayName: 'Install Lite pkg' - - bash: | pip install -e .[strategies] --find-links ${TORCH_URL} pip list diff --git a/.azure/gpu-tests-pytorch.yml b/.azure/gpu-tests-pytorch.yml index fbc44ac193519..05571269a99a7 100644 --- a/.azure/gpu-tests-pytorch.yml +++ b/.azure/gpu-tests-pytorch.yml @@ -93,16 +93,6 @@ jobs: python ./requirements/pytorch/adjust-versions.py requirements/pytorch/examples.txt ${PYTORCH_VERSION} displayName: 'Adjust dependencies' - - bash: | - pip install -e . --find-links ${TORCH_URL} - git checkout -- MANIFEST.in - env: - PACKAGE_NAME: "lite" - FREEZE_REQUIREMENTS: "1" - # Lite shall have pin version, so to keep development aligned we need to install lite from source not from pypi - # also installing from source not from on-the-fly created package to prevent accidental interaction with cache - displayName: 'Install Lite pkg' - - bash: pip install -e .[strategies] -r requirements/pytorch/devel.txt -r requirements/pytorch/examples.txt --find-links ${TORCH_URL} env: PACKAGE_NAME: "pytorch" diff --git a/.azure/hpu-tests.yml b/.azure/hpu-tests.yml index 77c90a744979b..8281f9e5c5fa6 100644 --- a/.azure/hpu-tests.yml +++ b/.azure/hpu-tests.yml @@ -58,16 +58,6 @@ jobs: sudo pip install pip -U displayName: 'Instance HW info' - - bash: | - pip install -e . - git checkout -- MANIFEST.in - env: - PACKAGE_NAME: "lite" - FREEZE_REQUIREMENTS: "1" - # Lite shall have pin version, so to keep development aligned we need to install lite from source not from pypi - # also installing from source not from on-the-fly created package to prevent accidental interaction with cache - displayName: 'Install Lite pkg' - - bash: | set -e pip --version diff --git a/.azure/ipu-tests.yml b/.azure/ipu-tests.yml index 6584c9563d46d..972bf1e95a06b 100644 --- a/.azure/ipu-tests.yml +++ b/.azure/ipu-tests.yml @@ -62,16 +62,6 @@ jobs: done displayName: "Reset IPU devices" - - bash: | - pip install -e . - git checkout -- MANIFEST.in - env: - PACKAGE_NAME: "lite" - FREEZE_REQUIREMENTS: "1" - # Lite shall have pin version, so to keep development aligned we need to install lite from source not from pypi - # also installing from source not from on-the-fly created package tp prevent accidental interaction with cache - displayName: 'Install Lite pkg' - - bash: | python ./requirements/pytorch/adjust-versions.py requirements/pytorch/extra.txt python ./requirements/pytorch/adjust-versions.py requirements/pytorch/examples.txt diff --git a/.github/workflows/ci-pkg-install.yml b/.github/workflows/ci-pkg-install.yml index 1307f4b301b9c..54e50a0682d81 100644 --- a/.github/workflows/ci-pkg-install.yml +++ b/.github/workflows/ci-pkg-install.yml @@ -23,47 +23,7 @@ defaults: shell: bash jobs: - - init-pypi: - runs-on: ubuntu-20.04 - steps: - - run: mkdir pypi && touch pypi/.placeholder - - uses: actions/upload-artifact@v3 - with: - name: ci-packages-${{ github.sha }} - path: pypi - - build-pypi: - needs: init-pypi - # This serves to create packages for potential internal dependencies - runs-on: ubuntu-20.04 - strategy: - fail-fast: true - max-parallel: 1 - matrix: - pkg-name: ["lite"] - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 - with: - python-version: "3.8" - - uses: actions/download-artifact@v3 - with: - name: ci-packages-${{ github.sha }} - path: pypi - - name: Build package - env: - PACKAGE_NAME: ${{ matrix.pkg-name }} - run: | - python setup.py sdist - cp dist/* pypi/ - - uses: actions/upload-artifact@v3 - with: - name: ci-packages-${{ github.sha }} - path: pypi - install-pkg: - needs: build-pypi runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -91,17 +51,9 @@ jobs: pkg-name: ${{ matrix.pkg-name }} nb-dirs: ${{ env.NB_DIRS }} - - uses: actions/download-artifact@v3 - with: - name: ci-packages-${{ github.sha }} - path: pypi - - - run: ls -l pypi/ - - uses: ./.github/actions/pkg-install with: pkg-name: ${{ matrix.pkg-name }} - pip-flags: "--pre --find-links ../pypi/" - name: Run CLI # todo: add testing for `lightning_app` diff --git a/.github/workflows/ci-pytorch-tests-slow.yml b/.github/workflows/ci-pytorch-tests-slow.yml index a325eea39bbb0..a775a7241a749 100644 --- a/.github/workflows/ci-pytorch-tests-slow.yml +++ b/.github/workflows/ci-pytorch-tests-slow.yml @@ -56,15 +56,6 @@ jobs: restore-keys: | ${{ runner.os }}-pip-py${{ matrix.python-version }}- - - name: Install lite for PL - # Lite shall have pin version, so to keep development aligned we need to install lite from source not from pypi - # also installing from source not from on-the-fly created package to prevent accidental interaction with cache - env: - PACKAGE_NAME: "lite" - run: | - pip install -e . --upgrade --find-links https://download.pytorch.org/whl/cpu/torch_stable.html - git checkout -- MANIFEST.in - - name: Install package & dependencies env: PACKAGE_NAME: "pytorch" diff --git a/.github/workflows/ci-pytorch-tests.yml b/.github/workflows/ci-pytorch-tests.yml index a0cef820380e7..970cfa0ff5de8 100644 --- a/.github/workflows/ci-pytorch-tests.yml +++ b/.github/workflows/ci-pytorch-tests.yml @@ -124,16 +124,6 @@ jobs: - name: Switch PyTorch URL run: python -c "print('TORCH_URL=https://download.pytorch.org/whl/' + str('test/cpu/torch_test.html' if '${{matrix.release}}' == 'pre' else 'cpu/torch_stable.html'))" >> $GITHUB_ENV - - name: Install lite for PL - # Lite shall have pin version, so to keep development aligned we need to install lite from source not from pypi - # also installing from source not from on-the-fly created package tp prevent accidental interaction with cache - if: ${{ matrix.pkg-name != 'lightning' }} - env: - PACKAGE_NAME: "lite" - run: | - pip install -e . --upgrade --find-links ${TORCH_URL} - git checkout -- MANIFEST.in - - name: Install package & dependencies env: PACKAGE_NAME: ${{ matrix.pkg-name }} diff --git a/src/pytorch_lightning/__setup__.py b/src/pytorch_lightning/__setup__.py index 205aefe48cc00..c26c60c01f43b 100644 --- a/src/pytorch_lightning/__setup__.py +++ b/src/pytorch_lightning/__setup__.py @@ -52,6 +52,8 @@ def _adjust_manifest(**__: Any) -> None: lines += [ "recursive-exclude src *.md" + os.linesep, "recursive-exclude requirements *.txt" + os.linesep, + "recursive-include requirements/lite *.txt" + os.linesep, + "recursive-include src/lightning_lite *.md" + os.linesep, "recursive-include src/pytorch_lightning *.md" + os.linesep, "recursive-include requirements/pytorch *.txt" + os.linesep, "include src/pytorch_lightning/py.typed" + os.linesep, # marker file for PEP 561 @@ -63,10 +65,6 @@ def _adjust_manifest(**__: Any) -> None: def _setup_args(**__: Any) -> Dict[str, Any]: _path_setup_tools = os.path.join(_PROJECT_ROOT, ".actions", "setup_tools.py") _setup_tools = _load_py_module("setup_tools", _path_setup_tools) - if os.path.isdir(os.path.join(_SOURCE_ROOT, "lightning_lite")): - _setup_tools.set_actual_version_from_src( - os.path.join(_PATH_REQUIREMENTS, "base.txt"), _SOURCE_ROOT, "lightning-lite" - ) _about = _load_py_module("about", os.path.join(_PACKAGE_ROOT, "__about__.py")) _version = _load_py_module("version", os.path.join(_PACKAGE_ROOT, "__version__.py")) _long_description = _setup_tools.load_readme_description( From 7e5f48e89aed246933e45d87fdcf00597b2dd872 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mochol=C3=AD?= Date: Fri, 4 Nov 2022 12:59:57 +0100 Subject: [PATCH 25/30] Add back env now that source-lit is gone --- .github/workflows/docs-checks.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docs-checks.yml b/.github/workflows/docs-checks.yml index ac1fff2c0a57f..ba6c2797b2bf6 100644 --- a/.github/workflows/docs-checks.yml +++ b/.github/workflows/docs-checks.yml @@ -147,12 +147,12 @@ jobs: ${{ runner.os }}-docs-make-${{ matrix.pkg-name }}- - name: Install package & dependencies + env: + PACKAGE_NAME: ${{ matrix.pkg-name }} run: | sudo apt-get update sudo apt-get install -y cmake pandoc texlive-latex-extra dvipng texlive-pictures pip --version - # TODO: lit should be renamed to lightning - PACKAGE_NAME=$(python -c "print('lightning' if '${{ matrix.pkg-name }}' == 'lit' else '${{ matrix.pkg-name }}')") \ pip install -e . -U \ -r requirements/${{ matrix.pkg-name }}/docs.txt \ -f https://download.pytorch.org/whl/cpu/torch_stable.html \ From 1aee68a7739b9bf096b2c573851558965b473699 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mochol=C3=AD?= Date: Fri, 4 Nov 2022 13:44:12 +0100 Subject: [PATCH 26/30] Remove download artifact --- .github/workflows/docs-checks.yml | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/.github/workflows/docs-checks.yml b/.github/workflows/docs-checks.yml index 7cead46fea5d9..859220f8def90 100644 --- a/.github/workflows/docs-checks.yml +++ b/.github/workflows/docs-checks.yml @@ -37,11 +37,6 @@ jobs: with: submodules: true - - uses: actions/download-artifact@v3 - with: - name: ci-packages-${{ github.sha }} - path: pypi - - uses: actions/setup-python@v4 with: python-version: "3.9" @@ -113,11 +108,6 @@ jobs: with: submodules: true - - uses: actions/download-artifact@v3 - with: - name: ci-packages-${{ github.sha }} - path: pypi - - uses: actions/setup-python@v4 with: python-version: "3.9" @@ -149,10 +139,8 @@ jobs: sudo apt-get update sudo apt-get install -y cmake pandoc texlive-latex-extra dvipng texlive-pictures pip --version - pip install -e . -U \ - -r requirements/${{ matrix.pkg-name }}/docs.txt \ - -f https://download.pytorch.org/whl/cpu/torch_stable.html \ - -f pypi + pip install -e . -U -r requirements/${{ matrix.pkg-name }}/docs.txt \ + -f https://download.pytorch.org/whl/cpu/torch_stable.html -f pypi pip list shell: bash From f81ae5984bfeec00a2020c66d3b655f985d8709e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mochol=C3=AD?= Date: Fri, 4 Nov 2022 15:57:19 +0100 Subject: [PATCH 27/30] checkgroup --- .github/checkgroup.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/checkgroup.yml b/.github/checkgroup.yml index 86d4dc9a0d07d..fce40e1c23e2d 100644 --- a/.github/checkgroup.yml +++ b/.github/checkgroup.yml @@ -358,21 +358,21 @@ subprojects: - "install-pkg (ubuntu-22.04, lite, 3.10)" - "install-pkg (ubuntu-22.04, pytorch, 3.7)" - "install-pkg (ubuntu-22.04, pytorch, 3.10)" - - "install-pkg (ubuntu-22.04, 3.7)" - - "install-pkg (ubuntu-22.04, 3.10)" + - "install-pkg (ubuntu-22.04, lightning, 3.7)" + - "install-pkg (ubuntu-22.04, lightning, 3.10)" - "install-pkg (macOS-12, app, 3.7)" - "install-pkg (macOS-12, app, 3.10)" - "install-pkg (macOS-12, lite, 3.7)" - "install-pkg (macOS-12, lite, 3.10)" - "install-pkg (macOS-12, pytorch, 3.7)" - "install-pkg (macOS-12, pytorch, 3.10)" - - "install-pkg (macOS-12, 3.7)" - - "install-pkg (macOS-12, 3.10)" + - "install-pkg (macOS-12, lightning, 3.7)" + - "install-pkg (macOS-12, lightning, 3.10)" - "install-pkg (windows-2022, app, 3.7)" - "install-pkg (windows-2022, app, 3.10)" - "install-pkg (windows-2022, lite, 3.7)" - "install-pkg (windows-2022, lite, 3.10)" - "install-pkg (windows-2022, pytorch, 3.7)" - "install-pkg (windows-2022, pytorch, 3.10)" - - "install-pkg (windows-2022, 3.7)" - - "install-pkg (windows-2022, 3.10)" + - "install-pkg (windows-2022, lightning, 3.7)" + - "install-pkg (windows-2022, lightning, 3.10)" From ac9dbb9265cab5db58f3dc01ae508d600de390eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mochol=C3=AD?= Date: Fri, 4 Nov 2022 17:02:46 +0100 Subject: [PATCH 28/30] TODOs suggested by Jirka --- src/pytorch_lightning/__setup__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pytorch_lightning/__setup__.py b/src/pytorch_lightning/__setup__.py index c26c60c01f43b..442bda630b884 100644 --- a/src/pytorch_lightning/__setup__.py +++ b/src/pytorch_lightning/__setup__.py @@ -84,8 +84,8 @@ def _setup_args(**__: Any) -> Dict[str, Any]: include=[ "pytorch_lightning", "pytorch_lightning.*", - "lightning_lite", # TODO: remove after the first standalone Lite release - "lightning_lite.*", # TODO: remove after the first standalone Lite release + "lightning_lite", + "lightning_lite.*", ], ), package_dir={"": "src"}, @@ -96,6 +96,8 @@ def _setup_args(**__: Any) -> Dict[str, Any]: keywords=["deep learning", "pytorch", "AI"], python_requires=">=3.7", setup_requires=[], + # TODO: aggregate pytorch and lite requirements as we include its source code directly in this package. + # this is not a problem yet because lite's base requirements are all included in pytorch's base requirements install_requires=_setup_tools.load_requirements( _PATH_REQUIREMENTS, unfreeze="" if _FREEZE_REQUIREMENTS else "all" ), From 8340b85991bb6927d851d86861b7efe2c845377b Mon Sep 17 00:00:00 2001 From: Jirka Borovec Date: Fri, 4 Nov 2022 17:41:53 +0100 Subject: [PATCH 29/30] _ --- src/lightning_app/testing/testing.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lightning_app/testing/testing.py b/src/lightning_app/testing/testing.py index 6bf17707cf512..95d46c7f6d5a7 100644 --- a/src/lightning_app/testing/testing.py +++ b/src/lightning_app/testing/testing.py @@ -137,12 +137,12 @@ def application_testing( from click.testing import CliRunner - patch1 = mock.patch("lightning_app.LightningApp", lightning_app_cls) + _patch1 = mock.patch("lightning_app.LightningApp", lightning_app_cls) # we need to patch both only with the mirror package - patch2 = ( + _patch2 = ( mock.patch("lightning.LightningApp", lightning_app_cls) if "lightning.app" in sys.modules else nullcontext() ) - with patch1, patch2: + with _patch1, _patch2: original = sys.argv sys.argv = command_line runner = CliRunner() From a5fcaa2a04c2f67bc1984a66fd9b12dd2117af24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mochol=C3=AD?= Date: Fri, 4 Nov 2022 17:46:41 +0100 Subject: [PATCH 30/30] Revert "_". These are local variables, do not need protected This reverts commit 8340b85991bb6927d851d86861b7efe2c845377b. --- src/lightning_app/testing/testing.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lightning_app/testing/testing.py b/src/lightning_app/testing/testing.py index 95d46c7f6d5a7..6bf17707cf512 100644 --- a/src/lightning_app/testing/testing.py +++ b/src/lightning_app/testing/testing.py @@ -137,12 +137,12 @@ def application_testing( from click.testing import CliRunner - _patch1 = mock.patch("lightning_app.LightningApp", lightning_app_cls) + patch1 = mock.patch("lightning_app.LightningApp", lightning_app_cls) # we need to patch both only with the mirror package - _patch2 = ( + patch2 = ( mock.patch("lightning.LightningApp", lightning_app_cls) if "lightning.app" in sys.modules else nullcontext() ) - with _patch1, _patch2: + with patch1, patch2: original = sys.argv sys.argv = command_line runner = CliRunner()