From c119c8c018a29c3e8b0406bd161dd94e13f48a5b Mon Sep 17 00:00:00 2001 From: Jirka Date: Wed, 12 Oct 2022 17:54:22 +0200 Subject: [PATCH 001/104] placeholder --- .actions/setup_tools.py | 4 ++++ setup.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.actions/setup_tools.py b/.actions/setup_tools.py index 33d587aa93c2c..7ab2ecb926c3b 100644 --- a/.actions/setup_tools.py +++ b/.actions/setup_tools.py @@ -403,6 +403,10 @@ def prune_duplicate_lines(body): return body_ +def create_mirror_package(src_folder: str, pkg_name: str = "pytorch_lightning", lit_name: str = "pytorch"): + # TODO + + def create_meta_package(src_folder: str, pkg_name: str = "pytorch_lightning", lit_name: str = "pytorch"): """Parse the real python package and for each module create a mirroe version with repalcing all function and class implementations by cross-imports to the true package. diff --git a/setup.py b/setup.py index d558a24e0bdac..ae14e3b843579 100755 --- a/setup.py +++ b/setup.py @@ -104,7 +104,7 @@ def _load_py_module(name: str, location: str) -> ModuleType: for lit_name, pkg_name in _PACKAGE_MAPPING.items(): # fixme: if we run creation of meta pkg against stable we shall pull the source - _SETUP_TOOLS.create_meta_package(os.path.join(_PATH_ROOT, "src"), pkg_name, lit_name) + _SETUP_TOOLS.create_mirror_package(os.path.join(_PATH_ROOT, "src"), pkg_name, lit_name) _SETUP_MODULE = _load_py_module(name="pkg_setup", location=_PATH_SETUP) _SETUP_MODULE._adjust_manifest(pkg_name=_REAL_PKG_NAME) From 1d178edeaf126b1cc570bd8d1f467b182ee7c9cd Mon Sep 17 00:00:00 2001 From: Jirka Date: Thu, 13 Oct 2022 12:00:40 +0200 Subject: [PATCH 002/104] mirror + prune --- .actions/setup_tools.py | 293 ++-------------------------------------- 1 file changed, 12 insertions(+), 281 deletions(-) diff --git a/.actions/setup_tools.py b/.actions/setup_tools.py index 7ab2ecb926c3b..d0cde0d57883e 100644 --- a/.actions/setup_tools.py +++ b/.actions/setup_tools.py @@ -166,221 +166,6 @@ def load_readme_description(path_dir: str, homepage: str, version: str) -> str: return text -def replace_block_with_imports(lines: List[str], import_path: str, kword: str = "class") -> List[str]: - """Parse a file and replace implementtaions bodies of function or class. - - >>> py_file = os.path.join(_PROJECT_ROOT, "src", "pytorch_lightning", "loggers", "logger.py") - >>> import_path = ".".join(["pytorch_lightning", "loggers", "logger"]) - >>> with open(py_file, encoding="utf-8") as fp: - ... lines = [ln.rstrip() for ln in fp.readlines()] - >>> lines = replace_block_with_imports(lines, import_path, "class") - >>> lines = replace_block_with_imports(lines, import_path, "def") - """ - body, tracking, skip_offset = [], False, 0 - for i, ln in enumerate(lines): - # support for defining a class with this condition - conditional_class_definitions = ("if TYPE_CHECKING", "if typing.TYPE_CHECKING", "if torch.", "if _TORCH_") - if ( - any(ln.startswith(pattern) for pattern in conditional_class_definitions) - # avoid bug in CI for the <1.7 meta code - and "pytorch_lightning.utilities.meta" not in import_path - ): - # dedent the next line - lines[i + 1] = lines[i + 1].lstrip() - continue - - offset = len(ln) - len(ln.lstrip()) - # in case of mating the class args are multi-line - if tracking and ln and offset <= skip_offset and not any(ln.lstrip().startswith(c) for c in ")]"): - tracking = False - if ln.lstrip().startswith(f"{kword} ") and not tracking: - name = ln.replace(f"{kword} ", "").strip() - idxs = [name.index(c) for c in ":(" if c in name] - name = name[: min(idxs)] - # skip private, TODO: consider skip even protected - if not name.startswith("__"): - body.append(f"{' ' * offset}from {import_path} import {name} # noqa: F401") - tracking, skip_offset = True, offset - continue - if not tracking: - body.append(ln) - return body - - -def replace_vars_with_imports(lines: List[str], import_path: str) -> List[str]: - """Parse a file and replace variable filling with import. - - >>> py_file = os.path.join(_PROJECT_ROOT, "src", "pytorch_lightning", "utilities", "imports.py") - >>> import_path = ".".join(["pytorch_lightning", "utilities", "imports"]) - >>> with open(py_file, encoding="utf-8") as fp: - ... lines = [ln.rstrip() for ln in fp.readlines()] - >>> lines = replace_vars_with_imports(lines, import_path) - """ - copied = [] - body, tracking, skip_offset = [], False, 0 - for ln in lines: - offset = len(ln) - len(ln.lstrip()) - # in case of mating the class args are multi-line - if tracking and ln and offset <= skip_offset and not any(ln.lstrip().startswith(c) for c in ")]}"): - tracking = False - var = re.match(r"^([\w_\d]+)[: [\w\., \[\]]*]? = ", ln.lstrip()) - if var: - name = var.groups()[0] - # skip private or apply white-list for allowed vars - if name not in copied and (not name.startswith("__") or name in ("__all__",)): - body.append(f"{' ' * offset}from {import_path} import {name} # noqa: F401") - copied.append(name) - tracking, skip_offset = True, offset - continue - if not tracking: - body.append(ln) - return body - - -def prune_imports_callables(lines: List[str]) -> List[str]: - """Prune imports and calling functions from a file, even multi-line. - - >>> py_file = os.path.join(_PROJECT_ROOT, "src", "pytorch_lightning", "utilities", "cli.py") - >>> import_path = ".".join(["pytorch_lightning", "utilities", "cli"]) - >>> with open(py_file, encoding="utf-8") as fp: - ... lines = [ln.rstrip() for ln in fp.readlines()] - >>> lines = prune_imports_callables(lines) - """ - body, tracking, skip_offset = [], False, 0 - for ln in lines: - if ln.lstrip().startswith("import "): - continue - offset = len(ln) - len(ln.lstrip()) - # in case of mating the class args are multi-line - if tracking and ln and offset <= skip_offset and not any(ln.lstrip().startswith(c) for c in ")]}"): - tracking = False - # catching callable - call = re.match(r"^[\w_\d\.]+\(", ln.lstrip()) - if (ln.lstrip().startswith("from ") and " import " in ln) or call: - tracking, skip_offset = True, offset - continue - if not tracking: - body.append(ln) - return body - - -def prune_func_calls(lines: List[str]) -> List[str]: - """Prune calling functions from a file, even multi-line. - - >>> py_file = os.path.join(_PROJECT_ROOT, "src", "pytorch_lightning", "loggers", "__init__.py") - >>> import_path = ".".join(["pytorch_lightning", "loggers"]) - >>> with open(py_file, encoding="utf-8") as fp: - ... lines = [ln.rstrip() for ln in fp.readlines()] - >>> lines = prune_func_calls(lines) - """ - body, tracking, score = [], False, 0 - for ln in lines: - # catching callable - calling = re.match(r"^@?[\w_\d\.]+ *\(", ln.lstrip()) - if calling and " import " not in ln: - tracking = True - score = 0 - if tracking: - score += ln.count("(") - ln.count(")") - if score == 0: - tracking = False - else: - body.append(ln) - return body - - -def prune_empty_statements(lines: List[str]) -> List[str]: - """Prune emprty if/else and try/except. - - >>> py_file = os.path.join(_PROJECT_ROOT, "src", "pytorch_lightning", "utilities", "cli.py") - >>> import_path = ".".join(["pytorch_lightning", "utilities", "cli"]) - >>> with open(py_file, encoding="utf-8") as fp: - ... lines = [ln.rstrip() for ln in fp.readlines()] - >>> lines = prune_imports_callables(lines) - >>> lines = prune_empty_statements(lines) - """ - kwords_pairs = ("with", "if ", "elif ", "else", "try", "except") - body, tracking, skip_offset, last_count = [], False, 0, 0 - # todo: consider some more complex logic as for example only some leaves of if/else tree are empty - for i, ln in enumerate(lines): - offset = len(ln) - len(ln.lstrip()) - # skipp all decorators - if ln.lstrip().startswith("@"): - # consider also multi-line decorators - if "(" in ln and ")" not in ln: - tracking, skip_offset = True, offset - continue - # in case of mating the class args are multi-line - if tracking and ln and offset <= skip_offset and not any(ln.lstrip().startswith(c) for c in ")]}"): - tracking = False - starts = [k for k in kwords_pairs if ln.lstrip().startswith(k)] - if starts: - start, count = starts[0], -1 - # look forward if this statement has a body - for ln_ in lines[i:]: - offset_ = len(ln_) - len(ln_.lstrip()) - if count == -1 and ln_.rstrip().endswith(":"): - count = 0 - elif ln_ and offset_ <= offset: - break - # skipp all til end of statement - elif ln_.lstrip(): - # count non-zero body lines - count += 1 - # cache the last key body as the supplement canot be without - if start in ("if", "elif", "try"): - last_count = count - if count <= 0 or (start in ("else", "except") and last_count <= 0): - tracking, skip_offset = True, offset - if not tracking: - body.append(ln) - return body - - -def prune_comments_docstrings(lines: List[str]) -> List[str]: - """Prune all doctsrings with triple " notation. - - >>> py_file = os.path.join(_PROJECT_ROOT, "src", "pytorch_lightning", "loggers", "csv_logs.py") - >>> import_path = ".".join(["pytorch_lightning", "loggers", "csv_logs"]) - >>> with open(py_file, encoding="utf-8") as fp: - ... lines = [ln.rstrip() for ln in fp.readlines()] - >>> lines = prune_comments_docstrings(lines) - """ - body, tracking = [], False - for ln in lines: - if "#" in ln and "noqa:" not in ln: - ln = ln[: ln.index("#")] - if not tracking and any(ln.lstrip().startswith(s) for s in ['"""', 'r"""']): - # oneliners skip directly - if len(ln.strip()) >= 6 and ln.rstrip().endswith('"""'): - continue - tracking = True - elif ln.rstrip().endswith('"""'): - tracking = False - continue - if not tracking: - body.append(ln.rstrip()) - return body - - -def wrap_try_except(body: List[str], pkg: str, ver: str) -> List[str]: - """Wrap the file with try/except for better traceability of import misalignment.""" - not_empty = sum(1 for ln in body if ln) - if not_empty == 0: - return body - body = ["try:"] + [f" {ln}" if ln else "" for ln in body] - body += [ - "", - "except ImportError as err:", - "", - " from os import linesep", - f" from {pkg} import __version__", - f" msg = f'Your `lightning` package was built for `{pkg}=={ver}`," + " but you are running {__version__}'", - " raise type(err)(str(err) + linesep + msg)", - ] - return body - - def parse_version_from_file(pkg_root: str) -> str: """Loading the package version from file.""" file_ver = os.path.join(pkg_root, "__version__.py") @@ -394,78 +179,24 @@ def parse_version_from_file(pkg_root: str) -> str: return ver -def prune_duplicate_lines(body): - body_ = [] - # drop duplicated lines - for ln in body: - if ln.lstrip() not in body_ or ln.lstrip() in (")", ""): - body_.append(ln) - return body_ - - def create_mirror_package(src_folder: str, pkg_name: str = "pytorch_lightning", lit_name: str = "pytorch"): - # TODO - - -def create_meta_package(src_folder: str, pkg_name: str = "pytorch_lightning", lit_name: str = "pytorch"): - """Parse the real python package and for each module create a mirroe version with repalcing all function and - class implementations by cross-imports to the true package. - - As validation run in termnal: `flake8 src/lightning/ --ignore E402,F401,E501` - - >>> create_meta_package(os.path.join(_PROJECT_ROOT, "src")) - """ + """Recursively replace imports in given folder.""" package_dir = os.path.join(src_folder, pkg_name) - pkg_ver = parse_version_from_file(package_dir) - # shutil.rmtree(os.path.join(src_folder, "lightning", lit_name)) - py_files = glob.glob(os.path.join(src_folder, pkg_name, "**", "*.py"), recursive=True) + py_files = glob.glob(os.path.join(package_dir, "**", "*.py"), recursive=True) for py_file in py_files: local_path = py_file.replace(package_dir + os.path.sep, "") - fname = os.path.basename(py_file) - if "-" in local_path: - continue - with open(py_file, encoding="utf-8") as fp: - lines = [ln.rstrip() for ln in fp.readlines()] - import_path = pkg_name + "." + local_path.replace(".py", "").replace(os.path.sep, ".") - import_path = import_path.replace(".__init__", "") - - if fname in ("__about__.py", "__version__.py"): - body = lines - else: - if fname.startswith("_") and fname not in ("__init__.py", "__main__.py"): - logging.warning(f"unsupported file: {local_path}") + with open(py_file, encoding="utf-8") as fo: + py = fo.readlines() + for i, ln in enumerate(py): + ln_ = ln.lstrip() + if ln_.startswith("#"): + continue + if not ln_.startswith("import ") and not re.search(r"from [\w_\.\d]+ import ", ln_): continue - # ToDO: perform some smarter parsing - preserve Constants, lambdas, etc - body = prune_comments_docstrings([ln.rstrip() for ln in lines]) - if fname not in ("__init__.py", "__main__.py"): - body = prune_imports_callables(body) - for key_word in ("class", "def", "async def"): - body = replace_block_with_imports(body, import_path, key_word) - # TODO: fix reimporting which is artefact after replacing var assignment with import; - # after fixing , update CI by remove F811 from CI/check pkg - body = replace_vars_with_imports(body, import_path) - if fname not in ("__main__.py",): - body = prune_func_calls(body) - body_len = -1 - # in case of several in-depth statements - while body_len != len(body): - body_len = len(body) - body = prune_duplicate_lines(body) - body = prune_empty_statements(body) - # add try/catch wrapper for whole body, - # so when import fails it tells you what is the package version this meta package was generated for... - body = wrap_try_except(body, pkg_name, pkg_ver) - - # todo: apply pre-commit formatting - # clean to many empty lines - body = [ln for ln, _group in groupby(body)] - # drop duplicated lines - body = prune_duplicate_lines(body) - # compose the target file name + py[i] = ln.replace(pkg_name, lit_name) new_file = os.path.join(src_folder, "lightning", lit_name, local_path) - os.makedirs(os.path.dirname(new_file), exist_ok=True) - with open(new_file, "w", encoding="utf-8") as fp: - fp.writelines([ln + os.linesep for ln in body]) + with open(new_file, "w", encoding="utf-8") as fo: + fo.writelines(py) def set_version_today(fpath: str) -> None: From 19a69176918d0fed40cd1e4f65053b18c88619ea Mon Sep 17 00:00:00 2001 From: Jirka Date: Thu, 13 Oct 2022 12:02:32 +0200 Subject: [PATCH 003/104] makedir --- .actions/setup_tools.py | 1 + 1 file changed, 1 insertion(+) diff --git a/.actions/setup_tools.py b/.actions/setup_tools.py index d0cde0d57883e..d0c6900344315 100644 --- a/.actions/setup_tools.py +++ b/.actions/setup_tools.py @@ -195,6 +195,7 @@ def create_mirror_package(src_folder: str, pkg_name: str = "pytorch_lightning", continue py[i] = ln.replace(pkg_name, lit_name) new_file = os.path.join(src_folder, "lightning", lit_name, local_path) + os.makedirs(os.path.dirname(new_file), exist_ok=True) with open(new_file, "w", encoding="utf-8") as fo: fo.writelines(py) From a73ce2fdb9cb08f03ec4afa399b537cc6427dfac Mon Sep 17 00:00:00 2001 From: Jirka Date: Thu, 13 Oct 2022 12:09:11 +0200 Subject: [PATCH 004/104] setup --- .actions/setup_tools.py | 8 +++++++- src/lightning/__setup__.py | 25 ++++++++++--------------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/.actions/setup_tools.py b/.actions/setup_tools.py index d0c6900344315..ec792f6944ef2 100644 --- a/.actions/setup_tools.py +++ b/.actions/setup_tools.py @@ -179,7 +179,7 @@ def parse_version_from_file(pkg_root: str) -> str: return ver -def create_mirror_package(src_folder: str, pkg_name: str = "pytorch_lightning", lit_name: str = "pytorch"): +def copy_adjusted_modules(src_folder: str, pkg_name: str, lit_name: str) -> None: """Recursively replace imports in given folder.""" package_dir = os.path.join(src_folder, pkg_name) py_files = glob.glob(os.path.join(package_dir, "**", "*.py"), recursive=True) @@ -200,6 +200,12 @@ def create_mirror_package(src_folder: str, pkg_name: str = "pytorch_lightning", fo.writelines(py) +def create_mirror_package(src_folder: str, pkg_name: str = "pytorch_lightning", lit_name: str = "pytorch") -> None: + """Recursively replace imports in given folder.""" + copy_adjusted_modules(src_folder, pkg_name, lit_name) + # TODO: copy also UI and other required files + + def set_version_today(fpath: str) -> None: """Replace the template date with today.""" with open(fpath) as fp: diff --git a/src/lightning/__setup__.py b/src/lightning/__setup__.py index cc3a4f8d11e78..c16cb842a9038 100644 --- a/src/lightning/__setup__.py +++ b/src/lightning/__setup__.py @@ -30,21 +30,16 @@ def _adjust_manifest(**kwargs: Any) -> None: assert os.path.isfile(manifest_path) with open(manifest_path) as fp: lines = [ln.rstrip() for ln in fp.readlines()] - if kwargs["pkg_name"] == "lightning": - lines += [ - "recursive-include src/lightning *.md", - "include requirements/base.txt", - # fixme: this is strange, this shall work with setup find package - include - "prune src/lightning_app", - "prune src/pytorch_lightning", - ] - else: - lines += [ - "recursive-include src *.md", - "recursive-include requirements *.txt", - "recursive-include src/lightning_app/ui *", - "recursive-include src/lightning_app/cli/*-template *", # Add templates as build-in - ] + lines += [ + "recursive-include src/lightning *.md", + "recursive-include requirements *.txt", + "recursive-include src/lightning/ui *", + "recursive-include src/lightning/cli/*-template *", # Add templates as build-in + # fixme: this is strange, this shall work with setup find package - include + "prune src/lightning_app", + "prune src/lightning_lite", + "prune src/pytorch_lightning", + ] with open(manifest_path, "w") as fp: fp.writelines([ln + os.linesep for ln in lines]) From fc01887adf840deca97ef1627d69df1039715612 Mon Sep 17 00:00:00 2001 From: Jirka Date: Thu, 13 Oct 2022 13:23:06 +0200 Subject: [PATCH 005/104] ci --- .github/workflows/ci-pkg-install.yml | 3 +-- setup.py | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci-pkg-install.yml b/.github/workflows/ci-pkg-install.yml index 9da9792101317..9a62ad69afdfd 100644 --- a/.github/workflows/ci-pkg-install.yml +++ b/.github/workflows/ci-pkg-install.yml @@ -76,7 +76,6 @@ jobs: # max-parallel: 1 matrix: os: [ubuntu-20.04, ubuntu-22.04, macOS-11, macOS-12, windows-2022] - pkg: ["", "lightning"] python-version: [3.8] # , 3.9 steps: @@ -95,7 +94,7 @@ jobs: - uses: ./.github/actions/pkg-check with: - pkg-name: ${{ matrix.pkg }} + pkg-name: "lightning" - uses: ./.github/actions/pkg-install with: diff --git a/setup.py b/setup.py index ae14e3b843579..8babf070d7442 100755 --- a/setup.py +++ b/setup.py @@ -25,12 +25,13 @@ In case you want to install just one package you need to export env. variable before calling `pip` - for `pytorch-lightning` use `export PACKAGE_NAME=pytorch ; pip install .` + - for `lightning-lite` use `export PACKAGE_NAME=lite ; pip install .` - for `lightning-app` use `export PACKAGE_NAME=app ; pip install .` 3. Building packages as sdist or binary wheel and installing or publish to PyPI afterwords you use command `python setup.py sdist` or `python setup.py bdist_wheel` accordingly. In case you want to build just a particular package you would use exporting env. variable as above: - `export PACKAGE_NAME=pytorch|app ; python setup.py sdist bdist_wheel` + `export PACKAGE_NAME=pytorch|app|lite ; python setup.py sdist bdist_wheel` 4. Automated releasing with GitHub action is natural extension of 3) is composed of three consecutive steps: a) determine which packages shall be released based on version increment in `__version__.py` and eventually From df8794a7e3ba0859f6ad12e3006b3fae59a56ed3 Mon Sep 17 00:00:00 2001 From: Jirka Date: Thu, 13 Oct 2022 13:24:24 +0200 Subject: [PATCH 006/104] ci --- .github/actions/pkg-check/action.yml | 1 + .github/workflows/ci-pkg-install.yml | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/actions/pkg-check/action.yml b/.github/actions/pkg-check/action.yml index bfd1602e69af3..fb559d86ce9c3 100644 --- a/.github/actions/pkg-check/action.yml +++ b/.github/actions/pkg-check/action.yml @@ -5,6 +5,7 @@ inputs: pkg-name: description: package name inside lightning.* required: true + default: "lightning" nb-dirs: description: nb of packages in the wrap/distribution required: false diff --git a/.github/workflows/ci-pkg-install.yml b/.github/workflows/ci-pkg-install.yml index 9a62ad69afdfd..e69678fd14ad0 100644 --- a/.github/workflows/ci-pkg-install.yml +++ b/.github/workflows/ci-pkg-install.yml @@ -93,12 +93,9 @@ jobs: - run: ls -lh pypi/ - uses: ./.github/actions/pkg-check - with: - pkg-name: "lightning" - uses: ./.github/actions/pkg-install with: - pkg-name: "lightning" pip-flags: "-U --pre --find-links ../pypi/" - name: Run CLI From ccbe4fd74277195cd4561692f82be4390f4b9449 Mon Sep 17 00:00:00 2001 From: Jirka Date: Thu, 13 Oct 2022 13:31:31 +0200 Subject: [PATCH 007/104] name --- .actions/setup_tools.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.actions/setup_tools.py b/.actions/setup_tools.py index ec792f6944ef2..edb0955d23a19 100644 --- a/.actions/setup_tools.py +++ b/.actions/setup_tools.py @@ -193,7 +193,7 @@ def copy_adjusted_modules(src_folder: str, pkg_name: str, lit_name: str) -> None continue if not ln_.startswith("import ") and not re.search(r"from [\w_\.\d]+ import ", ln_): continue - py[i] = ln.replace(pkg_name, lit_name) + py[i] = ln.replace(pkg_name, f'lightning.{lit_name}') new_file = os.path.join(src_folder, "lightning", lit_name, local_path) os.makedirs(os.path.dirname(new_file), exist_ok=True) with open(new_file, "w", encoding="utf-8") as fo: From 11744df3c3f0c9180506c94714e2740b7bf5af0d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 13 Oct 2022 11:36:03 +0000 Subject: [PATCH 008/104] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .actions/setup_tools.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.actions/setup_tools.py b/.actions/setup_tools.py index edb0955d23a19..189203d8cf64a 100644 --- a/.actions/setup_tools.py +++ b/.actions/setup_tools.py @@ -193,7 +193,7 @@ def copy_adjusted_modules(src_folder: str, pkg_name: str, lit_name: str) -> None continue if not ln_.startswith("import ") and not re.search(r"from [\w_\.\d]+ import ", ln_): continue - py[i] = ln.replace(pkg_name, f'lightning.{lit_name}') + py[i] = ln.replace(pkg_name, f"lightning.{lit_name}") new_file = os.path.join(src_folder, "lightning", lit_name, local_path) os.makedirs(os.path.dirname(new_file), exist_ok=True) with open(new_file, "w", encoding="utf-8") as fo: From c6d4d912016034bdd7302081ac0c8bf806b09dfd Mon Sep 17 00:00:00 2001 From: Jirka Date: Thu, 13 Oct 2022 13:40:26 +0200 Subject: [PATCH 009/104] ci clean --- .github/workflows/ci-pkg-install.yml | 107 +-------------------------- requirements/base.txt | 2 - 2 files changed, 3 insertions(+), 106 deletions(-) diff --git a/.github/workflows/ci-pkg-install.yml b/.github/workflows/ci-pkg-install.yml index e69678fd14ad0..ff655f1297176 100644 --- a/.github/workflows/ci-pkg-install.yml +++ b/.github/workflows/ci-pkg-install.yml @@ -17,24 +17,14 @@ defaults: jobs: - init-temp: - 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 - - install-standalone: - needs: init-temp + install-pkg: runs-on: ${{ matrix.os }} strategy: fail-fast: true max-parallel: 1 matrix: os: [ubuntu-20.04, ubuntu-22.04, macOS-11, macOS-12, windows-2022] - pkg: ["app", "lite", "pytorch"] + pkg: ["app", "lite", "pytorch", "lightning"] python-version: [3.8] # , 3.9 steps: @@ -49,105 +39,14 @@ jobs: grep 'pytest>' ../requirements/pytorch/test.txt | xargs -0 pip install python -m pytest setup_tools.py -v --doctest-modules --color=yes - - uses: actions/download-artifact@v3 - with: - name: ci-packages-${{ github.sha }} - path: pypi - - run: ls -lh pypi/ - - run: python -c "print('NB_DIRS=' + str(2 if '${{ matrix.pkg }}' == 'pytorch' else 1))" >> $GITHUB_ENV - uses: ./.github/actions/pkg-check with: pkg-name: ${{ matrix.pkg }} nb-dirs: ${{ env.NB_DIRS }} - - uses: actions/upload-artifact@v3 - with: - name: ci-packages-${{ github.sha }} - path: pypi - - - uses: ./.github/actions/pkg-install - - install-meta-src: - needs: install-standalone - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - # max-parallel: 1 - matrix: - os: [ubuntu-20.04, ubuntu-22.04, macOS-11, macOS-12, windows-2022] - python-version: [3.8] # , 3.9 - - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - - run: mkdir -p pypi - - uses: actions/download-artifact@v3 - if: ${{ matrix.pkg != '' }} - with: - name: ci-packages-${{ github.sha }} - path: pypi - - run: ls -lh pypi/ - - - uses: ./.github/actions/pkg-check - - - uses: ./.github/actions/pkg-install - with: - pip-flags: "-U --pre --find-links ../pypi/" - - - name: Run CLI - run: python -m lightning --version - - install-meta-pypi: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - # max-parallel: 1 - matrix: - os: [ubuntu-20.04, ubuntu-22.04, macOS-11, macOS-12, windows-2022] - python-version: [3.8] # , 3.9 - - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - - name: Dowload package - # todo: download also lite after it is fist published - run: | - pip install -q -r .actions/requirements.txt - for pkg in 'app' 'pytorch' ; do - python .actions/assistant.py download-package "$pkg" --folder pypi - done - ls -lh pypi/ - - - name: Unzip packages - working-directory: pypi - run: for file in `ls *.gz`; do tar -xzf $file; done - - name: Show upacked pkgs - if: runner.os == 'linux' - run: | - sudo apt install -y tree - tree pypi/ -L 3 - - - name: Miror source - run: | - pip install -q -r .actions/requirements.txt - python .actions/assistant.py mirror-pkg2source pypi src - ls -R src/ - - - uses: ./.github/actions/pkg-check - with: - pkg-name: "lightning" - - uses: ./.github/actions/pkg-install - with: - pkg-name: "lightning" - pip-flags: "-U --pre --find-links ../pypi/" - name: Run CLI + if: matrix.pkg == 'lightning' run: python -m lightning --version diff --git a/requirements/base.txt b/requirements/base.txt index fea4ee10f4ce7..e69de29bb2d1d 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -1,2 +0,0 @@ -pytorch_lightning>=1.6.5 -lightning_app>=0.5.2 From 36e9c04e69e22de94450d8716216752ed353cb00 Mon Sep 17 00:00:00 2001 From: Jirka Date: Thu, 13 Oct 2022 13:44:24 +0200 Subject: [PATCH 010/104] empty --- .github/workflows/ci-pkg-install.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-pkg-install.yml b/.github/workflows/ci-pkg-install.yml index ff655f1297176..cf6b41c3a6d4e 100644 --- a/.github/workflows/ci-pkg-install.yml +++ b/.github/workflows/ci-pkg-install.yml @@ -24,7 +24,7 @@ jobs: max-parallel: 1 matrix: os: [ubuntu-20.04, ubuntu-22.04, macOS-11, macOS-12, windows-2022] - pkg: ["app", "lite", "pytorch", "lightning"] + pkg: ["app", "lite", "pytorch", ""] python-version: [3.8] # , 3.9 steps: @@ -48,5 +48,5 @@ jobs: - uses: ./.github/actions/pkg-install - name: Run CLI - if: matrix.pkg == 'lightning' + if: matrix.pkg == '' run: python -m lightning --version From 972b509b05bef8bb952b6b68e112d37125aa3b13 Mon Sep 17 00:00:00 2001 From: Jirka Date: Thu, 13 Oct 2022 13:45:06 +0200 Subject: [PATCH 011/104] py --- .github/workflows/ci-pkg-install.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-pkg-install.yml b/.github/workflows/ci-pkg-install.yml index cf6b41c3a6d4e..d81cc1ad785be 100644 --- a/.github/workflows/ci-pkg-install.yml +++ b/.github/workflows/ci-pkg-install.yml @@ -25,7 +25,7 @@ jobs: matrix: os: [ubuntu-20.04, ubuntu-22.04, macOS-11, macOS-12, windows-2022] pkg: ["app", "lite", "pytorch", ""] - python-version: [3.8] # , 3.9 + python-version: [3.7 , 3.10] # steps: - uses: actions/checkout@v3 From 4acc2dffe14de546fbb28d5e2d7a104f9f5b9051 Mon Sep 17 00:00:00 2001 From: Jirka Date: Thu, 13 Oct 2022 13:45:42 +0200 Subject: [PATCH 012/104] parallel --- .github/workflows/ci-pkg-install.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci-pkg-install.yml b/.github/workflows/ci-pkg-install.yml index d81cc1ad785be..db2e3d62b55f2 100644 --- a/.github/workflows/ci-pkg-install.yml +++ b/.github/workflows/ci-pkg-install.yml @@ -20,8 +20,7 @@ jobs: install-pkg: runs-on: ${{ matrix.os }} strategy: - fail-fast: true - max-parallel: 1 + fail-fast: false matrix: os: [ubuntu-20.04, ubuntu-22.04, macOS-11, macOS-12, windows-2022] pkg: ["app", "lite", "pytorch", ""] From d4294b6dec862c5ed354ffeb9619df2b908682b6 Mon Sep 17 00:00:00 2001 From: Jirka Date: Thu, 13 Oct 2022 13:51:20 +0200 Subject: [PATCH 013/104] doctest --- .actions/setup_tools.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.actions/setup_tools.py b/.actions/setup_tools.py index 189203d8cf64a..74484961b7ae7 100644 --- a/.actions/setup_tools.py +++ b/.actions/setup_tools.py @@ -114,8 +114,8 @@ def load_requirements( """Loading requirements from a file. >>> path_req = os.path.join(_PROJECT_ROOT, "requirements") - >>> load_requirements(path_req, unfreeze="major") # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE - ['pytorch_lightning...', 'lightning_app...'] + >>> load_requirements(path_req, "docs.txt", unfreeze="major") # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE + ['sphinx>=4.0, <6.0 # strict', ...] """ with open(os.path.join(path_dir, file_name)) as file: lines = [ln.strip() for ln in file.readlines()] From b7a6469b3d120173d7e4fe7253fb4019a22565af Mon Sep 17 00:00:00 2001 From: Jirka Date: Thu, 13 Oct 2022 13:57:26 +0200 Subject: [PATCH 014/104] flake8 --- .github/actions/pkg-check/action.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/actions/pkg-check/action.yml b/.github/actions/pkg-check/action.yml index fb559d86ce9c3..d3842180f3703 100644 --- a/.github/actions/pkg-check/action.yml +++ b/.github/actions/pkg-check/action.yml @@ -22,10 +22,7 @@ runs: - name: Source check env: PACKAGE_NAME: ${{ inputs.pkg-name }} - run: | - python setup.py check --metadata --strict - # TODO: fix reimporting (F811) which is aftefact after rplacing var assigne with import in meta package - flake8 src/lightning/ --ignore E402,F401,E501,W391,E303,F811 + run: python setup.py check --metadata --strict shell: bash - name: Create package From 4fc4fc52d21a6b5399cd3b52f3a8c513836de2c6 Mon Sep 17 00:00:00 2001 From: Jirka Date: Thu, 13 Oct 2022 14:00:52 +0200 Subject: [PATCH 015/104] ci --- .github/actions/pkg-check/action.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/actions/pkg-check/action.yml b/.github/actions/pkg-check/action.yml index d3842180f3703..21709c92c5de5 100644 --- a/.github/actions/pkg-check/action.yml +++ b/.github/actions/pkg-check/action.yml @@ -38,10 +38,6 @@ runs: # python setup.py clean shell: bash - - name: copy/export pkg - run: cp dist/* pypi/ - shell: bash - - name: Unzip packages if: ${{ inputs.pkg-name != '' }} working-directory: dist From f03aa13844fa2526339a279124d904ed75507d65 Mon Sep 17 00:00:00 2001 From: Jirka Date: Thu, 13 Oct 2022 14:02:24 +0200 Subject: [PATCH 016/104] typo --- .github/workflows/ci-pkg-install.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-pkg-install.yml b/.github/workflows/ci-pkg-install.yml index db2e3d62b55f2..69ecf882a3d6c 100644 --- a/.github/workflows/ci-pkg-install.yml +++ b/.github/workflows/ci-pkg-install.yml @@ -24,7 +24,7 @@ jobs: matrix: os: [ubuntu-20.04, ubuntu-22.04, macOS-11, macOS-12, windows-2022] pkg: ["app", "lite", "pytorch", ""] - python-version: [3.7 , 3.10] # + python-version: ["3.7" , "3.10"] # steps: - uses: actions/checkout@v3 From 31106383b86fd6d4dfc6927a53e234e1c6811717 Mon Sep 17 00:00:00 2001 From: Jirka Date: Thu, 13 Oct 2022 14:17:40 +0200 Subject: [PATCH 017/104] replace --- .actions/setup_tools.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.actions/setup_tools.py b/.actions/setup_tools.py index 74484961b7ae7..fb96d17301a8b 100644 --- a/.actions/setup_tools.py +++ b/.actions/setup_tools.py @@ -188,11 +188,6 @@ def copy_adjusted_modules(src_folder: str, pkg_name: str, lit_name: str) -> None with open(py_file, encoding="utf-8") as fo: py = fo.readlines() for i, ln in enumerate(py): - ln_ = ln.lstrip() - if ln_.startswith("#"): - continue - if not ln_.startswith("import ") and not re.search(r"from [\w_\.\d]+ import ", ln_): - continue py[i] = ln.replace(pkg_name, f"lightning.{lit_name}") new_file = os.path.join(src_folder, "lightning", lit_name, local_path) os.makedirs(os.path.dirname(new_file), exist_ok=True) From 3b4b535db5294c6af99ecf99415023b23d2efc2a Mon Sep 17 00:00:00 2001 From: Jirka Date: Thu, 13 Oct 2022 14:25:56 +0200 Subject: [PATCH 018/104] clean --- src/lightning/__setup__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lightning/__setup__.py b/src/lightning/__setup__.py index c16cb842a9038..378a2bfa644a6 100644 --- a/src/lightning/__setup__.py +++ b/src/lightning/__setup__.py @@ -50,7 +50,7 @@ def _setup_args(**kwargs: Any) -> Dict[str, Any]: _long_description = _SETUP_TOOLS.load_readme_description( _PROJECT_ROOT, homepage=_about.__homepage__, version=_version.version ) - _include_pkgs = ["lightning", "lightning.*"] if kwargs["pkg_name"] == "lightning" else ["*"] + _include_pkgs = ["lightning", "lightning.*"] # TODO: consider invaliding some additional arguments from packages, for example if include data or safe to zip From d3d838d18e3d1904452413c0e0e193201cb819ca Mon Sep 17 00:00:00 2001 From: Jirka Borovec Date: Thu, 13 Oct 2022 14:26:31 +0200 Subject: [PATCH 019/104] Apply suggestions from code review --- .github/workflows/ci-pkg-install.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-pkg-install.yml b/.github/workflows/ci-pkg-install.yml index 69ecf882a3d6c..6464b5fa2c08c 100644 --- a/.github/workflows/ci-pkg-install.yml +++ b/.github/workflows/ci-pkg-install.yml @@ -24,7 +24,7 @@ jobs: matrix: os: [ubuntu-20.04, ubuntu-22.04, macOS-11, macOS-12, windows-2022] pkg: ["app", "lite", "pytorch", ""] - python-version: ["3.7" , "3.10"] # + python-version: ["3.7" , "3.10"] steps: - uses: actions/checkout@v3 From 0a7e804aad56c71cee521d4a8a578ddb1ab4f9af Mon Sep 17 00:00:00 2001 From: Jirka Date: Thu, 13 Oct 2022 19:03:54 +0200 Subject: [PATCH 020/104] re.sub --- .actions/setup_tools.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.actions/setup_tools.py b/.actions/setup_tools.py index fb96d17301a8b..5e67e1a9f7ba4 100644 --- a/.actions/setup_tools.py +++ b/.actions/setup_tools.py @@ -188,7 +188,7 @@ def copy_adjusted_modules(src_folder: str, pkg_name: str, lit_name: str) -> None with open(py_file, encoding="utf-8") as fo: py = fo.readlines() for i, ln in enumerate(py): - py[i] = ln.replace(pkg_name, f"lightning.{lit_name}") + py[i] = re.sub(rf"(?!_){pkg_name}(?!_)", f"lightning.{lit_name}", ln) new_file = os.path.join(src_folder, "lightning", lit_name, local_path) os.makedirs(os.path.dirname(new_file), exist_ok=True) with open(new_file, "w", encoding="utf-8") as fo: From c18154496e9be40511366209018bb036f71d11a0 Mon Sep 17 00:00:00 2001 From: Jirka Date: Thu, 13 Oct 2022 19:18:16 +0200 Subject: [PATCH 021/104] fix UI path --- .actions/setup_tools.py | 12 +++--------- src/lightning/__setup__.py | 2 +- src/lightning_app/__setup__.py | 2 +- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/.actions/setup_tools.py b/.actions/setup_tools.py index 5e67e1a9f7ba4..5e6abccc15f44 100644 --- a/.actions/setup_tools.py +++ b/.actions/setup_tools.py @@ -179,7 +179,7 @@ def parse_version_from_file(pkg_root: str) -> str: return ver -def copy_adjusted_modules(src_folder: str, pkg_name: str, lit_name: str) -> None: +def create_mirror_package(src_folder: str, pkg_name: str = "pytorch_lightning", lit_name: str = "pytorch") -> None: """Recursively replace imports in given folder.""" package_dir = os.path.join(src_folder, pkg_name) py_files = glob.glob(os.path.join(package_dir, "**", "*.py"), recursive=True) @@ -195,12 +195,6 @@ def copy_adjusted_modules(src_folder: str, pkg_name: str, lit_name: str) -> None fo.writelines(py) -def create_mirror_package(src_folder: str, pkg_name: str = "pytorch_lightning", lit_name: str = "pytorch") -> None: - """Recursively replace imports in given folder.""" - copy_adjusted_modules(src_folder, pkg_name, lit_name) - # TODO: copy also UI and other required files - - def set_version_today(fpath: str) -> None: """Replace the template date with today.""" with open(fpath) as fp: @@ -215,12 +209,12 @@ def _replace_today(ln): fp.writelines(lines) -def _download_frontend(root: str = _PROJECT_ROOT): +def _download_frontend(pkg_path: str): """Downloads an archive file for a specific release of the Lightning frontend and extracts it to the correct directory.""" try: - frontend_dir = pathlib.Path(root, "src", "lightning_app", "ui") + frontend_dir = pathlib.Path(pkg_path, "ui") download_dir = tempfile.mkdtemp() shutil.rmtree(frontend_dir, ignore_errors=True) diff --git a/src/lightning/__setup__.py b/src/lightning/__setup__.py index 378a2bfa644a6..b7d37f797ec54 100644 --- a/src/lightning/__setup__.py +++ b/src/lightning/__setup__.py @@ -55,7 +55,7 @@ def _setup_args(**kwargs: Any) -> Dict[str, Any]: # TODO: consider invaliding some additional arguments from packages, for example if include data or safe to zip # TODO: remove this once lightning-ui package is ready as a dependency - _SETUP_TOOLS._download_frontend(_PROJECT_ROOT) + _SETUP_TOOLS._download_frontend(os.path.join(_SOURCE_ROOT, "lightning", "app")) return dict( name="lightning", diff --git a/src/lightning_app/__setup__.py b/src/lightning_app/__setup__.py index 9fd5a5d969bbf..10c4204772e04 100644 --- a/src/lightning_app/__setup__.py +++ b/src/lightning_app/__setup__.py @@ -70,7 +70,7 @@ def _setup_args(**__: Any) -> Dict[str, Any]: ) # TODO: remove this once lightning-ui package is ready as a dependency - _setup_tools._download_frontend(_PROJECT_ROOT) + _setup_tools._download_frontend(os.path.join(_SOURCE_ROOT, "lightning_app")) return dict( name="lightning-app", From 2285871bd163a4fa9951182003e4320e2851bdd5 Mon Sep 17 00:00:00 2001 From: Jirka Date: Thu, 13 Oct 2022 20:37:30 +0200 Subject: [PATCH 022/104] full replace --- .actions/setup_tools.py | 22 +++++++++++++++++----- setup.py | 4 +--- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/.actions/setup_tools.py b/.actions/setup_tools.py index 5e6abccc15f44..7c7f8ff963650 100644 --- a/.actions/setup_tools.py +++ b/.actions/setup_tools.py @@ -12,7 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. import glob -import logging import os import pathlib import re @@ -23,7 +22,7 @@ from datetime import datetime from distutils.version import LooseVersion from importlib.util import module_from_spec, spec_from_file_location -from itertools import chain, groupby +from itertools import chain from types import ModuleType from typing import List, Sequence @@ -179,7 +178,7 @@ def parse_version_from_file(pkg_root: str) -> str: return ver -def create_mirror_package(src_folder: str, pkg_name: str = "pytorch_lightning", lit_name: str = "pytorch") -> None: +def copy_adjusted_modules(src_folder: str, pkg_name: str, lit_name: str, pkg_lut: dict) -> None: """Recursively replace imports in given folder.""" package_dir = os.path.join(src_folder, pkg_name) py_files = glob.glob(os.path.join(package_dir, "**", "*.py"), recursive=True) @@ -187,14 +186,27 @@ def create_mirror_package(src_folder: str, pkg_name: str = "pytorch_lightning", local_path = py_file.replace(package_dir + os.path.sep, "") with open(py_file, encoding="utf-8") as fo: py = fo.readlines() - for i, ln in enumerate(py): - py[i] = re.sub(rf"(?!_){pkg_name}(?!_)", f"lightning.{lit_name}", ln) + for n2, n1 in pkg_lut.items(): + for i, ln in enumerate(py): + py[i] = re.sub(rf"(?!_){n1}(?!_)", f"lightning.{n2}", ln) new_file = os.path.join(src_folder, "lightning", lit_name, local_path) os.makedirs(os.path.dirname(new_file), exist_ok=True) with open(new_file, "w", encoding="utf-8") as fo: fo.writelines(py) +def create_mirror_package(src_folder: str, lit_pkg_mapping: dict) -> None: + """Recursively replace imports in given folder. + + >>> create_mirror_package( + ... os.path.join(_PROJECT_ROOT, "src"), + ... {"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) + + def set_version_today(fpath: str) -> None: """Replace the template date with today.""" with open(fpath) as fp: diff --git a/setup.py b/setup.py index 8babf070d7442..b9680a56510cb 100755 --- a/setup.py +++ b/setup.py @@ -103,9 +103,7 @@ def _load_py_module(name: str, location: str) -> ModuleType: if _PACKAGE_NAME not in _PACKAGE_MAPPING: _SETUP_TOOLS.set_version_today(os.path.join(_PATH_SRC, "lightning", "__version__.py")) - for lit_name, pkg_name in _PACKAGE_MAPPING.items(): - # fixme: if we run creation of meta pkg against stable we shall pull the source - _SETUP_TOOLS.create_mirror_package(os.path.join(_PATH_ROOT, "src"), pkg_name, lit_name) + _SETUP_TOOLS.create_mirror_package(os.path.join(_PATH_ROOT, "src"), _PACKAGE_MAPPING) _SETUP_MODULE = _load_py_module(name="pkg_setup", location=_PATH_SETUP) _SETUP_MODULE._adjust_manifest(pkg_name=_REAL_PKG_NAME) From d7f3c8a20c426f4d2f6bc8964f1fd20e18d713d7 Mon Sep 17 00:00:00 2001 From: Jirka Date: Thu, 13 Oct 2022 23:06:54 +0200 Subject: [PATCH 023/104] ui path? --- src/lightning_app/core/constants.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/lightning_app/core/constants.py b/src/lightning_app/core/constants.py index bfb1deb5ae8f8..1734b6b91e5d9 100644 --- a/src/lightning_app/core/constants.py +++ b/src/lightning_app/core/constants.py @@ -3,8 +3,6 @@ import lightning_cloud.env -import lightning_app - def get_lightning_cloud_url() -> str: # DO NOT CHANGE! @@ -38,7 +36,7 @@ def get_lightning_cloud_url() -> str: HTTP_QUEUE_REFRESH_INTERVAL = float(os.getenv("LIGHTNING_HTTP_QUEUE_REFRESH_INTERVAL", "0.1")) USER_ID = os.getenv("USER_ID", "1234") -FRONTEND_DIR = os.path.join(os.path.dirname(lightning_app.__file__), "ui") +FRONTEND_DIR = str(Path(__file__).parent.parent / "ui") PACKAGE_LIGHTNING = os.getenv("PACKAGE_LIGHTNING", None) CLOUD_UPLOAD_WARNING = int(os.getenv("CLOUD_UPLOAD_WARNING", "2")) DISABLE_DEPENDENCY_CACHE = bool(int(os.getenv("DISABLE_DEPENDENCY_CACHE", "0"))) From 0a17aba13e6087dbd0cc5cf932236491e7d38763 Mon Sep 17 00:00:00 2001 From: Jirka Date: Thu, 20 Oct 2022 11:05:33 +0200 Subject: [PATCH 024/104] replace --- src/lightning_app/runners/cloud.py | 12 ++++++------ src/lightning_app/testing/helpers.py | 6 +++--- tests/tests_app/utilities/test_tracer.py | 2 +- .../components/python/test_scripts.py | 4 ++-- tests/tests_app_examples/test_quick_start.py | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/lightning_app/runners/cloud.py b/src/lightning_app/runners/cloud.py index 68172913767b9..4a75678afa964 100644 --- a/src/lightning_app/runners/cloud.py +++ b/src/lightning_app/runners/cloud.py @@ -227,10 +227,10 @@ def dispatch( ) if list_apps_resp.lightningapps: # There can be only one app with unique project_id<>name pair - lightning_app = list_apps_resp.lightningapps[0] + lit_app = list_apps_resp.lightningapps[0] else: app_body = Body7(name=app_config.name, can_download_source_code=True) - lightning_app = self.backend.client.lightningapp_v2_service_create_lightningapp_v2( + lit_app = self.backend.client.lightningapp_v2_service_create_lightningapp_v2( project_id=project.project_id, body=app_body ) @@ -264,7 +264,7 @@ def dispatch( self._ensure_cluster_project_binding(project.project_id, cluster_id) lightning_app_release = self.backend.client.lightningapp_v2_service_create_lightningapp_release( - project_id=project.project_id, app_id=lightning_app.id, body=release_body + project_id=project.project_id, app_id=lit_app.id, body=release_body ) if cluster_id is not None: @@ -288,7 +288,7 @@ def dispatch( # right now we only allow a single instance of the app find_instances_resp = self.backend.client.lightningapp_instance_service_list_lightningapp_instances( - project_id=project.project_id, app_id=lightning_app.id + project_id=project.project_id, app_id=lit_app.id ) queue_server_type = V1QueueServerType.REDIS if CLOUD_QUEUE_TYPE == "redis" else V1QueueServerType.HTTP if find_instances_resp.lightningapps: @@ -335,12 +335,12 @@ def dispatch( lightning_app_instance = ( self.backend.client.lightningapp_v2_service_create_lightningapp_release_instance( project_id=project.project_id, - app_id=lightning_app.id, + app_id=lit_app.id, id=lightning_app_release.id, body=Body9( cluster_id=cluster_id, desired_state=app_release_desired_state, - name=lightning_app.name, + name=lit_app.name, env=v1_env_vars, queue_server_type=queue_server_type, ), diff --git a/src/lightning_app/testing/helpers.py b/src/lightning_app/testing/helpers.py index f2e29b8213d02..925336a1c39be 100644 --- a/src/lightning_app/testing/helpers.py +++ b/src/lightning_app/testing/helpers.py @@ -54,7 +54,7 @@ def test_wrapper(arg1): def __new__( self, *args, - pytorch_lightning: bool = False, + pl: bool = False, flash: bool = False, min_python: Optional[str] = None, skip_windows: bool = False, @@ -67,7 +67,7 @@ def __new__( """ Args: *args: Any :class:`pytest.mark.skipif` arguments. - pytorch_lightning: Requires that PyTorch Lightning is installed. + pl: Requires that PyTorch Lightning is installed. flash: Requires that Flash is installed. min_python: Require that Python is greater or equal than this version. skip_windows: Skip for Windows platform. @@ -95,7 +95,7 @@ def __new__( conditions.append(sys.platform == "darwin") reasons.append("unimplemented on MacOS") - if pytorch_lightning: + if pl: conditions.append(not _is_pytorch_lightning_available()) reasons.append("PyTorch Lightning is required.") diff --git a/tests/tests_app/utilities/test_tracer.py b/tests/tests_app/utilities/test_tracer.py index 995f0e3da6ccd..6c0ced00fab49 100644 --- a/tests/tests_app/utilities/test_tracer.py +++ b/tests/tests_app/utilities/test_tracer.py @@ -7,7 +7,7 @@ from lightning_app.utilities.tracer import Tracer -@RunIf(pytorch_lightning=True) +@RunIf(pl=True) def test_tracer(): from pytorch_lightning import Trainer diff --git a/tests/tests_app_examples/components/python/test_scripts.py b/tests/tests_app_examples/components/python/test_scripts.py index 0e25fefa28a71..c164ed2200a37 100644 --- a/tests/tests_app_examples/components/python/test_scripts.py +++ b/tests/tests_app_examples/components/python/test_scripts.py @@ -8,7 +8,7 @@ from lightning_app.testing.helpers import run_script, RunIf -@RunIf(pytorch_lightning=True) +@RunIf(pl=True) @pytest.mark.parametrize( "file", [ @@ -21,7 +21,7 @@ def test_scripts(file): @pytest.mark.skip(reason="causing some issues with CI, not sure if the test is actually needed") -@RunIf(pytorch_lightning=True) +@RunIf(pl=True) def test_components_app_example(): runner = CliRunner() diff --git a/tests/tests_app_examples/test_quick_start.py b/tests/tests_app_examples/test_quick_start.py index 875d501bc35b7..6635ec40db8dc 100644 --- a/tests/tests_app_examples/test_quick_start.py +++ b/tests/tests_app_examples/test_quick_start.py @@ -26,7 +26,7 @@ def run_once(self): # TODO: Investigate why it doesn't work @pytest.mark.skipif(True, reason="test is skipped because CI was blocking all the PRs.") -@RunIf(pytorch_lightning=True, skip_windows=True, skip_linux=True) +@RunIf(pl=True, skip_windows=True, skip_linux=True) def test_quick_start_example(caplog, monkeypatch): """This test ensures the Quick Start example properly train and serve PyTorch Lightning.""" From 128b5771e0bcd12475605628c5a9203f7f7fc503 Mon Sep 17 00:00:00 2001 From: Jirka Date: Sun, 23 Oct 2022 10:20:25 +0200 Subject: [PATCH 025/104] updates --- .actions/assistant.py | 8 ++++---- .actions/setup_tools.py | 17 ++++++++++++----- docs/source-lit/conf.py | 10 +++++----- requirements/app/base.txt | 2 +- src/lightning/__init__.py | 5 +++++ src/lightning/__version__.py | 2 +- tests/tests_app/cli/test_connect.py | 6 +++--- 7 files changed, 31 insertions(+), 19 deletions(-) diff --git a/.actions/assistant.py b/.actions/assistant.py index ef09c1079a3d3..017a0a68d13cc 100644 --- a/.actions/assistant.py +++ b/.actions/assistant.py @@ -83,10 +83,10 @@ def prepare_nightly_version(proj_root: str = _PATH_ROOT) -> None: now_date = now.strftime("%Y%m%d") print(f"prepare init '{path_info}' - replace version by {now_date}") - with open(path_info) as fp: + with open(path_info, encoding="utf-8") as fp: init = fp.read() init = re.sub(r'__version__ = [\d\.\w\'"]+', f'__version__ = "{now_date}"', init) - with open(path_info, "w") as fp: + with open(path_info, "w", encoding="utf-8") as fp: fp.write(init) @staticmethod @@ -118,8 +118,8 @@ def _prune_packages(req_file: str, packages: Sequence[str]) -> None: @staticmethod def _replace_min(fname: str) -> None: - req = open(fname).read().replace(">=", "==") - open(fname, "w").write(req) + req = open(fname, encoding="utf-8").read().replace(">=", "==") + open(fname, "w", encoding="utf-8").write(req) @staticmethod def replace_oldest_ver(requirement_fnames: Sequence[str] = REQUIREMENT_FILES_ALL) -> None: diff --git a/.actions/setup_tools.py b/.actions/setup_tools.py index 7c7f8ff963650..574fda4930d8a 100644 --- a/.actions/setup_tools.py +++ b/.actions/setup_tools.py @@ -181,15 +181,22 @@ def parse_version_from_file(pkg_root: str) -> str: def copy_adjusted_modules(src_folder: str, pkg_name: str, lit_name: str, pkg_lut: dict) -> None: """Recursively replace imports in given folder.""" package_dir = os.path.join(src_folder, pkg_name) - py_files = glob.glob(os.path.join(package_dir, "**", "*.py"), recursive=True) - for py_file in py_files: - local_path = py_file.replace(package_dir + os.path.sep, "") - with open(py_file, encoding="utf-8") as fo: + all_files = glob.glob(os.path.join(package_dir, "**", "*.*"), recursive=True) + for fname in all_files: + local_path = fname.replace(package_dir + os.path.sep, "") + new_file = os.path.join(src_folder, "lightning", lit_name, local_path) + if not fname.endswith(".py"): + if not fname.endswith(".pyc"): + os.makedirs(os.path.dirname(new_file), exist_ok=True) + shutil.copy2(fname, new_file) + continue + + with open(fname, encoding="utf-8") as fo: py = fo.readlines() for n2, n1 in pkg_lut.items(): for i, ln in enumerate(py): py[i] = re.sub(rf"(?!_){n1}(?!_)", f"lightning.{n2}", ln) - new_file = os.path.join(src_folder, "lightning", lit_name, local_path) + os.makedirs(os.path.dirname(new_file), exist_ok=True) with open(new_file, "w", encoding="utf-8") as fo: fo.writelines(py) diff --git a/docs/source-lit/conf.py b/docs/source-lit/conf.py index 8d5c4c47465e3..1d499f8316c81 100644 --- a/docs/source-lit/conf.py +++ b/docs/source-lit/conf.py @@ -398,13 +398,13 @@ def find_source(): from typing import Optional import torch -import pytorch_lightning as pl +import lightning.pytorch as pl from torch import nn from torch.utils.data import IterableDataset, DataLoader, Dataset -from pytorch_lightning import LightningDataModule, LightningModule, Trainer, seed_everything -from pytorch_lightning.callbacks import Callback -from pytorch_lightning.cli import LightningCLI -from pytorch_lightning.utilities import ( +from lightning.pytorch import LightningDataModule, LightningModule, Trainer, seed_everything +from lightning.pytorch.callbacks import Callback +from lightning.pytorch.cli import LightningCLI +from lightning.pytorch.utilities import ( _APEX_AVAILABLE, _TORCHVISION_AVAILABLE, _TORCH_GREATER_EQUAL_1_10, diff --git a/requirements/app/base.txt b/requirements/app/base.txt index 2d186bc35e3f4..6cf63c76189f5 100644 --- a/requirements/app/base.txt +++ b/requirements/app/base.txt @@ -1,5 +1,5 @@ lightning-cloud>=0.5.10 -packaging +typing-extensions>=4.0.0, <4.3.1 deepdiff>=5.7.0, <=5.8.1 starsessions>=1.2.1, <2.0 # strict fsspec>=2022.5.0, <=2022.7.1 diff --git a/src/lightning/__init__.py b/src/lightning/__init__.py index cf8873d3d8a91..62275b02b0fc6 100644 --- a/src/lightning/__init__.py +++ b/src/lightning/__init__.py @@ -1,5 +1,6 @@ """Root package info.""" import logging +import os from typing import Any _DETAIL = 15 # between logging.INFO and logging.DEBUG, used for logging in production use cases @@ -39,6 +40,10 @@ def _detail(self: Any, message: str, *args: Any, **kwargs: Any) -> None: from lightning.pytorch.trainer import Trainer # noqa: E402 from lightning.pytorch.utilities.seed import seed_everything # noqa: E402 +import lightning.app # isort: skip # noqa: E402 + +lightning.app._PROJECT_ROOT = os.path.dirname(lightning.app._PROJECT_ROOT) + __all__ = [ "LightningApp", "LightningFlow", diff --git a/src/lightning/__version__.py b/src/lightning/__version__.py index 1a929693c0e53..ea312c65c44f6 100644 --- a/src/lightning/__version__.py +++ b/src/lightning/__version__.py @@ -1 +1 @@ -version = "YYYY.-M.-D" +version = "1.8.0rc0" diff --git a/tests/tests_app/cli/test_connect.py b/tests/tests_app/cli/test_connect.py index 055a4afbd1532..c41cedfa7aeab 100644 --- a/tests/tests_app/cli/test_connect.py +++ b/tests/tests_app/cli/test_connect.py @@ -6,7 +6,7 @@ import click import pytest -from lightning_app import _PACKAGE_ROOT +from lightning_app import _PROJECT_ROOT from lightning_app.cli.commands.connection import ( _list_app_commands, _resolve_command_path, @@ -29,7 +29,7 @@ def test_connect_disconnect_local(monkeypatch): data = json.load(f) data["paths"]["/command/command_with_client"]["post"]["cls_path"] = os.path.join( - os.path.dirname(os.path.dirname(_PACKAGE_ROOT)), + _PROJECT_ROOT, data["paths"]["/command/command_with_client"]["post"]["cls_path"], ) @@ -91,7 +91,7 @@ def test_connect_disconnect_cloud(monkeypatch): data = json.load(f) data["paths"]["/command/command_with_client"]["post"]["cls_path"] = os.path.join( - os.path.dirname(os.path.dirname(_PACKAGE_ROOT)), + _PROJECT_ROOT, data["paths"]["/command/command_with_client"]["post"]["cls_path"], ) From 5b1acfc03c420ac7431964345c16a4ab1c15dd5c Mon Sep 17 00:00:00 2001 From: Jirka Date: Sun, 23 Oct 2022 11:07:38 +0200 Subject: [PATCH 026/104] regex --- .actions/setup_tools.py | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/.actions/setup_tools.py b/.actions/setup_tools.py index 574fda4930d8a..3ccd78c6f939b 100644 --- a/.actions/setup_tools.py +++ b/.actions/setup_tools.py @@ -24,7 +24,7 @@ from importlib.util import module_from_spec, spec_from_file_location from itertools import chain from types import ModuleType -from typing import List, Sequence +from typing import Dict, List, Sequence from pkg_resources import parse_requirements @@ -178,6 +178,30 @@ def parse_version_from_file(pkg_root: str) -> str: return ver +def _replace_imports_in_file(lines: List[str], pkg_lut: Dict[str, str]) -> List[str]: + """REplace imports of standlone package to lightning. + + >>> lns = ["lightning_app", + ... "delete_cloud_lightning_apps", + ... "from lightning_app import", + ... "lightning_app is ours", + ... "def _lightning_app():", + ... ":class:`~lightning_app.core.flow.LightningFlow`"] + >>> from pprint import pprint + >>> pprint(_replace_imports_in_file(lns, {"app": "lightning_app"})) + ['lightning.app', + 'delete_cloud_lightning_apps', + 'from lightning.app import', + 'lightning.app is ours', + 'def _lightning_app():', + ':class:`~lightning.app.core.flow.LightningFlow`'] + """ + for n2, n1 in pkg_lut.items(): + for i, ln in enumerate(lines): + lines[i] = re.sub(rf"([^_]|^){n1}([^_]|$)", rf"\1lightning.{n2}\2", ln) + return lines + + def copy_adjusted_modules(src_folder: str, pkg_name: str, lit_name: str, pkg_lut: dict) -> None: """Recursively replace imports in given folder.""" package_dir = os.path.join(src_folder, pkg_name) @@ -193,10 +217,7 @@ def copy_adjusted_modules(src_folder: str, pkg_name: str, lit_name: str, pkg_lut with open(fname, encoding="utf-8") as fo: py = fo.readlines() - for n2, n1 in pkg_lut.items(): - for i, ln in enumerate(py): - py[i] = re.sub(rf"(?!_){n1}(?!_)", f"lightning.{n2}", ln) - + py = _replace_imports_in_file(py, pkg_lut) os.makedirs(os.path.dirname(new_file), exist_ok=True) with open(new_file, "w", encoding="utf-8") as fo: fo.writelines(py) From ac20d050efbbc552c073f022afcd923343c8183a Mon Sep 17 00:00:00 2001 From: Jirka Date: Sun, 23 Oct 2022 11:26:18 +0200 Subject: [PATCH 027/104] ci --- .github/workflows/ci-app-tests.yml | 7 ++++--- .github/workflows/ci-lite-test-full.yml | 7 ++++--- .github/workflows/ci-pytorch-test-full.yml | 9 +++++---- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci-app-tests.yml b/.github/workflows/ci-app-tests.yml index dea25859ca91d..330e81407d3f9 100644 --- a/.github/workflows/ci-app-tests.yml +++ b/.github/workflows/ci-app-tests.yml @@ -64,10 +64,11 @@ jobs: pip list - name: DocTests App - # todo: run doctest laos on mono-package - if: ${{ matrix.pkg-name != 'LAI' }} working-directory: src - run: python -m pytest lightning_app --ignore-glob="**/cli/*-template/**" + run: | + pip install pytest -q + scope=$(python -c "print('lightning/app' if '${{matrix.pkg-name}}' == 'LAI' else 'lightning_app')") + python -m pytest $scope --ignore-glob="**/cli/*-template/**" - name: Get pip cache id: pip-cache diff --git a/.github/workflows/ci-lite-test-full.yml b/.github/workflows/ci-lite-test-full.yml index f74451accead0..27dc7c23dfbca 100644 --- a/.github/workflows/ci-lite-test-full.yml +++ b/.github/workflows/ci-lite-test-full.yml @@ -83,10 +83,11 @@ jobs: pip list - name: DocTests Lite - # todo: run docstest laos on mono-package - if: ${{ matrix.pkg-name != 'LAI' }} working-directory: src - run: python -m pytest lightning_lite + run: | + pip install pytest -q + scope=$(python -c "print('lightning/lite' if '${{matrix.pkg-name}}' == 'LAI' else 'lightning_lite')") + python -m pytest $scope # Note: This uses an internal pip API and may not always work # https://github.com/actions/cache/blob/master/examples.md#multiple-oss-in-a-workflow diff --git a/.github/workflows/ci-pytorch-test-full.yml b/.github/workflows/ci-pytorch-test-full.yml index 13c9c0cb107f9..ef16d6e50516a 100644 --- a/.github/workflows/ci-pytorch-test-full.yml +++ b/.github/workflows/ci-pytorch-test-full.yml @@ -111,14 +111,15 @@ jobs: env: PACKAGE_NAME: ${{ matrix.pkg-name }} run: | - pip install -e . pytest --upgrade --find-links ${TORCH_URL} + pip install -e . --upgrade --find-links ${TORCH_URL} pip list - name: DocTests PL - # todo: run docstest laos on mono-package - if: ${{ matrix.pkg-name != 'LAI' }} working-directory: ./src - run: python -m pytest pytorch_lightning + run: | + pip install pytest -q + scope=$(python -c "print('lightning/pytorch' if '${{matrix.pkg-name}}' == 'LAI' else 'pytorch_lightning')") + python -m pytest $scope - name: Get pip cache dir id: pip-cache From 20b70452470aca88072ac96408549260b4be098e Mon Sep 17 00:00:00 2001 From: Jirka Date: Sun, 23 Oct 2022 13:51:57 +0200 Subject: [PATCH 028/104] fix --- .actions/setup_tools.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.actions/setup_tools.py b/.actions/setup_tools.py index 3ccd78c6f939b..739089c72d7b8 100644 --- a/.actions/setup_tools.py +++ b/.actions/setup_tools.py @@ -184,6 +184,7 @@ def _replace_imports_in_file(lines: List[str], pkg_lut: Dict[str, str]) -> List[ >>> lns = ["lightning_app", ... "delete_cloud_lightning_apps", ... "from lightning_app import", + ... "lightning_apps = []", ... "lightning_app is ours", ... "def _lightning_app():", ... ":class:`~lightning_app.core.flow.LightningFlow`"] @@ -192,13 +193,14 @@ def _replace_imports_in_file(lines: List[str], pkg_lut: Dict[str, str]) -> List[ ['lightning.app', 'delete_cloud_lightning_apps', 'from lightning.app import', + 'lightning_apps = []', 'lightning.app is ours', 'def _lightning_app():', ':class:`~lightning.app.core.flow.LightningFlow`'] """ for n2, n1 in pkg_lut.items(): for i, ln in enumerate(lines): - lines[i] = re.sub(rf"([^_]|^){n1}([^_]|$)", rf"\1lightning.{n2}\2", ln) + lines[i] = re.sub(rf"([^_]|^){n1}([^_\w]|$)", rf"\1lightning.{n2}\2", ln) return lines From f196539f3138ad0eb74b050173425834bd8bbf3d Mon Sep 17 00:00:00 2001 From: Jirka Date: Sun, 23 Oct 2022 13:57:54 +0200 Subject: [PATCH 029/104] ci --- .github/workflows/ci-pkg-install.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-pkg-install.yml b/.github/workflows/ci-pkg-install.yml index 0210cfe9a3bf1..fdcf3bcefa939 100644 --- a/.github/workflows/ci-pkg-install.yml +++ b/.github/workflows/ci-pkg-install.yml @@ -32,10 +32,15 @@ jobs: with: python-version: ${{ matrix.python-version }} + - name: Install pytest extensions + # TODO: for mono-package create & load requirements/test.txt + if: ${{ matrix.pkg != '' }} + run: grep 'pytest>' requirements/${{ matrix.pkg }}/test.txt | xargs -0 pip install + - name: DocTests actions working-directory: .actions/ run: | - grep 'pytest>' ../requirements/pytorch/test.txt | xargs -0 pip install + pip install pytest -q python -m pytest setup_tools.py - run: python -c "print('NB_DIRS=' + str(2 if '${{ matrix.pkg }}' == 'pytorch' else 1))" >> $GITHUB_ENV @@ -47,5 +52,5 @@ jobs: - uses: ./.github/actions/pkg-install - name: Run CLI - if: matrix.pkg == '' + if: ${{ matrix.pkg == '' }} run: python -m lightning --version From 27a223c4c3c27aa4186824e02ef935dc1f0ab89f Mon Sep 17 00:00:00 2001 From: Jirka Date: Sun, 23 Oct 2022 19:58:39 +0200 Subject: [PATCH 030/104] path --- src/lightning_app/__setup__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lightning_app/__setup__.py b/src/lightning_app/__setup__.py index 1f0c6ec7fbfa1..55ba6d09fae11 100644 --- a/src/lightning_app/__setup__.py +++ b/src/lightning_app/__setup__.py @@ -70,7 +70,7 @@ def _setup_args(**__: Any) -> Dict[str, Any]: ) # TODO: remove this once lightning-ui package is ready as a dependency - _setup_tools._download_frontend(os.path.join(_SOURCE_ROOT, "lightning_app")) + _setup_tools._download_frontend(_PACKAGE_ROOT) return dict( name="lightning-app", From a2dded9c451d3a51c2708abc3d0b47e05b3d0d4c Mon Sep 17 00:00:00 2001 From: Jirka Date: Sun, 23 Oct 2022 22:54:40 +0200 Subject: [PATCH 031/104] ci --- .github/workflows/ci-app-examples.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci-app-examples.yml b/.github/workflows/ci-app-examples.yml index e998f2a218dcf..018b886c3c465 100644 --- a/.github/workflows/ci-app-examples.yml +++ b/.github/workflows/ci-app-examples.yml @@ -80,6 +80,8 @@ jobs: run: npm install -g yarn - name: Install Lightning as top-level + env: + PACKAGE_NAME: app run: pip install -e . shell: bash From db2af8bdfe1b0e085d8d44ffec1ec210aeec7bae Mon Sep 17 00:00:00 2001 From: Jirka Date: Sun, 23 Oct 2022 22:57:51 +0200 Subject: [PATCH 032/104] replace --- .actions/assistant.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.actions/assistant.py b/.actions/assistant.py index 017a0a68d13cc..bccc890afab40 100644 --- a/.actions/assistant.py +++ b/.actions/assistant.py @@ -212,7 +212,7 @@ def copy_replace_imports( for source_import, target_import in zip(source_imports, target_imports): for i, ln in enumerate(py): - py[i] = re.sub(rf"(?!_){source_import}(?!_)", target_import, ln) + py[i] = re.sub(rf"([^_]|^){source_import}([^_\w]|$)", rf"\1{target_import}\2", ln) if target_dir: fp_new = fp.replace(source_dir, target_dir) From 8bd711413702e4f970a3e714754b25606a8eb396 Mon Sep 17 00:00:00 2001 From: Justus Schock <12886177+justusschock@users.noreply.github.com> Date: Mon, 24 Oct 2022 10:51:31 +0200 Subject: [PATCH 033/104] Update .actions/setup_tools.py Co-authored-by: Jirka Borovec --- .actions/setup_tools.py | 1 + 1 file changed, 1 insertion(+) diff --git a/.actions/setup_tools.py b/.actions/setup_tools.py index 739089c72d7b8..15f05c11966cf 100644 --- a/.actions/setup_tools.py +++ b/.actions/setup_tools.py @@ -204,6 +204,7 @@ def _replace_imports_in_file(lines: List[str], pkg_lut: Dict[str, str]) -> List[ return lines +# TODO: unify usage with assistant function, such that import this function in there def copy_adjusted_modules(src_folder: str, pkg_name: str, lit_name: str, pkg_lut: dict) -> None: """Recursively replace imports in given folder.""" package_dir = os.path.join(src_folder, pkg_name) From 6a503f9dc9da50d70dd494ca1743d9bf57ef2602 Mon Sep 17 00:00:00 2001 From: Justus Schock Date: Mon, 24 Oct 2022 12:06:25 +0200 Subject: [PATCH 034/104] also convert lightning_lite tests for PL tests to adapt mocking paths --- .github/workflows/ci-pytorch-test-full.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-pytorch-test-full.yml b/.github/workflows/ci-pytorch-test-full.yml index ef16d6e50516a..c9ee29a009563 100644 --- a/.github/workflows/ci-pytorch-test-full.yml +++ b/.github/workflows/ci-pytorch-test-full.yml @@ -168,7 +168,7 @@ jobs: - name: Adjust tests if: ${{ matrix.pkg-name == 'LAI' }} - run: python .actions/assistant.py copy_replace_imports --source_dir="./tests" --source_import="pytorch_lightning" --target_import="lightning.pytorch" + run: python .actions/assistant.py copy_replace_imports --source_dir="./tests" --source_import="pytorch_lightning,lightning_lite" --target_import="lightning.pytorch,lightning.lite" - name: Testing Warnings # the stacklevel can only be set on >=3.7 From 26801bc5c253c7f95c2c0af773ea0471e578f98c Mon Sep 17 00:00:00 2001 From: manskx Date: Mon, 24 Oct 2022 12:08:40 +0200 Subject: [PATCH 035/104] fix app example test --- tests/tests_app_examples/test_argparse.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/tests_app_examples/test_argparse.py b/tests/tests_app_examples/test_argparse.py index 0c1e55b0d4498..ddc0f51799467 100644 --- a/tests/tests_app_examples/test_argparse.py +++ b/tests/tests_app_examples/test_argparse.py @@ -1,7 +1,7 @@ import os import sys -from lightning_app import _PACKAGE_ROOT +from lightning_app import _PROJECT_ROOT from lightning_app.testing.testing import application_testing from lightning_app.utilities.load_app import _patch_sys_argv @@ -10,12 +10,13 @@ def test_app_argparse_example(): original_argv = sys.argv command_line = [ - os.path.join(os.path.dirname(os.path.dirname(_PACKAGE_ROOT)), "examples/app_argparse/app.py"), + os.path.join(_PROJECT_ROOT, "examples/app_argparse/app.py"), "--app_args", "--use_gpu", "--without-server", ] result = application_testing(command_line=command_line) + print(result.stdout) assert result.exit_code == 0, result.__dict__ assert sys.argv == original_argv From de6b9b12b1181439fc911e292336d99ac1e2e652 Mon Sep 17 00:00:00 2001 From: Justus Schock Date: Mon, 24 Oct 2022 14:36:34 +0200 Subject: [PATCH 036/104] update logger propagation for PL tests --- tests/tests_pytorch/conftest.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/tests/tests_pytorch/conftest.py b/tests/tests_pytorch/conftest.py index b6f4942dc6859..5d8616ad00657 100644 --- a/tests/tests_pytorch/conftest.py +++ b/tests/tests_pytorch/conftest.py @@ -191,11 +191,23 @@ def caplog(caplog): """ import logging - lightning_logger = logging.getLogger("pytorch_lightning") - propagate = lightning_logger.propagate - lightning_logger.propagate = True + root_logger = logging.getLogger() + root_propagate = root_logger.propagate + root_logger.propagate = True + + propagation_dict = { + name: logging.getLogger(name).propagate + for name in logging.root.manager.loggerDict + if name.startswith("pytorch_lightning") + } + for name in propagation_dict.keys(): + logging.getLogger(name).propagate = True + yield caplog - lightning_logger.propagate = propagate + + root_logger.propagate = root_propagate + for name, propagate in propagation_dict.items(): + logging.getLogger(name).propagate = propagate @pytest.fixture From c1a5e119c740b5468daac63028de8aa799a177ac Mon Sep 17 00:00:00 2001 From: Justus Schock Date: Mon, 24 Oct 2022 15:21:38 +0200 Subject: [PATCH 037/104] update logger propagation for PL tests --- tests/tests_pytorch/loops/test_training_loop.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/tests_pytorch/loops/test_training_loop.py b/tests/tests_pytorch/loops/test_training_loop.py index dc52a08f068ae..7ae02c663f2e8 100644 --- a/tests/tests_pytorch/loops/test_training_loop.py +++ b/tests/tests_pytorch/loops/test_training_loop.py @@ -174,7 +174,7 @@ def test_fit_loop_done_log_messages(caplog): fit_loop.max_epochs = 5 fit_loop.epoch_loop.min_steps = 0 - with caplog.at_level(level=logging.DEBUG, logger="pytorch_lightning.utilities.rank_zero"): + with caplog.at_level(level=logging.DEBUG): assert fit_loop.done assert "should_stop` was set" in caplog.text @@ -224,7 +224,7 @@ def test_should_stop_early_stopping_conditions_met( trainer.fit_loop.epoch_progress.current.processed = current_epoch message = "`Trainer.fit` stopped: `trainer.should_stop` was set." - with caplog.at_level(level=logging.DEBUG, logger="pytorch_lightning.utilities.rank_zero"): + with caplog.at_level(level=logging.DEBUG): assert trainer.fit_loop.done is fit_loop_done assert (message in caplog.text) is raise_debug_msg From 3a5541655d7b08da9bb2b20abcc987d67476b66c Mon Sep 17 00:00:00 2001 From: Jirka Borovec Date: Mon, 24 Oct 2022 16:10:28 +0200 Subject: [PATCH 038/104] Apply suggestions from code review --- .github/actions/pkg-check/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/pkg-check/action.yml b/.github/actions/pkg-check/action.yml index 21709c92c5de5..9f86319774585 100644 --- a/.github/actions/pkg-check/action.yml +++ b/.github/actions/pkg-check/action.yml @@ -5,7 +5,7 @@ inputs: pkg-name: description: package name inside lightning.* required: true - default: "lightning" + default: "" nb-dirs: description: nb of packages in the wrap/distribution required: false From 0ce862ea7ecfc51789e64fd6957393221d7069bc Mon Sep 17 00:00:00 2001 From: Justus Schock Date: Mon, 24 Oct 2022 15:21:38 +0200 Subject: [PATCH 039/104] Revert "update logger propagation for PL tests" This reverts commit c1a5e119c740b5468daac63028de8aa799a177ac. --- tests/tests_pytorch/loops/test_training_loop.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/tests_pytorch/loops/test_training_loop.py b/tests/tests_pytorch/loops/test_training_loop.py index 7ae02c663f2e8..dc52a08f068ae 100644 --- a/tests/tests_pytorch/loops/test_training_loop.py +++ b/tests/tests_pytorch/loops/test_training_loop.py @@ -174,7 +174,7 @@ def test_fit_loop_done_log_messages(caplog): fit_loop.max_epochs = 5 fit_loop.epoch_loop.min_steps = 0 - with caplog.at_level(level=logging.DEBUG): + with caplog.at_level(level=logging.DEBUG, logger="pytorch_lightning.utilities.rank_zero"): assert fit_loop.done assert "should_stop` was set" in caplog.text @@ -224,7 +224,7 @@ def test_should_stop_early_stopping_conditions_met( trainer.fit_loop.epoch_progress.current.processed = current_epoch message = "`Trainer.fit` stopped: `trainer.should_stop` was set." - with caplog.at_level(level=logging.DEBUG): + with caplog.at_level(level=logging.DEBUG, logger="pytorch_lightning.utilities.rank_zero"): assert trainer.fit_loop.done is fit_loop_done assert (message in caplog.text) is raise_debug_msg From 391d0c4534b02db7a7ac8b3252c0ac7e6e0c9280 Mon Sep 17 00:00:00 2001 From: Jirka Date: Mon, 24 Oct 2022 16:56:21 +0200 Subject: [PATCH 040/104] playwright --- requirements/app/test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/app/test.txt b/requirements/app/test.txt index cf5df4c8297fe..3dcad0517e5b4 100644 --- a/requirements/app/test.txt +++ b/requirements/app/test.txt @@ -3,7 +3,7 @@ codecov>=2.1, <=2.1.12 pytest>=7.0, <=7.1.2 pytest-timeout <=2.1.0 pytest-cov <=3.0.0 -playwright==1.27.1 +playwright>=1.17.2 # this is the latest version for py3.8 # pytest-flake8 httpx trio<0.22.0 From 1a63da21c8280e2aa7b5df7ee665c494c75d06f9 Mon Sep 17 00:00:00 2001 From: Jirka Date: Mon, 24 Oct 2022 17:05:18 +0200 Subject: [PATCH 041/104] py --- .github/workflows/ci-app-examples.yml | 2 +- .github/workflows/ci-app-tests.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-app-examples.yml b/.github/workflows/ci-app-examples.yml index b2dad27bcb25f..7384fc0fcf7db 100644 --- a/.github/workflows/ci-app-examples.yml +++ b/.github/workflows/ci-app-examples.yml @@ -33,7 +33,7 @@ jobs: matrix: os: [ubuntu-20.04, macOS-11, windows-2022] pkg-name: ["LAI", "app"] # the "LAI" is for installing monolithic package - python-version: [3.8] + python-version: ["3.9"] requires: ["oldest", "latest"] # Timeout: https://stackoverflow.com/a/59076067/4521646 diff --git a/.github/workflows/ci-app-tests.yml b/.github/workflows/ci-app-tests.yml index 0498a40066163..954a0f8c65a23 100644 --- a/.github/workflows/ci-app-tests.yml +++ b/.github/workflows/ci-app-tests.yml @@ -33,7 +33,7 @@ jobs: matrix: os: [ubuntu-20.04, macOS-11, windows-2022] pkg-name: ["LAI", "app"] # the "LAI" is for installing monolithic package - python-version: [3.8] + python-version: ["3.8"] requires: ["oldest", "latest"] # Timeout: https://stackoverflow.com/a/59076067/4521646 From 9330b9d5f9bb7c5215e841738b589fc7b499a4b9 Mon Sep 17 00:00:00 2001 From: manskx Date: Mon, 24 Oct 2022 17:36:26 +0200 Subject: [PATCH 042/104] update import in tests --- tests/tests_app_examples/test_collect_failures.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/tests_app_examples/test_collect_failures.py b/tests/tests_app_examples/test_collect_failures.py index c149211e10774..2a4e3e79474e4 100644 --- a/tests/tests_app_examples/test_collect_failures.py +++ b/tests/tests_app_examples/test_collect_failures.py @@ -2,7 +2,7 @@ from time import sleep import pytest -from tests_app import _PROJECT_ROOT +from lightning_app import _PROJECT_ROOT from lightning_app.testing.testing import run_app_in_cloud From cbb16587f120fa9b0ce0e58ba1d208e87ddedc41 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 24 Oct 2022 15:38:51 +0000 Subject: [PATCH 043/104] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/tests_app_examples/test_collect_failures.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/tests_app_examples/test_collect_failures.py b/tests/tests_app_examples/test_collect_failures.py index 2a4e3e79474e4..6bda6bf4bd253 100644 --- a/tests/tests_app_examples/test_collect_failures.py +++ b/tests/tests_app_examples/test_collect_failures.py @@ -2,8 +2,8 @@ from time import sleep import pytest -from lightning_app import _PROJECT_ROOT +from lightning_app import _PROJECT_ROOT from lightning_app.testing.testing import run_app_in_cloud From c02f766521c91454be36b19784c6a3ed2f715109 Mon Sep 17 00:00:00 2001 From: Jirka Date: Mon, 24 Oct 2022 17:55:40 +0200 Subject: [PATCH 044/104] try edit import in overwrite --- src/lightning_app/utilities/app_helpers.py | 24 +++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/lightning_app/utilities/app_helpers.py b/src/lightning_app/utilities/app_helpers.py index 10f07e86cb0c7..3a0ca4fe80e65 100644 --- a/src/lightning_app/utilities/app_helpers.py +++ b/src/lightning_app/utilities/app_helpers.py @@ -16,7 +16,7 @@ import websockets from deepdiff import Delta -import lightning_app +from lightning_app import _logger, LightningWork, structures from lightning_app.core.constants import APP_SERVER_PORT, APP_STATE_MAX_SIZE_BYTES, SUPPORTED_PRIMITIVE_TYPES from lightning_app.utilities.exceptions import LightningAppStateException @@ -233,10 +233,10 @@ def is_overridden(method_name: str, instance: Optional[object] = None, parent: O if instance is None: return False if parent is None: - if isinstance(instance, lightning_app.LightningFlow): - parent = lightning_app.LightningFlow - elif isinstance(instance, lightning_app.LightningWork): - parent = lightning_app.LightningWork + if isinstance(instance, LightningFlow): + parent = LightningFlow + elif isinstance(instance, LightningWork): + parent = LightningWork if parent is None: raise ValueError("Expected a parent") from lightning_utilities.core.overrides import is_overridden @@ -263,7 +263,7 @@ def _set_child_name(component: "Component", child: "Component", new_name: str) - child._name = child_name # the name changed, so recursively update the names of the children of this child - if isinstance(child, lightning_app.core.LightningFlow): + if isinstance(child, LightningFlow): for n, c in child.flows.items(): _set_child_name(child, c, n) for n, w in child.named_works(recurse=False): @@ -271,10 +271,10 @@ def _set_child_name(component: "Component", child: "Component", new_name: str) - for n in child._structures: s = getattr(child, n) _set_child_name(child, s, n) - if isinstance(child, lightning_app.structures.Dict): + if isinstance(child, structures.Dict): for n, c in child.items(): _set_child_name(child, c, n) - if isinstance(child, lightning_app.structures.List): + if isinstance(child, structures.List): for c in child: _set_child_name(child, c, c.name.split(".")[-1]) @@ -290,13 +290,13 @@ def _delta_to_app_state_delta(root: "LightningFlow", component: "Component", del new_prefix = "root" for p, c in _walk_to_component(root, component): - if isinstance(c, lightning_app.core.LightningWork): + if isinstance(c, LightningWork): new_prefix += "['works']" - if isinstance(c, lightning_app.core.LightningFlow): + if isinstance(c, LightningFlow): new_prefix += "['flows']" - if isinstance(c, (lightning_app.structures.Dict, lightning_app.structures.List)): + if isinstance(c, (structures.Dict, structures.List)): new_prefix += "['structures']" c_n = c.name.split(".")[-1] @@ -341,7 +341,7 @@ def _collect_child_process_pids(pid: int) -> List[int]: def _print_to_logger_info(*args, **kwargs): # TODO Find a better way to re-direct print to loggers. - lightning_app._logger.info(" ".join([str(v) for v in args])) + _logger.info(" ".join([str(v) for v in args])) def convert_print_to_logger_info(func: Callable) -> Callable: From 70fca84f3eb4403721f31df962b605a7aef7285e Mon Sep 17 00:00:00 2001 From: manskx Date: Mon, 24 Oct 2022 17:57:43 +0200 Subject: [PATCH 045/104] debug code --- src/lightning_app/utilities/load_app.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/lightning_app/utilities/load_app.py b/src/lightning_app/utilities/load_app.py index 614944bc7e249..2fc01d7159530 100644 --- a/src/lightning_app/utilities/load_app.py +++ b/src/lightning_app/utilities/load_app.py @@ -80,6 +80,9 @@ def _create_code(script_path: str): with open_python_file(script_path) as f: filebody = f.read() + logger.info(f"Loading app from {script_path}") + logger.info("code: %s", filebody) + return compile( filebody, # Pass in the file path so it can show up in exceptions. From a97bfd630ac2f65106645e4bff97dbd3d44a1b6f Mon Sep 17 00:00:00 2001 From: Jirka Date: Mon, 24 Oct 2022 17:59:23 +0200 Subject: [PATCH 046/104] rev playwright --- requirements/app/test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/app/test.txt b/requirements/app/test.txt index 3dcad0517e5b4..db5dec735e646 100644 --- a/requirements/app/test.txt +++ b/requirements/app/test.txt @@ -3,7 +3,7 @@ codecov>=2.1, <=2.1.12 pytest>=7.0, <=7.1.2 pytest-timeout <=2.1.0 pytest-cov <=3.0.0 -playwright>=1.17.2 # this is the latest version for py3.8 +playwright>=1.27.1, <1.27.2 # pytest-flake8 httpx trio<0.22.0 From a3fbc7568b3aa5ed71ae9ea10ebf598c47fec6ed Mon Sep 17 00:00:00 2001 From: Jirka Date: Mon, 24 Oct 2022 18:09:56 +0200 Subject: [PATCH 047/104] Revert "try edit import in overwrite" This reverts commit c02f766521c91454be36b19784c6a3ed2f715109. --- src/lightning_app/utilities/app_helpers.py | 24 +++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/lightning_app/utilities/app_helpers.py b/src/lightning_app/utilities/app_helpers.py index 3a0ca4fe80e65..10f07e86cb0c7 100644 --- a/src/lightning_app/utilities/app_helpers.py +++ b/src/lightning_app/utilities/app_helpers.py @@ -16,7 +16,7 @@ import websockets from deepdiff import Delta -from lightning_app import _logger, LightningWork, structures +import lightning_app from lightning_app.core.constants import APP_SERVER_PORT, APP_STATE_MAX_SIZE_BYTES, SUPPORTED_PRIMITIVE_TYPES from lightning_app.utilities.exceptions import LightningAppStateException @@ -233,10 +233,10 @@ def is_overridden(method_name: str, instance: Optional[object] = None, parent: O if instance is None: return False if parent is None: - if isinstance(instance, LightningFlow): - parent = LightningFlow - elif isinstance(instance, LightningWork): - parent = LightningWork + if isinstance(instance, lightning_app.LightningFlow): + parent = lightning_app.LightningFlow + elif isinstance(instance, lightning_app.LightningWork): + parent = lightning_app.LightningWork if parent is None: raise ValueError("Expected a parent") from lightning_utilities.core.overrides import is_overridden @@ -263,7 +263,7 @@ def _set_child_name(component: "Component", child: "Component", new_name: str) - child._name = child_name # the name changed, so recursively update the names of the children of this child - if isinstance(child, LightningFlow): + if isinstance(child, lightning_app.core.LightningFlow): for n, c in child.flows.items(): _set_child_name(child, c, n) for n, w in child.named_works(recurse=False): @@ -271,10 +271,10 @@ def _set_child_name(component: "Component", child: "Component", new_name: str) - for n in child._structures: s = getattr(child, n) _set_child_name(child, s, n) - if isinstance(child, structures.Dict): + if isinstance(child, lightning_app.structures.Dict): for n, c in child.items(): _set_child_name(child, c, n) - if isinstance(child, structures.List): + if isinstance(child, lightning_app.structures.List): for c in child: _set_child_name(child, c, c.name.split(".")[-1]) @@ -290,13 +290,13 @@ def _delta_to_app_state_delta(root: "LightningFlow", component: "Component", del new_prefix = "root" for p, c in _walk_to_component(root, component): - if isinstance(c, LightningWork): + if isinstance(c, lightning_app.core.LightningWork): new_prefix += "['works']" - if isinstance(c, LightningFlow): + if isinstance(c, lightning_app.core.LightningFlow): new_prefix += "['flows']" - if isinstance(c, (structures.Dict, structures.List)): + if isinstance(c, (lightning_app.structures.Dict, lightning_app.structures.List)): new_prefix += "['structures']" c_n = c.name.split(".")[-1] @@ -341,7 +341,7 @@ def _collect_child_process_pids(pid: int) -> List[int]: def _print_to_logger_info(*args, **kwargs): # TODO Find a better way to re-direct print to loggers. - _logger.info(" ".join([str(v) for v in args])) + lightning_app._logger.info(" ".join([str(v) for v in args])) def convert_print_to_logger_info(func: Callable) -> Callable: From 51879cdb1903eb00010c5e49e1e895c817507473 Mon Sep 17 00:00:00 2001 From: Jirka Date: Mon, 24 Oct 2022 17:59:23 +0200 Subject: [PATCH 048/104] ci: adjust examples --- .github/workflows/ci-app-examples.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/ci-app-examples.yml b/.github/workflows/ci-app-examples.yml index 7384fc0fcf7db..bae782089b28a 100644 --- a/.github/workflows/ci-app-examples.yml +++ b/.github/workflows/ci-app-examples.yml @@ -92,6 +92,12 @@ jobs: if: ${{ matrix.pkg-name == 'LAI' }} run: python .actions/assistant.py copy_replace_imports --source_dir="./tests" --source_import="lightning_app" --target_import="lightning.app" + - name: Adjust examples + if: ${{ matrix.pkg-name != 'LAI' }} + 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" + - name: switch coverage scope run: python -c "print('COVERAGE_SCOPE=' + str('lightning' if '${{matrix.pkg-name}}' == 'LAI' else 'lightning_app'))" >> $GITHUB_ENV From 43c63c853bb18d09737406cc485e61357a605860 Mon Sep 17 00:00:00 2001 From: manskx Date: Mon, 24 Oct 2022 19:39:35 +0200 Subject: [PATCH 049/104] adjust examples cloud --- .azure/app-cloud-e2e.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.azure/app-cloud-e2e.yml b/.azure/app-cloud-e2e.yml index 3a506668963ac..809f4bbcc9b63 100644 --- a/.azure/app-cloud-e2e.yml +++ b/.azure/app-cloud-e2e.yml @@ -133,6 +133,11 @@ jobs: condition: eq(variables['name'], 'quick_start') displayName: 'Install Quick Start' + - bash: | + 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" + displayName: 'Adjust examples' + - bash: | pip --version pip list From 65166d9d68d66603c7f6aac36fb80292723bcdc6 Mon Sep 17 00:00:00 2001 From: manskx Date: Mon, 24 Oct 2022 19:51:53 +0200 Subject: [PATCH 050/104] mock lightning_app --- src/lightning_app/testing/testing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lightning_app/testing/testing.py b/src/lightning_app/testing/testing.py index 21ee0c8605609..3a13a7ad4e566 100644 --- a/src/lightning_app/testing/testing.py +++ b/src/lightning_app/testing/testing.py @@ -134,7 +134,7 @@ def application_testing( from click.testing import CliRunner - with mock.patch("lightning.LightningApp", lightning_app_cls): + with mock.patch("lightning_app.LightningApp", lightning_app_cls): original = sys.argv sys.argv = command_line runner = CliRunner() From 48217423065e47ce665fe65d2a921c59486d2e5e Mon Sep 17 00:00:00 2001 From: manskx Date: Mon, 24 Oct 2022 19:57:24 +0200 Subject: [PATCH 051/104] Install assistant dependencies --- .azure/app-cloud-e2e.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.azure/app-cloud-e2e.yml b/.azure/app-cloud-e2e.yml index 809f4bbcc9b63..64e708b1573e6 100644 --- a/.azure/app-cloud-e2e.yml +++ b/.azure/app-cloud-e2e.yml @@ -133,6 +133,9 @@ jobs: condition: eq(variables['name'], 'quick_start') displayName: 'Install Quick Start' + - bash: python -m pip install -q -r .actions/requirements.txt + displayName: 'Install assistant dependencies' + - bash: | 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" From ed703f522d76c2c7a5eb9620f08240b6f8ac053b Mon Sep 17 00:00:00 2001 From: Jirka Date: Mon, 24 Oct 2022 20:47:12 +0200 Subject: [PATCH 052/104] lightning --- .github/workflows/ci-app-examples.yml | 8 ++++---- .github/workflows/ci-app-tests.yml | 10 +++++----- .github/workflows/ci-lite-test-full.yml | 10 +++++----- .github/workflows/ci-pytorch-test-full.yml | 16 ++++++++-------- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/.github/workflows/ci-app-examples.yml b/.github/workflows/ci-app-examples.yml index bae782089b28a..3a4f3799a0d0b 100644 --- a/.github/workflows/ci-app-examples.yml +++ b/.github/workflows/ci-app-examples.yml @@ -32,7 +32,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-20.04, macOS-11, windows-2022] - pkg-name: ["LAI", "app"] # the "LAI" is for installing monolithic package + pkg-name: ["lightning", "app"] # the "lightning" is for installing monolithic package python-version: ["3.9"] requires: ["oldest", "latest"] @@ -89,17 +89,17 @@ jobs: run: pip install -e . - name: Adjust tests - if: ${{ matrix.pkg-name == 'LAI' }} + if: ${{ matrix.pkg-name == 'lightning' }} run: python .actions/assistant.py copy_replace_imports --source_dir="./tests" --source_import="lightning_app" --target_import="lightning.app" - name: Adjust examples - if: ${{ matrix.pkg-name != 'LAI' }} + 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" - name: switch coverage scope - run: python -c "print('COVERAGE_SCOPE=' + str('lightning' if '${{matrix.pkg-name}}' == 'LAI' else 'lightning_app'))" >> $GITHUB_ENV + run: python -c "print('COVERAGE_SCOPE=' + str('lightning' if '${{matrix.pkg-name}}' == 'lightning' else 'lightning_app'))" >> $GITHUB_ENV - name: Tests working-directory: ./tests diff --git a/.github/workflows/ci-app-tests.yml b/.github/workflows/ci-app-tests.yml index 954a0f8c65a23..339fc99366c04 100644 --- a/.github/workflows/ci-app-tests.yml +++ b/.github/workflows/ci-app-tests.yml @@ -32,7 +32,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-20.04, macOS-11, windows-2022] - pkg-name: ["LAI", "app"] # the "LAI" is for installing monolithic package + pkg-name: ["lightning", "app"] # the "lightning" is for installing monolithic package python-version: ["3.8"] requires: ["oldest", "latest"] @@ -67,7 +67,7 @@ jobs: working-directory: src run: | pip install pytest -q - scope=$(python -c "print('lightning/app' if '${{matrix.pkg-name}}' == 'LAI' else 'lightning_app')") + scope=$(python -c "print('lightning/app' if '${{matrix.pkg-name}}' == 'lightning' else 'lightning_app')") python -m pytest $scope --ignore-glob="**/cli/*-template/**" - name: Get pip cache @@ -99,17 +99,17 @@ jobs: run: npm install -g yarn - name: Adjust tests - if: ${{ matrix.pkg-name == 'LAI' }} + if: ${{ matrix.pkg-name == 'lightning' }} run: python .actions/assistant.py copy_replace_imports --source_dir="./tests" --source_import="lightning_app" --target_import="lightning.app" - name: Adjust examples - if: ${{ matrix.pkg-name != 'LAI' }} + 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" - name: switch coverage scope - run: python -c "print('COVERAGE_SCOPE=' + str('lightning' if '${{matrix.pkg-name}}' == 'LAI' else 'lightning_app'))" >> $GITHUB_ENV + run: python -c "print('COVERAGE_SCOPE=' + str('lightning' if '${{matrix.pkg-name}}' == 'lightning' else 'lightning_app'))" >> $GITHUB_ENV - name: Tests working-directory: ./tests diff --git a/.github/workflows/ci-lite-test-full.yml b/.github/workflows/ci-lite-test-full.yml index 27dc7c23dfbca..69ae3db90ffe2 100644 --- a/.github/workflows/ci-lite-test-full.yml +++ b/.github/workflows/ci-lite-test-full.yml @@ -34,7 +34,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-20.04, windows-2022, macOS-11] - pkg-name: ["LAI", "lite"] # the "LAI" is for installing monolithic package + pkg-name: ["lightning", "lite"] # the "lightning" is for installing monolithic package python-version: ["3.7", "3.10"] requires: ["oldest", "latest"] release: ["stable"] @@ -44,7 +44,7 @@ jobs: - {python-version: "3.9", requires: "oldest"} - {python-version: "3.10", requires: "oldest"} include: - - {os: ubuntu-22.04, pkg-name: "LAI", python-version: "3.10", release: "pre"} + - {os: ubuntu-22.04, pkg-name: "lightning", python-version: "3.10", release: "pre"} - {os: ubuntu-22.04, pkg-name: "lite", python-version: "3.10", release: "pre"} timeout-minutes: 45 @@ -86,7 +86,7 @@ jobs: working-directory: src run: | pip install pytest -q - scope=$(python -c "print('lightning/lite' if '${{matrix.pkg-name}}' == 'LAI' else 'lightning_lite')") + scope=$(python -c "print('lightning/lite' if '${{matrix.pkg-name}}' == 'lightning' else 'lightning_lite')") python -m pytest $scope # Note: This uses an internal pip API and may not always work @@ -109,7 +109,7 @@ jobs: pip list - name: Adjust tests - if: ${{ matrix.pkg-name == 'LAI' }} + if: ${{ matrix.pkg-name == 'lightning' }} run: python .actions/assistant.py copy_replace_imports --source_dir="./tests" --source_import="lightning_lite" --target_import="lightning.lite" - name: Testing Warnings @@ -120,7 +120,7 @@ jobs: run: python utilities/test_warnings.py - name: switch coverage scope - run: python -c "print('COVERAGE_SCOPE=' + str('lightning' if '${{matrix.pkg-name}}' == 'LAI' else 'lightning_lite'))" >> $GITHUB_ENV + run: python -c "print('COVERAGE_SCOPE=' + str('lightning' if '${{matrix.pkg-name}}' == 'lightning' else 'lightning_lite'))" >> $GITHUB_ENV - name: Testing Lite working-directory: tests/tests_lite diff --git a/.github/workflows/ci-pytorch-test-full.yml b/.github/workflows/ci-pytorch-test-full.yml index c9ee29a009563..813533d79a8f4 100644 --- a/.github/workflows/ci-pytorch-test-full.yml +++ b/.github/workflows/ci-pytorch-test-full.yml @@ -37,7 +37,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-20.04, windows-2022, macOS-11] - pkg-name: ["LAI", "pytorch"] # the "LAI" is for installing monolithic package + pkg-name: ["lightning", "pytorch"] # the "lightning" is for installing monolithic package python-version: ["3.8", "3.9", "3.10"] pytorch-version: ["1.9", "1.10", "1.11", "1.12"] exclude: @@ -55,14 +55,14 @@ jobs: - {pytorch-version: "1.12", python-version: "3.9"} include: # PT is set for sanity check - - {os: "macos-11", pkg-name: "LAI", python-version: "3.7", pytorch-version: "1.9", requires: "oldest"} + - {os: "macos-11", pkg-name: "lightning", python-version: "3.7", pytorch-version: "1.9", requires: "oldest"} - {os: "macos-11", pkg-name: "pytorch", python-version: "3.7", pytorch-version: "1.9", requires: "oldest"} - - {os: "ubuntu-20.04", pkg-name: "LAI", python-version: "3.7", pytorch-version: "1.9", requires: "oldest"} + - {os: "ubuntu-20.04", pkg-name: "lightning", python-version: "3.7", pytorch-version: "1.9", requires: "oldest"} - {os: "ubuntu-20.04", pkg-name: "pytorch", python-version: "3.7", pytorch-version: "1.9", requires: "oldest"} - - {os: "windows-2022", pkg-name: "LAI", python-version: "3.7", pytorch-version: "1.9", requires: "oldest"} + - {os: "windows-2022", pkg-name: "lightning", python-version: "3.7", pytorch-version: "1.9", requires: "oldest"} - {os: "windows-2022", pkg-name: "pytorch", python-version: "3.7", pytorch-version: "1.9", requires: "oldest"} # close FUTURE - - {os: "ubuntu-20.04", pkg-name: "LAI", python-version: "3.10", pytorch-version: "1.13", release: "pre"} + - {os: "ubuntu-20.04", pkg-name: "lightning", python-version: "3.10", pytorch-version: "1.13", release: "pre"} - {os: "ubuntu-20.04", pkg-name: "pytorch", python-version: "3.10", pytorch-version: "1.13", release: "pre"} timeout-minutes: 50 @@ -118,7 +118,7 @@ jobs: working-directory: ./src run: | pip install pytest -q - scope=$(python -c "print('lightning/pytorch' if '${{matrix.pkg-name}}' == 'LAI' else 'pytorch_lightning')") + scope=$(python -c "print('lightning/pytorch' if '${{matrix.pkg-name}}' == 'lightning' else 'pytorch_lightning')") python -m pytest $scope - name: Get pip cache dir @@ -167,7 +167,7 @@ jobs: python requirements/pytorch/check-avail-extras.py - name: Adjust tests - if: ${{ matrix.pkg-name == 'LAI' }} + if: ${{ matrix.pkg-name == 'lightning' }} run: python .actions/assistant.py copy_replace_imports --source_dir="./tests" --source_import="pytorch_lightning,lightning_lite" --target_import="lightning.pytorch,lightning.lite" - name: Testing Warnings @@ -178,7 +178,7 @@ jobs: run: python utilities/test_warnings.py - name: switch coverage scope - run: python -c "print('COVERAGE_SCOPE=' + str('lightning' if '${{matrix.pkg-name}}' == 'LAI' else 'pytorch_lightning'))" >> $GITHUB_ENV + run: python -c "print('COVERAGE_SCOPE=' + str('lightning' if '${{matrix.pkg-name}}' == 'lightning' else 'pytorch_lightning'))" >> $GITHUB_ENV - name: Testing PyTorch working-directory: tests/tests_pytorch From 8c5e8b27846a7c8e714e0526e8f427830aad4bab Mon Sep 17 00:00:00 2001 From: Jirka Date: Mon, 24 Oct 2022 20:51:05 +0200 Subject: [PATCH 053/104] setup --- setup.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/setup.py b/setup.py index b9680a56510cb..b400133b14da1 100755 --- a/setup.py +++ b/setup.py @@ -95,14 +95,9 @@ 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")) - if _PACKAGE_NAME == "lightning": # install just the meta package - _SETUP_TOOLS._relax_require_versions(_PATH_SRC, _PATH_REQUIRE) - elif _PACKAGE_NAME not in _PACKAGE_MAPPING: # install everything + if _PACKAGE_NAME not in _PACKAGE_MAPPING: # install everything _SETUP_TOOLS._load_aggregate_requirements(_PATH_REQUIRE, _FREEZE_REQUIREMENTS) - if _PACKAGE_NAME not in _PACKAGE_MAPPING: - _SETUP_TOOLS.set_version_today(os.path.join(_PATH_SRC, "lightning", "__version__.py")) - _SETUP_TOOLS.create_mirror_package(os.path.join(_PATH_ROOT, "src"), _PACKAGE_MAPPING) _SETUP_MODULE = _load_py_module(name="pkg_setup", location=_PATH_SETUP) From 831073aa15688ba006c050ec9ded52de076426ed Mon Sep 17 00:00:00 2001 From: Jirka Borovec Date: Mon, 24 Oct 2022 21:49:06 +0200 Subject: [PATCH 054/104] Apply suggestions from code review --- requirements/app/test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/app/test.txt b/requirements/app/test.txt index db5dec735e646..cf5df4c8297fe 100644 --- a/requirements/app/test.txt +++ b/requirements/app/test.txt @@ -3,7 +3,7 @@ codecov>=2.1, <=2.1.12 pytest>=7.0, <=7.1.2 pytest-timeout <=2.1.0 pytest-cov <=3.0.0 -playwright>=1.27.1, <1.27.2 +playwright==1.27.1 # pytest-flake8 httpx trio<0.22.0 From ccfe7f8cfe42a527786771bc08430ca139f5e800 Mon Sep 17 00:00:00 2001 From: Jirka Borovec Date: Tue, 25 Oct 2022 01:18:27 +0200 Subject: [PATCH 055/104] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Carlos Mocholí --- .actions/setup_tools.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.actions/setup_tools.py b/.actions/setup_tools.py index 15f05c11966cf..a6d794429eb34 100644 --- a/.actions/setup_tools.py +++ b/.actions/setup_tools.py @@ -179,7 +179,7 @@ def parse_version_from_file(pkg_root: str) -> str: def _replace_imports_in_file(lines: List[str], pkg_lut: Dict[str, str]) -> List[str]: - """REplace imports of standlone package to lightning. + """Replace imports of standalone package to lightning. >>> lns = ["lightning_app", ... "delete_cloud_lightning_apps", From 68fea9da1195d56d0902832552932f1e5ec115b9 Mon Sep 17 00:00:00 2001 From: Jirka Borovec Date: Tue, 25 Oct 2022 01:18:48 +0200 Subject: [PATCH 056/104] Apply suggestions from code review --- .github/workflows/ci-pkg-install.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/ci-pkg-install.yml b/.github/workflows/ci-pkg-install.yml index fdcf3bcefa939..a01d93537de3e 100644 --- a/.github/workflows/ci-pkg-install.yml +++ b/.github/workflows/ci-pkg-install.yml @@ -32,11 +32,6 @@ jobs: with: python-version: ${{ matrix.python-version }} - - name: Install pytest extensions - # TODO: for mono-package create & load requirements/test.txt - if: ${{ matrix.pkg != '' }} - run: grep 'pytest>' requirements/${{ matrix.pkg }}/test.txt | xargs -0 pip install - - name: DocTests actions working-directory: .actions/ run: | From bf375b4435c85e2976a08327a9dc712cd25a8e53 Mon Sep 17 00:00:00 2001 From: manskx Date: Tue, 25 Oct 2022 09:08:42 +0200 Subject: [PATCH 057/104] disable cache --- .azure/app-cloud-e2e.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.azure/app-cloud-e2e.yml b/.azure/app-cloud-e2e.yml index b95c938d420e4..5f40316ef0f1e 100644 --- a/.azure/app-cloud-e2e.yml +++ b/.azure/app-cloud-e2e.yml @@ -92,14 +92,14 @@ jobs: pip --version displayName: 'Info' - - task: Cache@2 - condition: ne(variables['name'], 'quick_start') - inputs: - key: 'pip | "$(name)" | requirements/app/base.txt' - restoreKeys: | - pip | "$(Agent.OS)" - path: $(pip_cache_dir) - displayName: Cache pip +# - task: Cache@2 +# condition: ne(variables['name'], 'quick_start') +# inputs: +# key: 'pip | "$(name)" | requirements/app/base.txt' +# restoreKeys: | +# pip | "$(Agent.OS)" +# path: $(pip_cache_dir) +# displayName: Cache pip - bash: git restore . && python -m pip install -e .[ui] --find-links https://download.pytorch.org/whl/cpu/torch_stable.html env: From 80dab9d8f237807cd72ac3b6b63859a20525ec95 Mon Sep 17 00:00:00 2001 From: Jirka Date: Tue, 25 Oct 2022 09:09:18 +0200 Subject: [PATCH 058/104] move doctest to install --- .github/actions/pkg-install/action.yml | 4 ++-- .github/workflows/ci-app-tests.yml | 26 ++++++++-------------- .github/workflows/ci-lite-test-full.yml | 26 ++++++---------------- .github/workflows/ci-pkg-install.yml | 7 ++++++ .github/workflows/ci-pytorch-test-full.yml | 26 ++++++---------------- 5 files changed, 32 insertions(+), 57 deletions(-) diff --git a/.github/actions/pkg-install/action.yml b/.github/actions/pkg-install/action.yml index c39d11eca460b..155c4edf99997 100644 --- a/.github/actions/pkg-install/action.yml +++ b/.github/actions/pkg-install/action.yml @@ -25,7 +25,7 @@ runs: run: echo "PKG_NAME=${{ inputs.pkg-name }}" >> $GITHUB_ENV shell: bash - - name: Install | Uninstall package - archive + - name: Install package - archive working-directory: ./dist run: | pip install *.tar.gz ${{ inputs.pip-flags }} @@ -33,7 +33,7 @@ runs: python -c "import ${PKG_NAME} ; print(${PKG_NAME}.__version__)" shell: bash - - name: Install | Uninstall package - wheel + - name: Install package - wheel working-directory: ./dist run: | pip install *.whl ${{ inputs.pip-flags }} diff --git a/.github/workflows/ci-app-tests.yml b/.github/workflows/ci-app-tests.yml index 339fc99366c04..c0afc8401e951 100644 --- a/.github/workflows/ci-app-tests.yml +++ b/.github/workflows/ci-app-tests.yml @@ -53,23 +53,6 @@ jobs: if: ${{ matrix.requires == 'oldest' }} run: python .actions/assistant.py replace_oldest_ver - - 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 package - env: - PACKAGE_NAME: ${{ matrix.pkg-name }} - run: | - pip install -e . pytest --upgrade --find-links ${TORCH_URL} - pip list - - - name: DocTests App - working-directory: src - run: | - pip install pytest -q - scope=$(python -c "print('lightning/app' if '${{matrix.pkg-name}}' == 'lightning' else 'lightning_app')") - python -m pytest $scope --ignore-glob="**/cli/*-template/**" - - name: Get pip cache id: pip-cache run: | @@ -82,6 +65,15 @@ jobs: key: ${{ runner.os }}-pip-py${{ matrix.python-version }}-${{ matrix.pkg-name }}-${{ matrix.requires }}-${{ hashFiles('requirements/app/base.txt') }} restore-keys: ${{ runner.os }}-pip-py${{ matrix.python-version }}-${{ matrix.pkg-name }}-${{ matrix.requires }}- + - 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 package + env: + PACKAGE_NAME: ${{ matrix.pkg-name }} + run: | + pip install -e . pytest --upgrade --find-links ${TORCH_URL} + pip list - name: Install dependencies env: # TODO: drop this when we will be using regular releases for testing diff --git a/.github/workflows/ci-lite-test-full.yml b/.github/workflows/ci-lite-test-full.yml index d316977833d36..53a4bf0910667 100644 --- a/.github/workflows/ci-lite-test-full.yml +++ b/.github/workflows/ci-lite-test-full.yml @@ -72,23 +72,6 @@ jobs: run: | python .actions/assistant.py replace_oldest_ver - - 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 package - env: - PACKAGE_NAME: ${{ matrix.pkg-name }} - run: | - pip install -e . pytest --upgrade --find-links ${TORCH_URL} - pip list - - - name: DocTests Lite - working-directory: src - run: | - pip install pytest -q - scope=$(python -c "print('lightning/lite' if '${{matrix.pkg-name}}' == 'lightning' else 'lightning_lite')") - python -m pytest $scope - # Note: This uses an internal pip API and may not always work # https://github.com/actions/cache/blob/master/examples.md#multiple-oss-in-a-workflow - name: Get pip cache dir @@ -103,9 +86,14 @@ jobs: restore-keys: | ${{ runner.os }}-pip-py${{ matrix.python-version }}-${{ matrix.pkg-name }}-${{ matrix.release }}-${{ matrix.requires }}- - - name: Install dependencies + - 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 package & dependencies + env: + PACKAGE_NAME: ${{ matrix.pkg-name }} run: | - pip install -r requirements/lite/devel.txt --upgrade --find-links ${TORCH_URL} + pip install -e . -r requirements/lite/devel.txt --upgrade --find-links ${TORCH_URL} pip list - name: Adjust tests diff --git a/.github/workflows/ci-pkg-install.yml b/.github/workflows/ci-pkg-install.yml index a01d93537de3e..bd94ff2676f05 100644 --- a/.github/workflows/ci-pkg-install.yml +++ b/.github/workflows/ci-pkg-install.yml @@ -49,3 +49,10 @@ jobs: - name: Run CLI if: ${{ matrix.pkg == '' }} run: python -m lightning --version + + - name: DocTests package + working-directory: src + run: | + pip install pytest -q + scope=$(python -c "lut = {'app': 'lightning', 'lite': 'lightning_lite', 'pytorch': 'pytorch_lightning'} ; print(lut.get('${{matrix.pkg-name}}', 'lightning')") + python -m pytest $scope \ No newline at end of file diff --git a/.github/workflows/ci-pytorch-test-full.yml b/.github/workflows/ci-pytorch-test-full.yml index 813533d79a8f4..6461ea1773d9d 100644 --- a/.github/workflows/ci-pytorch-test-full.yml +++ b/.github/workflows/ci-pytorch-test-full.yml @@ -104,23 +104,6 @@ jobs: python ./requirements/pytorch/adjust-versions.py requirements/pytorch/examples.txt ${{ matrix.pytorch-version }} cat requirements/pytorch/base.txt - - 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 package - env: - PACKAGE_NAME: ${{ matrix.pkg-name }} - run: | - pip install -e . --upgrade --find-links ${TORCH_URL} - pip list - - - name: DocTests PL - working-directory: ./src - run: | - pip install pytest -q - scope=$(python -c "print('lightning/pytorch' if '${{matrix.pkg-name}}' == 'lightning' else 'pytorch_lightning')") - python -m pytest $scope - - name: Get pip cache dir id: pip-cache run: echo "::set-output name=dir::$(pip cache dir)" @@ -133,9 +116,14 @@ jobs: restore-keys: | ${{ runner.os }}-pip-py${{ matrix.python-version }}-${{ matrix.pkg-name }}-${{ matrix.release }}-${{ matrix.requires }}- - - name: Install dependencies + - 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 package & dependencies + env: + PACKAGE_NAME: ${{ matrix.pkg-name }} run: | - pip install -r requirements/pytorch/devel.txt --upgrade --find-links ${TORCH_URL} + pip install -e . -r requirements/pytorch/devel.txt --upgrade --find-links ${TORCH_URL} pip list - name: Reinstall Horovod if necessary From 2ecc1d6279b4b44487dbb49b305265d7416aecee Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 25 Oct 2022 07:12:17 +0000 Subject: [PATCH 059/104] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .github/workflows/ci-pkg-install.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-pkg-install.yml b/.github/workflows/ci-pkg-install.yml index bd94ff2676f05..e6c148530bcaa 100644 --- a/.github/workflows/ci-pkg-install.yml +++ b/.github/workflows/ci-pkg-install.yml @@ -55,4 +55,4 @@ jobs: run: | pip install pytest -q scope=$(python -c "lut = {'app': 'lightning', 'lite': 'lightning_lite', 'pytorch': 'pytorch_lightning'} ; print(lut.get('${{matrix.pkg-name}}', 'lightning')") - python -m pytest $scope \ No newline at end of file + python -m pytest $scope From 79362fd6a54297d85603a7f304bd261b655540bd Mon Sep 17 00:00:00 2001 From: Jirka Date: Tue, 25 Oct 2022 09:20:04 +0200 Subject: [PATCH 060/104] ) --- .github/workflows/ci-pkg-install.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-pkg-install.yml b/.github/workflows/ci-pkg-install.yml index bd94ff2676f05..89bffb8c1e026 100644 --- a/.github/workflows/ci-pkg-install.yml +++ b/.github/workflows/ci-pkg-install.yml @@ -54,5 +54,5 @@ jobs: working-directory: src run: | pip install pytest -q - scope=$(python -c "lut = {'app': 'lightning', 'lite': 'lightning_lite', 'pytorch': 'pytorch_lightning'} ; print(lut.get('${{matrix.pkg-name}}', 'lightning')") + scope=$(python -c "lut = {'app': 'lightning', 'lite': 'lightning_lite', 'pytorch': 'pytorch_lightning'} ; print(lut.get('${{matrix.pkg-name}}', 'lightning'))") python -m pytest $scope \ No newline at end of file From 75d080b21c953bc5aeff9fbc2a2f977c41ee4c6c Mon Sep 17 00:00:00 2001 From: Jirka Date: Tue, 25 Oct 2022 09:32:34 +0200 Subject: [PATCH 061/104] echo ./ --- .github/workflows/ci-pkg-install.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci-pkg-install.yml b/.github/workflows/ci-pkg-install.yml index f44e36b6a8d0f..abd90f7e5fc83 100644 --- a/.github/workflows/ci-pkg-install.yml +++ b/.github/workflows/ci-pkg-install.yml @@ -47,12 +47,13 @@ jobs: - uses: ./.github/actions/pkg-install - name: Run CLI - if: ${{ matrix.pkg == '' }} + if: ${{ matrix.pkg == '' || matrix.pkg == 'app' }} run: python -m lightning --version - - name: DocTests package + - name: DocTest package working-directory: src run: | pip install pytest -q scope=$(python -c "lut = {'app': 'lightning', 'lite': 'lightning_lite', 'pytorch': 'pytorch_lightning'} ; print(lut.get('${{matrix.pkg-name}}', 'lightning'))") - python -m pytest $scope + echo ${scope} + python -m pytest ./${scope} From 974b58f86fa1180fa5c3dec4898e2f69c88f1bfc Mon Sep 17 00:00:00 2001 From: Jirka Date: Tue, 25 Oct 2022 10:06:02 +0200 Subject: [PATCH 062/104] ci --- .github/workflows/ci-pkg-install.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci-pkg-install.yml b/.github/workflows/ci-pkg-install.yml index abd90f7e5fc83..d5f93c3c4e9ab 100644 --- a/.github/workflows/ci-pkg-install.yml +++ b/.github/workflows/ci-pkg-install.yml @@ -47,13 +47,14 @@ jobs: - uses: ./.github/actions/pkg-install - name: Run CLI - if: ${{ matrix.pkg == '' || matrix.pkg == 'app' }} + # todo: add testing for `lightning_app` + if: ${{ matrix.pkg == '' }} run: python -m lightning --version - name: DocTest package - working-directory: src run: | - pip install pytest -q - scope=$(python -c "lut = {'app': 'lightning', 'lite': 'lightning_lite', 'pytorch': 'pytorch_lightning'} ; print(lut.get('${{matrix.pkg-name}}', 'lightning'))") + scope=$(python -c "lut = {'app': 'lightning', 'lite': 'lightning_lite', 'pytorch': 'pytorch_lightning'} ; print(lut.get('${{matrix.pkg}}', 'lightning'))") echo ${scope} - python -m pytest ./${scope} + pip install pytest -q + pip list + python -m pytest src/${scope} --ignore-glob="**/cli/*-template/**" From 5bdaeab00a044b4ef7ed30686cacd5d889c3e57b Mon Sep 17 00:00:00 2001 From: Jirka Date: Tue, 25 Oct 2022 10:28:41 +0200 Subject: [PATCH 063/104] lru --- src/lightning_app/components/database/utilities.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lightning_app/components/database/utilities.py b/src/lightning_app/components/database/utilities.py index 5edcb321dd9cc..8e34828afc37f 100644 --- a/src/lightning_app/components/database/utilities.py +++ b/src/lightning_app/components/database/utilities.py @@ -111,7 +111,7 @@ def compare_values(self, x, y): return PydanticJSONType -@functools.lru_cache +@functools.lru_cache(maxsize=128) # compatibility for py3.7 def get_primary_key(model_type: Type["SQLModel"]) -> str: primary_keys = sqlalchemy_inspect(model_type).primary_key From c6828931f395cf6040116ef4c0a70b67c35e7707 Mon Sep 17 00:00:00 2001 From: manskx Date: Tue, 25 Oct 2022 10:29:11 +0200 Subject: [PATCH 064/104] revert disabling cache, prints --- .azure/app-cloud-e2e.yml | 16 ++++++++-------- src/lightning_app/utilities/load_app.py | 3 --- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/.azure/app-cloud-e2e.yml b/.azure/app-cloud-e2e.yml index 5f40316ef0f1e..b95c938d420e4 100644 --- a/.azure/app-cloud-e2e.yml +++ b/.azure/app-cloud-e2e.yml @@ -92,14 +92,14 @@ jobs: pip --version displayName: 'Info' -# - task: Cache@2 -# condition: ne(variables['name'], 'quick_start') -# inputs: -# key: 'pip | "$(name)" | requirements/app/base.txt' -# restoreKeys: | -# pip | "$(Agent.OS)" -# path: $(pip_cache_dir) -# displayName: Cache pip + - task: Cache@2 + condition: ne(variables['name'], 'quick_start') + inputs: + key: 'pip | "$(name)" | requirements/app/base.txt' + restoreKeys: | + pip | "$(Agent.OS)" + path: $(pip_cache_dir) + displayName: Cache pip - bash: git restore . && python -m pip install -e .[ui] --find-links https://download.pytorch.org/whl/cpu/torch_stable.html env: diff --git a/src/lightning_app/utilities/load_app.py b/src/lightning_app/utilities/load_app.py index 2fc01d7159530..614944bc7e249 100644 --- a/src/lightning_app/utilities/load_app.py +++ b/src/lightning_app/utilities/load_app.py @@ -80,9 +80,6 @@ def _create_code(script_path: str): with open_python_file(script_path) as f: filebody = f.read() - logger.info(f"Loading app from {script_path}") - logger.info("code: %s", filebody) - return compile( filebody, # Pass in the file path so it can show up in exceptions. From 29aca4c3c9930cf306deebe1bc37ad42cd4c3954 Mon Sep 17 00:00:00 2001 From: Jirka Date: Tue, 25 Oct 2022 10:36:37 +0200 Subject: [PATCH 065/104] ci --- .github/workflows/ci-pkg-install.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/ci-pkg-install.yml b/.github/workflows/ci-pkg-install.yml index d5f93c3c4e9ab..2c1c30e7d2b4b 100644 --- a/.github/workflows/ci-pkg-install.yml +++ b/.github/workflows/ci-pkg-install.yml @@ -53,8 +53,6 @@ jobs: - name: DocTest package run: | - scope=$(python -c "lut = {'app': 'lightning', 'lite': 'lightning_lite', 'pytorch': 'pytorch_lightning'} ; print(lut.get('${{matrix.pkg}}', 'lightning'))") - echo ${scope} - pip install pytest -q pip list + scope=$(python -c "lut = {'app': 'lightning_app', 'lite': 'lightning_lite', 'pytorch': 'pytorch_lightning'} ; print(lut.get('${{matrix.pkg}}', 'lightning'))") python -m pytest src/${scope} --ignore-glob="**/cli/*-template/**" From f1630e0786a04952bb9f1377645391165246aaba Mon Sep 17 00:00:00 2001 From: Jirka Date: Tue, 25 Oct 2022 10:57:24 +0200 Subject: [PATCH 066/104] prune ci jobs --- .github/workflows/ci-lite-test-full.yml | 13 ++++++++++--- .github/workflows/ci-pytorch-test-full.yml | 8 +++++++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci-lite-test-full.yml b/.github/workflows/ci-lite-test-full.yml index 53a4bf0910667..9bbc81f7122a8 100644 --- a/.github/workflows/ci-lite-test-full.yml +++ b/.github/workflows/ci-lite-test-full.yml @@ -34,7 +34,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-20.04, windows-2022, macOS-11] - pkg-name: ["lite", "lightning"] # "lightning" installs the monolithic package + pkg-name: ["lite"] # "lightning" installs the monolithic package python-version: ["3.7", "3.8", "3.9", "3.10"] requires: ["oldest", "latest"] release: ["stable"] @@ -44,8 +44,15 @@ jobs: - {python-version: "3.9", requires: "oldest"} - {python-version: "3.10", requires: "oldest"} include: - - {os: ubuntu-22.04, pkg-name: "lightning", python-version: "3.10", release: "pre"} - - {os: ubuntu-22.04, pkg-name: "lite", python-version: "3.10", release: "pre"} + - {os: "macos-11", pkg-name: "lightning", python-version: "3.8", requires: "latest"} + - {os: "macos-11", pkg-name: "lightning", python-version: "3.10", requires: "latest"} + - {os: "ubuntu-20.04", pkg-name: "lightning", python-version: "3.8", requires: "latest"} + - {os: "ubuntu-20.04", pkg-name: "lightning", python-version: "3.10", requires: "latest"} + - {os: "windows-2022", pkg-name: "lightning", python-version: "3.8", requires: "latest"} + - {os: "windows-2022", pkg-name: "lightning", python-version: "3.10", requires: "latest"} + # FUTURE + - {os: "ubuntu-22.04", pkg-name: "lite", python-version: "3.10", release: "pre"} + - {os: "ubuntu-22.04", pkg-name: "lightning", python-version: "3.10", release: "pre"} timeout-minutes: 45 diff --git a/.github/workflows/ci-pytorch-test-full.yml b/.github/workflows/ci-pytorch-test-full.yml index 6461ea1773d9d..b4db1fd0b7004 100644 --- a/.github/workflows/ci-pytorch-test-full.yml +++ b/.github/workflows/ci-pytorch-test-full.yml @@ -37,7 +37,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-20.04, windows-2022, macOS-11] - pkg-name: ["lightning", "pytorch"] # the "lightning" is for installing monolithic package + pkg-name: ["pytorch"] # the "lightning" is for installing monolithic package python-version: ["3.8", "3.9", "3.10"] pytorch-version: ["1.9", "1.10", "1.11", "1.12"] exclude: @@ -54,6 +54,12 @@ jobs: - {pytorch-version: "1.12", python-version: "3.8"} - {pytorch-version: "1.12", python-version: "3.9"} include: + - {os: "macos-11", pkg-name: "lightning", python-version: "3.8", pytorch-version: "1.10"} + - {os: "macos-11", pkg-name: "lightning", python-version: "3.10", pytorch-version: "1.12"} + - {os: "ubuntu-20.04", pkg-name: "lightning", python-version: "3.8", pytorch-version: "1.10"} + - {os: "ubuntu-20.04", pkg-name: "lightning", python-version: "3.10", pytorch-version: "1.12"} + - {os: "windows-2022", pkg-name: "lightning", python-version: "3.8", pytorch-version: "1.10"} + - {os: "windows-2022", pkg-name: "lightning", python-version: "3.10", pytorch-version: "1.12"} # PT is set for sanity check - {os: "macos-11", pkg-name: "lightning", python-version: "3.7", pytorch-version: "1.9", requires: "oldest"} - {os: "macos-11", pkg-name: "pytorch", python-version: "3.7", pytorch-version: "1.9", requires: "oldest"} From 5f2b739afea567462ba57a351cbb59d777229ed3 Mon Sep 17 00:00:00 2001 From: Jirka Date: Tue, 25 Oct 2022 11:05:13 +0200 Subject: [PATCH 067/104] prune ci jobs --- .github/workflows/ci-app-examples.yml | 6 +++++- .github/workflows/ci-app-tests.yml | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-app-examples.yml b/.github/workflows/ci-app-examples.yml index 3a4f3799a0d0b..0381c013486d0 100644 --- a/.github/workflows/ci-app-examples.yml +++ b/.github/workflows/ci-app-examples.yml @@ -32,9 +32,13 @@ jobs: fail-fast: false matrix: os: [ubuntu-20.04, macOS-11, windows-2022] - pkg-name: ["lightning", "app"] # the "lightning" is for installing monolithic package + pkg-name: ["app"] # the "lightning" is for installing monolithic package python-version: ["3.9"] requires: ["oldest", "latest"] + include: + - {os: "macos-11", pkg-name: "lightning", python-version: "3.10", requires: "latest"} + - {os: "ubuntu-20.04", pkg-name: "lightning", python-version: "3.10", requires: "latest"} + - {os: "windows-2022", pkg-name: "lightning", python-version: "3.10", requires: "latest"} # Timeout: https://stackoverflow.com/a/59076067/4521646 timeout-minutes: 10 diff --git a/.github/workflows/ci-app-tests.yml b/.github/workflows/ci-app-tests.yml index c0afc8401e951..1e7d6d642aa36 100644 --- a/.github/workflows/ci-app-tests.yml +++ b/.github/workflows/ci-app-tests.yml @@ -32,9 +32,13 @@ jobs: fail-fast: false matrix: os: [ubuntu-20.04, macOS-11, windows-2022] - pkg-name: ["lightning", "app"] # the "lightning" is for installing monolithic package + pkg-name: ["app"] # the "lightning" is for installing monolithic package python-version: ["3.8"] requires: ["oldest", "latest"] + include: + - {os: "macos-11", pkg-name: "lightning", python-version: "3.9", requires: "latest"} + - {os: "ubuntu-20.04", pkg-name: "lightning", python-version: "3.9", requires: "latest"} + - {os: "windows-2022", pkg-name: "lightning", python-version: "3.9", requires: "latest"} # Timeout: https://stackoverflow.com/a/59076067/4521646 timeout-minutes: 25 From 69756afed333cdb072d3254bf11a9a7c2403bb17 Mon Sep 17 00:00:00 2001 From: Justus Schock Date: Tue, 25 Oct 2022 11:19:53 +0200 Subject: [PATCH 068/104] training loop standalone tests --- tests/tests_pytorch/loops/test_training_loop.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/tests_pytorch/loops/test_training_loop.py b/tests/tests_pytorch/loops/test_training_loop.py index dc52a08f068ae..203bcf38c6f30 100644 --- a/tests/tests_pytorch/loops/test_training_loop.py +++ b/tests/tests_pytorch/loops/test_training_loop.py @@ -20,6 +20,7 @@ from pytorch_lightning import seed_everything, Trainer from pytorch_lightning.demos.boring_classes import BoringModel from pytorch_lightning.loops import FitLoop +from tests_pytorch.helpers.runif import RunIf def test_outputs_format(tmpdir): @@ -140,6 +141,7 @@ def validation_step(self, *args): assert model.validation_called_at == (0, 5) +@RunIf(standalone=True) def test_fit_loop_done_log_messages(caplog): fit_loop = FitLoop(max_epochs=1) trainer = Mock(spec=Trainer) @@ -210,6 +212,7 @@ def training_step_end(self, outputs): (4, 10, 4, True, True, True), ], ) +@RunIf(standalone=True) def test_should_stop_early_stopping_conditions_met( caplog, min_epochs, min_steps, current_epoch, early_stop, fit_loop_done, raise_debug_msg ): From fb10b19220ae151d3955f27220c578606078fafb Mon Sep 17 00:00:00 2001 From: Justus Schock Date: Tue, 25 Oct 2022 15:55:23 +0200 Subject: [PATCH 069/104] add sys modules cleanup fixture --- tests/tests_pytorch/conftest.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/tests_pytorch/conftest.py b/tests/tests_pytorch/conftest.py index 5d8616ad00657..3047ebdd61360 100644 --- a/tests/tests_pytorch/conftest.py +++ b/tests/tests_pytorch/conftest.py @@ -30,6 +30,16 @@ from tests_pytorch import _PATH_DATASETS +@pytest.fixture +def sys_modules_cleanup(): + yield + import sys + + for key in list(sys.modules.keys()): + if key.startswith("pytorch_lightning") or key.startswith("lightning"): + sys.modules.pop(key) + + @pytest.fixture(scope="session") def datadir(): return Path(_PATH_DATASETS) @@ -198,7 +208,7 @@ def caplog(caplog): propagation_dict = { name: logging.getLogger(name).propagate for name in logging.root.manager.loggerDict - if name.startswith("pytorch_lightning") + if name.startswith("lightning.pytorch") } for name in propagation_dict.keys(): logging.getLogger(name).propagate = True From c15efdd205da2353187275a8d3da141d0ec0ec0a Mon Sep 17 00:00:00 2001 From: Justus Schock Date: Tue, 25 Oct 2022 15:56:29 +0200 Subject: [PATCH 070/104] make use of fixture --- .../checkpointing/test_legacy_checkpoints.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/tests_pytorch/checkpointing/test_legacy_checkpoints.py b/tests/tests_pytorch/checkpointing/test_legacy_checkpoints.py index 316381e61d4d8..4bd7479093616 100644 --- a/tests/tests_pytorch/checkpointing/test_legacy_checkpoints.py +++ b/tests/tests_pytorch/checkpointing/test_legacy_checkpoints.py @@ -32,7 +32,7 @@ @pytest.mark.parametrize("pl_version", LEGACY_BACK_COMPATIBLE_PL_VERSIONS) -def test_load_legacy_checkpoints(tmpdir, pl_version: str): +def test_load_legacy_checkpoints(tmpdir, sys_modules_cleanup, pl_version: str): PATH_LEGACY = os.path.join(LEGACY_CHECKPOINTS_PATH, pl_version) with patch("sys.path", [PATH_LEGACY] + sys.path): from simple_classif_training import ClassifDataModule, ClassificationModel @@ -62,11 +62,11 @@ def on_train_epoch_start(self, trainer: "pl.Trainer", pl_module: "pl.LightningMo @pytest.mark.parametrize("pl_version", LEGACY_BACK_COMPATIBLE_PL_VERSIONS) -def test_legacy_ckpt_threading(tmpdir, pl_version: str): +def test_legacy_ckpt_threading(tmpdir, sys_modules_cleanup, pl_version: str): def load_model(): import torch - from pytorch_lightning.utilities.migration import pl_legacy_patch + from lightning.pytorch.utilities.migration import pl_legacy_patch with pl_legacy_patch(): _ = torch.load(PATH_LEGACY) @@ -84,7 +84,7 @@ def load_model(): @pytest.mark.parametrize("pl_version", LEGACY_BACK_COMPATIBLE_PL_VERSIONS) -def test_resume_legacy_checkpoints(tmpdir, pl_version: str): +def test_resume_legacy_checkpoints(tmpdir, sys_modules_cleanup, pl_version: str): PATH_LEGACY = os.path.join(LEGACY_CHECKPOINTS_PATH, pl_version) with patch("sys.path", [PATH_LEGACY] + sys.path): from simple_classif_training import ClassifDataModule, ClassificationModel From 146599afd8c79f07f4b19b062194b5163a399760 Mon Sep 17 00:00:00 2001 From: Justus Schock Date: Tue, 25 Oct 2022 15:59:14 +0200 Subject: [PATCH 071/104] revert standalone --- tests/tests_pytorch/loops/test_training_loop.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/tests_pytorch/loops/test_training_loop.py b/tests/tests_pytorch/loops/test_training_loop.py index 203bcf38c6f30..dc52a08f068ae 100644 --- a/tests/tests_pytorch/loops/test_training_loop.py +++ b/tests/tests_pytorch/loops/test_training_loop.py @@ -20,7 +20,6 @@ from pytorch_lightning import seed_everything, Trainer from pytorch_lightning.demos.boring_classes import BoringModel from pytorch_lightning.loops import FitLoop -from tests_pytorch.helpers.runif import RunIf def test_outputs_format(tmpdir): @@ -141,7 +140,6 @@ def validation_step(self, *args): assert model.validation_called_at == (0, 5) -@RunIf(standalone=True) def test_fit_loop_done_log_messages(caplog): fit_loop = FitLoop(max_epochs=1) trainer = Mock(spec=Trainer) @@ -212,7 +210,6 @@ def training_step_end(self, outputs): (4, 10, 4, True, True, True), ], ) -@RunIf(standalone=True) def test_should_stop_early_stopping_conditions_met( caplog, min_epochs, min_steps, current_epoch, early_stop, fit_loop_done, raise_debug_msg ): From 9297fd7209fcd8938bf7f46d740f3697f4a1fccb Mon Sep 17 00:00:00 2001 From: Jirka Date: Tue, 25 Oct 2022 16:09:13 +0200 Subject: [PATCH 072/104] ci e2e --- .azure/app-cloud-e2e.yml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/.azure/app-cloud-e2e.yml b/.azure/app-cloud-e2e.yml index f271f5181e430..c8ad74d0fd182 100644 --- a/.azure/app-cloud-e2e.yml +++ b/.azure/app-cloud-e2e.yml @@ -101,6 +101,7 @@ jobs: path: $(pip_cache_dir) displayName: Cache pip + # TODO: we are testing it as `lightning`, so add also version for `lightning_app` - bash: git restore . && python -m pip install -e . -r requirements/app/test.txt -r requirements/app/ui.txt --find-links https://download.pytorch.org/whl/cpu/torch_stable.html displayName: 'Install Lightning & dependencies' @@ -126,14 +127,6 @@ jobs: condition: eq(variables['name'], 'quick_start') displayName: 'Install Quick Start' - - bash: python -m pip install -q -r .actions/requirements.txt - displayName: 'Install assistant dependencies' - - - bash: | - 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" - displayName: 'Adjust examples' - - bash: | pip --version pip list From 5a2acb045aae52419b8bc70be79adbe4faa63dc1 Mon Sep 17 00:00:00 2001 From: manskx Date: Tue, 25 Oct 2022 17:15:10 +0200 Subject: [PATCH 073/104] fix imports in lightning --- .azure/app-cloud-e2e.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.azure/app-cloud-e2e.yml b/.azure/app-cloud-e2e.yml index c8ad74d0fd182..43aae8be2ec8b 100644 --- a/.azure/app-cloud-e2e.yml +++ b/.azure/app-cloud-e2e.yml @@ -127,6 +127,16 @@ jobs: condition: eq(variables['name'], 'quick_start') displayName: 'Install Quick Start' + - bash: python -m pip install -q -r .actions/requirements.txt + displayName: 'Install assistant dependencies' + + # Fix imports to use `lightning` instead of `lightning_app` since we install lightning only ATM + # TODO: fixme when installing `lightning_app` as well + - bash: | + 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_app" --target_import="lightning" + displayName: 'Adjust examples' + - bash: | pip --version pip list From fec212a2d727e19dfd6c1767adc5f332b9ac36d4 Mon Sep 17 00:00:00 2001 From: manskx Date: Tue, 25 Oct 2022 17:50:27 +0200 Subject: [PATCH 074/104] fix imports of lightning in tests --- .azure/app-cloud-e2e.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.azure/app-cloud-e2e.yml b/.azure/app-cloud-e2e.yml index 43aae8be2ec8b..7d87f25d839f3 100644 --- a/.azure/app-cloud-e2e.yml +++ b/.azure/app-cloud-e2e.yml @@ -134,7 +134,7 @@ jobs: # TODO: fixme when installing `lightning_app` as well - bash: | 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_app" --target_import="lightning" + python .actions/assistant.py copy_replace_imports --source_dir="./tests" --source_import="lightning_app" --target_import="lightning.app" displayName: 'Adjust examples' - bash: | From 6c24a20cfc5f15978f08abf652061c3d0176b8ae Mon Sep 17 00:00:00 2001 From: Justus Schock Date: Tue, 25 Oct 2022 15:56:29 +0200 Subject: [PATCH 075/104] Revert "make use of fixture" This reverts commit c15efdd205da2353187275a8d3da141d0ec0ec0a. --- .../checkpointing/test_legacy_checkpoints.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/tests_pytorch/checkpointing/test_legacy_checkpoints.py b/tests/tests_pytorch/checkpointing/test_legacy_checkpoints.py index 4bd7479093616..316381e61d4d8 100644 --- a/tests/tests_pytorch/checkpointing/test_legacy_checkpoints.py +++ b/tests/tests_pytorch/checkpointing/test_legacy_checkpoints.py @@ -32,7 +32,7 @@ @pytest.mark.parametrize("pl_version", LEGACY_BACK_COMPATIBLE_PL_VERSIONS) -def test_load_legacy_checkpoints(tmpdir, sys_modules_cleanup, pl_version: str): +def test_load_legacy_checkpoints(tmpdir, pl_version: str): PATH_LEGACY = os.path.join(LEGACY_CHECKPOINTS_PATH, pl_version) with patch("sys.path", [PATH_LEGACY] + sys.path): from simple_classif_training import ClassifDataModule, ClassificationModel @@ -62,11 +62,11 @@ def on_train_epoch_start(self, trainer: "pl.Trainer", pl_module: "pl.LightningMo @pytest.mark.parametrize("pl_version", LEGACY_BACK_COMPATIBLE_PL_VERSIONS) -def test_legacy_ckpt_threading(tmpdir, sys_modules_cleanup, pl_version: str): +def test_legacy_ckpt_threading(tmpdir, pl_version: str): def load_model(): import torch - from lightning.pytorch.utilities.migration import pl_legacy_patch + from pytorch_lightning.utilities.migration import pl_legacy_patch with pl_legacy_patch(): _ = torch.load(PATH_LEGACY) @@ -84,7 +84,7 @@ def load_model(): @pytest.mark.parametrize("pl_version", LEGACY_BACK_COMPATIBLE_PL_VERSIONS) -def test_resume_legacy_checkpoints(tmpdir, sys_modules_cleanup, pl_version: str): +def test_resume_legacy_checkpoints(tmpdir, pl_version: str): PATH_LEGACY = os.path.join(LEGACY_CHECKPOINTS_PATH, pl_version) with patch("sys.path", [PATH_LEGACY] + sys.path): from simple_classif_training import ClassifDataModule, ClassificationModel From f4bcd48cf8718a913f858dcbf64b14e755063ef7 Mon Sep 17 00:00:00 2001 From: Justus Schock Date: Tue, 25 Oct 2022 18:46:55 +0200 Subject: [PATCH 076/104] Revert other commits for fixtures --- tests/tests_pytorch/conftest.py | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/tests/tests_pytorch/conftest.py b/tests/tests_pytorch/conftest.py index 3047ebdd61360..5d8616ad00657 100644 --- a/tests/tests_pytorch/conftest.py +++ b/tests/tests_pytorch/conftest.py @@ -30,16 +30,6 @@ from tests_pytorch import _PATH_DATASETS -@pytest.fixture -def sys_modules_cleanup(): - yield - import sys - - for key in list(sys.modules.keys()): - if key.startswith("pytorch_lightning") or key.startswith("lightning"): - sys.modules.pop(key) - - @pytest.fixture(scope="session") def datadir(): return Path(_PATH_DATASETS) @@ -208,7 +198,7 @@ def caplog(caplog): propagation_dict = { name: logging.getLogger(name).propagate for name in logging.root.manager.loggerDict - if name.startswith("lightning.pytorch") + if name.startswith("pytorch_lightning") } for name in propagation_dict.keys(): logging.getLogger(name).propagate = True From 12cbf7b008594254a5849f9857cfda9175680b0b Mon Sep 17 00:00:00 2001 From: Justus Schock Date: Tue, 25 Oct 2022 18:47:40 +0200 Subject: [PATCH 077/104] revert use of fixture --- tests/tests_pytorch/loops/test_training_loop.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/tests_pytorch/loops/test_training_loop.py b/tests/tests_pytorch/loops/test_training_loop.py index dc52a08f068ae..203bcf38c6f30 100644 --- a/tests/tests_pytorch/loops/test_training_loop.py +++ b/tests/tests_pytorch/loops/test_training_loop.py @@ -20,6 +20,7 @@ from pytorch_lightning import seed_everything, Trainer from pytorch_lightning.demos.boring_classes import BoringModel from pytorch_lightning.loops import FitLoop +from tests_pytorch.helpers.runif import RunIf def test_outputs_format(tmpdir): @@ -140,6 +141,7 @@ def validation_step(self, *args): assert model.validation_called_at == (0, 5) +@RunIf(standalone=True) def test_fit_loop_done_log_messages(caplog): fit_loop = FitLoop(max_epochs=1) trainer = Mock(spec=Trainer) @@ -210,6 +212,7 @@ def training_step_end(self, outputs): (4, 10, 4, True, True, True), ], ) +@RunIf(standalone=True) def test_should_stop_early_stopping_conditions_met( caplog, min_epochs, min_steps, current_epoch, early_stop, fit_loop_done, raise_debug_msg ): From 51a5a14cc04b065fff085166b1ee5dc76a82a234 Mon Sep 17 00:00:00 2001 From: Jirka Date: Tue, 25 Oct 2022 21:12:01 +0200 Subject: [PATCH 078/104] py3.9 --- .github/workflows/ci-app-examples.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci-app-examples.yml b/.github/workflows/ci-app-examples.yml index 0381c013486d0..29c45b78034e3 100644 --- a/.github/workflows/ci-app-examples.yml +++ b/.github/workflows/ci-app-examples.yml @@ -36,9 +36,9 @@ jobs: python-version: ["3.9"] requires: ["oldest", "latest"] include: - - {os: "macos-11", pkg-name: "lightning", python-version: "3.10", requires: "latest"} - - {os: "ubuntu-20.04", pkg-name: "lightning", python-version: "3.10", requires: "latest"} - - {os: "windows-2022", pkg-name: "lightning", python-version: "3.10", requires: "latest"} + - {os: "macos-11", pkg-name: "lightning", python-version: "3.9", requires: "latest"} + - {os: "ubuntu-20.04", pkg-name: "lightning", python-version: "3.9", requires: "latest"} + - {os: "windows-2022", pkg-name: "lightning", python-version: "3.9", requires: "latest"} # Timeout: https://stackoverflow.com/a/59076067/4521646 timeout-minutes: 10 From 43b48bef18ce80144fc1f7cd9dab576f06fe5c31 Mon Sep 17 00:00:00 2001 From: Jirka Date: Tue, 25 Oct 2022 21:24:06 +0200 Subject: [PATCH 079/104] fix mocking --- src/lightning_app/testing/testing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lightning_app/testing/testing.py b/src/lightning_app/testing/testing.py index df1504b728448..690eb2458e9b6 100644 --- a/src/lightning_app/testing/testing.py +++ b/src/lightning_app/testing/testing.py @@ -136,7 +136,7 @@ def application_testing( from click.testing import CliRunner - with mock.patch("lightning_app.LightningApp", lightning_app_cls): + with mock.patch("LightningApp", lightning_app_cls): original = sys.argv sys.argv = command_line runner = CliRunner() From 1089c2a6733612717f6550eddfdb5220ff856442 Mon Sep 17 00:00:00 2001 From: Jirka Date: Tue, 25 Oct 2022 21:46:04 +0200 Subject: [PATCH 080/104] fix paths --- tests/tests_app/utilities/packaging/test_build_spec.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/tests_app/utilities/packaging/test_build_spec.py b/tests/tests_app/utilities/packaging/test_build_spec.py index 4d3855d6f9645..e1b9466dc0806 100644 --- a/tests/tests_app/utilities/packaging/test_build_spec.py +++ b/tests/tests_app/utilities/packaging/test_build_spec.py @@ -1,7 +1,7 @@ import os import sys -from tests_app import _PROJECT_ROOT +from tests_app import _TESTS_ROOT from lightning_app.testing import application_testing, LightningTestApp from lightning_app.utilities.packaging.build_config import BuildConfig @@ -17,7 +17,7 @@ def on_after_run_once(self): def test_build_config_no_requirements(): - command_line = [os.path.join(_PROJECT_ROOT, "tests/utilities/packaging/projects/no_req/app.py")] + command_line = [os.path.join(_TESTS_ROOT, "utilities/packaging/projects/no_req/app.py")] application_testing(NoRequirementsLightningTestApp, command_line + EXTRAS_ARGS) sys.path = sys.path[:-1] @@ -60,7 +60,7 @@ def on_after_run_once(self): def test_build_config_dockerfile(): - command_line = [os.path.join(_PROJECT_ROOT, "tests/utilities/packaging/projects/dockerfile/app.py")] + command_line = [os.path.join(_TESTS_ROOT, "utilities/packaging/projects/dockerfile/app.py")] application_testing(DockerfileLightningTestApp, command_line + EXTRAS_ARGS) sys.path = sys.path[:-1] @@ -76,6 +76,6 @@ def on_after_run_once(self): def test_build_config_requirements(): - command_line = [os.path.join(_PROJECT_ROOT, "tests/utilities/packaging/projects/req/app.py")] + command_line = [os.path.join(_TESTS_ROOT, "utilities/packaging/projects/req/app.py")] application_testing(RequirementsLightningTestApp, command_line + EXTRAS_ARGS) sys.path = sys.path[:-1] From d4b0b1ed05a383445ceea2f47f012630dd2842a9 Mon Sep 17 00:00:00 2001 From: Jirka Date: Tue, 25 Oct 2022 22:02:17 +0200 Subject: [PATCH 081/104] hack mocking --- src/lightning_app/testing/testing.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lightning_app/testing/testing.py b/src/lightning_app/testing/testing.py index 690eb2458e9b6..7cb06602ba80f 100644 --- a/src/lightning_app/testing/testing.py +++ b/src/lightning_app/testing/testing.py @@ -136,7 +136,9 @@ def application_testing( from click.testing import CliRunner - with mock.patch("LightningApp", lightning_app_cls): + with mock.patch("lightning.LightningApp", lightning_app_cls), mock.patch( + "lightning_app.LightningApp", lightning_app_cls + ): original = sys.argv sys.argv = command_line runner = CliRunner() From 11635ae02c09f27d3cf0876d6df964ec34175791 Mon Sep 17 00:00:00 2001 From: Jirka Date: Tue, 25 Oct 2022 22:20:16 +0200 Subject: [PATCH 082/104] docs --- docs/source-lit/conf.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/source-lit/conf.py b/docs/source-lit/conf.py index 5d6a2e54b7675..d5dd5e242ec6c 100644 --- a/docs/source-lit/conf.py +++ b/docs/source-lit/conf.py @@ -401,17 +401,17 @@ def find_source(): import lightning.pytorch as pl from torch import nn from torch.utils.data import IterableDataset, DataLoader, Dataset -from pytorch.lightning import LightningDataModule, LightningModule, Trainer, seed_everything -from pytorch.lightning.callbacks import Callback -from pytorch.lightning.cli import _JSONARGPARSE_SIGNATURES_AVAILABLE as _JSONARGPARSE_AVAILABLE -from pytorch.lightning.utilities import ( +from lightning.pytorch import LightningDataModule, LightningModule, Trainer, seed_everything +from lightning.pytorch.callbacks import Callback +from lightning.pytorch.cli import _JSONARGPARSE_SIGNATURES_AVAILABLE as _JSONARGPARSE_AVAILABLE +from lightning.pytorch.utilities import ( _APEX_AVAILABLE, _TORCHVISION_AVAILABLE, _TORCH_GREATER_EQUAL_1_10, ) -from pytorch.lightning.loggers.neptune import _NEPTUNE_AVAILABLE -from pytorch.lightning.loggers.comet import _COMET_AVAILABLE -from pytorch.lightning.loggers.mlflow import _MLFLOW_AVAILABLE -from pytorch.lightning.loggers.wandb import _WANDB_AVAILABLE +from lightning.pytorch.loggers.neptune import _NEPTUNE_AVAILABLE +from lightning.pytorch.loggers.comet import _COMET_AVAILABLE +from lightning.pytorch.loggers.mlflow import _MLFLOW_AVAILABLE +from lightning.pytorch.loggers.wandb import _WANDB_AVAILABLE """ coverage_skip_undoc_in_source = True From 01e45b94e308f5b5cf8e98a39f4c24e2294ecb51 Mon Sep 17 00:00:00 2001 From: Jirka Borovec Date: Tue, 25 Oct 2022 22:22:17 +0200 Subject: [PATCH 083/104] Apply suggestions from code review --- tests/tests_app_examples/test_argparse.py | 1 - tests/tests_pytorch/loops/test_training_loop.py | 2 -- 2 files changed, 3 deletions(-) diff --git a/tests/tests_app_examples/test_argparse.py b/tests/tests_app_examples/test_argparse.py index ddc0f51799467..7d34b7d0c00f3 100644 --- a/tests/tests_app_examples/test_argparse.py +++ b/tests/tests_app_examples/test_argparse.py @@ -16,7 +16,6 @@ def test_app_argparse_example(): "--without-server", ] result = application_testing(command_line=command_line) - print(result.stdout) assert result.exit_code == 0, result.__dict__ assert sys.argv == original_argv diff --git a/tests/tests_pytorch/loops/test_training_loop.py b/tests/tests_pytorch/loops/test_training_loop.py index 203bcf38c6f30..56f1c82dd1068 100644 --- a/tests/tests_pytorch/loops/test_training_loop.py +++ b/tests/tests_pytorch/loops/test_training_loop.py @@ -141,7 +141,6 @@ def validation_step(self, *args): assert model.validation_called_at == (0, 5) -@RunIf(standalone=True) def test_fit_loop_done_log_messages(caplog): fit_loop = FitLoop(max_epochs=1) trainer = Mock(spec=Trainer) @@ -212,7 +211,6 @@ def training_step_end(self, outputs): (4, 10, 4, True, True, True), ], ) -@RunIf(standalone=True) def test_should_stop_early_stopping_conditions_met( caplog, min_epochs, min_steps, current_epoch, early_stop, fit_loop_done, raise_debug_msg ): From 0fd1be6baef34c011357e02f170f26e78dbe87ef Mon Sep 17 00:00:00 2001 From: Jirka Date: Tue, 25 Oct 2022 23:02:08 +0200 Subject: [PATCH 084/104] rev suggestion --- tests/tests_pytorch/loops/test_training_loop.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/tests_pytorch/loops/test_training_loop.py b/tests/tests_pytorch/loops/test_training_loop.py index 56f1c82dd1068..203bcf38c6f30 100644 --- a/tests/tests_pytorch/loops/test_training_loop.py +++ b/tests/tests_pytorch/loops/test_training_loop.py @@ -141,6 +141,7 @@ def validation_step(self, *args): assert model.validation_called_at == (0, 5) +@RunIf(standalone=True) def test_fit_loop_done_log_messages(caplog): fit_loop = FitLoop(max_epochs=1) trainer = Mock(spec=Trainer) @@ -211,6 +212,7 @@ def training_step_end(self, outputs): (4, 10, 4, True, True, True), ], ) +@RunIf(standalone=True) def test_should_stop_early_stopping_conditions_met( caplog, min_epochs, min_steps, current_epoch, early_stop, fit_loop_done, raise_debug_msg ): From 3b7607a5779aa561e25530b3cff21aa696ae086b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mochol=C3=AD?= Date: Wed, 26 Oct 2022 02:55:59 +0200 Subject: [PATCH 085/104] Minor changes to the parametrizations --- .github/workflows/ci-app-examples.yml | 5 +++-- .github/workflows/ci-app-tests.yml | 5 +++-- .github/workflows/ci-lite-test-full.yml | 13 ++++++++----- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci-app-examples.yml b/.github/workflows/ci-app-examples.yml index 29c45b78034e3..b2c05a65fa8e4 100644 --- a/.github/workflows/ci-app-examples.yml +++ b/.github/workflows/ci-app-examples.yml @@ -32,11 +32,12 @@ jobs: fail-fast: false matrix: os: [ubuntu-20.04, macOS-11, windows-2022] - pkg-name: ["app"] # the "lightning" is for installing monolithic package + pkg-name: ["app"] python-version: ["3.9"] requires: ["oldest", "latest"] include: - - {os: "macos-11", pkg-name: "lightning", python-version: "3.9", requires: "latest"} + # "lightning" installs the monolithic package + - {os: "macOS-11", pkg-name: "lightning", python-version: "3.9", requires: "latest"} - {os: "ubuntu-20.04", pkg-name: "lightning", python-version: "3.9", requires: "latest"} - {os: "windows-2022", pkg-name: "lightning", python-version: "3.9", requires: "latest"} diff --git a/.github/workflows/ci-app-tests.yml b/.github/workflows/ci-app-tests.yml index 1e7d6d642aa36..848d83c85cc69 100644 --- a/.github/workflows/ci-app-tests.yml +++ b/.github/workflows/ci-app-tests.yml @@ -32,11 +32,12 @@ jobs: fail-fast: false matrix: os: [ubuntu-20.04, macOS-11, windows-2022] - pkg-name: ["app"] # the "lightning" is for installing monolithic package + pkg-name: ["app"] python-version: ["3.8"] requires: ["oldest", "latest"] include: - - {os: "macos-11", pkg-name: "lightning", python-version: "3.9", requires: "latest"} + # "lightning" installs the monolithic package + - {os: "macOS-11", pkg-name: "lightning", python-version: "3.9", requires: "latest"} - {os: "ubuntu-20.04", pkg-name: "lightning", python-version: "3.9", requires: "latest"} - {os: "windows-2022", pkg-name: "lightning", python-version: "3.9", requires: "latest"} diff --git a/.github/workflows/ci-lite-test-full.yml b/.github/workflows/ci-lite-test-full.yml index 79c154cf3fba9..1e53fba2d0d1a 100644 --- a/.github/workflows/ci-lite-test-full.yml +++ b/.github/workflows/ci-lite-test-full.yml @@ -34,7 +34,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-20.04, windows-2022, macOS-11] - pkg-name: ["lite"] # "lightning" installs the monolithic package + pkg-name: ["lite"] python-version: ["3.7", "3.8", "3.9", "3.10"] requires: ["oldest", "latest"] release: ["stable"] @@ -44,14 +44,17 @@ jobs: - {python-version: "3.9", requires: "oldest"} - {python-version: "3.10", requires: "oldest"} include: - - {os: "macos-11", pkg-name: "lightning", python-version: "3.8", requires: "latest"} - - {os: "macos-11", pkg-name: "lightning", python-version: "3.10", requires: "latest"} + # release-candidate tests, mixed Python versions + - {os: "macOS-11", pkg-name: "pytorch", python-version: "3.10", release: "pre"} + - {os: "ubuntu-20.04", pkg-name: "pytorch", python-version: "3.9", release: "pre"} + - {os: "windows-2022", pkg-name: "pytorch", python-version: "3.8", release": "pre"} + # "lightning" installs the monolithic package + - {os: "macOS-11", pkg-name: "lightning", python-version: "3.8", requires: "latest"} + - {os: "macOS-11", pkg-name: "lightning", python-version: "3.10", requires: "latest"} - {os: "ubuntu-20.04", pkg-name: "lightning", python-version: "3.8", requires: "latest"} - {os: "ubuntu-20.04", pkg-name: "lightning", python-version: "3.10", requires: "latest"} - {os: "windows-2022", pkg-name: "lightning", python-version: "3.8", requires: "latest"} - {os: "windows-2022", pkg-name: "lightning", python-version: "3.10", requires: "latest"} - # FUTURE - - {os: "ubuntu-22.04", pkg-name: "lite", python-version: "3.10", release: "pre"} - {os: "ubuntu-22.04", pkg-name: "lightning", python-version: "3.10", release: "pre"} timeout-minutes: 45 From 150d5eba6bea5dcdafc128f7a6cfb35b1c1784e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mochol=C3=AD?= Date: Wed, 26 Oct 2022 03:11:12 +0200 Subject: [PATCH 086/104] Update checkgroup with the new and changed jobs --- .github/checkgroup.yml | 68 +++++++++++++++++++--- .github/workflows/ci-pytorch-test-full.yml | 2 +- 2 files changed, 60 insertions(+), 10 deletions(-) diff --git a/.github/checkgroup.yml b/.github/checkgroup.yml index e74feee781dc4..530e6f7f457c4 100644 --- a/.github/checkgroup.yml +++ b/.github/checkgroup.yml @@ -28,15 +28,21 @@ subprojects: - "pl-cpu (macOS-11, pytorch, 3.9, 1.11)" - "pl-cpu (macOS-11, pytorch, 3.8, 1.10)" - "pl-cpu (windows-2022, pytorch, 3.10, 1.11)" - - "pl-cpu (windows.2022, pytorch, 3.9, 1.10)" + - "pl-cpu (windows-2022, pytorch, 3.9, 1.10)" - "pl-cpu (windows-2022, pytorch, 3.8, 1.9)" - "pl-cpu (ubuntu-20.04, pytorch, 3.8, 1.11)" - "pl-cpu (macOS-11, pytorch, 3.10, 1.12)" + - "pl-cpu (macOS-11, lightning, 3.10, 1.12)" - "pl-cpu (ubuntu-20.04, pytorch, 3.10, 1.12)" + - "pl-cpu (ubuntu-20.04, lightning, 3.10, 1.12)" - "pl-cpu (windows-2022, pytorch, 3.10, 1.12)" + - "pl-cpu (windows-2022, lightning, 3.10, 1.12)" - "pl-cpu (macOS-11, pytorch, 3.7, 1.9, oldest)" + - "pl-cpu (macOS-11, lightning, 3.7, 1.9, oldest)" - "pl-cpu (ubuntu-20.04, pytorch, 3.7, 1.9, oldest)" + - "pl-cpu (ubuntu-20.04, lightning, 3.7, 1.9, oldest)" - "pl-cpu (windows-2022, pytorch, 3.7, 1.9, oldest)" + - "pl-cpu (windows-2022, lighting, 3.7, 1.9, oldest)" - "pl-cpu (macOS-11, pytorch, 3.10, 1.13, pre)" - "pl-cpu (ubuntu-20.04, pytorch, 3.9, 1.13, pre)" - "pl-cpu (windows-2022, pytorch, 3.8, 1.13, pre)" @@ -59,15 +65,21 @@ subprojects: - "pl-cpu (macOS-11, pytorch, 3.9, 1.11)" - "pl-cpu (macOS-11, pytorch, 3.8, 1.10)" - "pl-cpu (windows-2022, pytorch, 3.10, 1.11)" - - "pl-cpu (windows.2022, pytorch, 3.9, 1.10)" + - "pl-cpu (windows-2022, pytorch, 3.9, 1.10)" - "pl-cpu (windows-2022, pytorch, 3.8, 1.9)" - "pl-cpu (ubuntu-20.04, pytorch, 3.8, 1.11)" - "pl-cpu (macOS-11, pytorch, 3.10, 1.12)" + - "pl-cpu (macOS-11, lightning, 3.10, 1.12)" - "pl-cpu (ubuntu-20.04, pytorch, 3.10, 1.12)" + - "pl-cpu (ubuntu-20.04, lightning, 3.10, 1.12)" - "pl-cpu (windows-2022, pytorch, 3.10, 1.12)" + - "pl-cpu (windows-2022, lightning, 3.10, 1.12)" - "pl-cpu (macOS-11, pytorch, 3.7, 1.9, oldest)" + - "pl-cpu (macOS-11, lightning, 3.7, 1.9, oldest)" - "pl-cpu (ubuntu-20.04, pytorch, 3.7, 1.9, oldest)" + - "pl-cpu (ubuntu-20.04, lightning, 3.7, 1.9, oldest)" - "pl-cpu (windows-2022, pytorch, 3.7, 1.9, oldest)" + - "pl-cpu (windows-2022, lighting, 3.7, 1.9, oldest)" - "pl-cpu (macOS-11, pytorch, 3.10, 1.13, pre)" - "pl-cpu (ubuntu-20.04, pytorch, 3.9, 1.13, pre)" - "pl-cpu (windows-2022, pytorch, 3.8, 1.13, pre)" @@ -174,21 +186,37 @@ subprojects: - "lite-cpu (windows-2022, lite, 3.9, oldest, stable)" - "lite-cpu (windows-2022, lite, 3.10, latest, stable)" - "lite-cpu (windows-2022, lite, 3.10, oldest, stable)" + - "lite-cpu (macOS-11, pytorch, 3.10, pre)" + - "lite-cpu (ubuntu-20.04, pytorch, 3.9, pre)" + - "lite-cpu (windows-2022, pytorch, 3.8 pre)" + - "lite-cpu (macOS-11, lightning, 3.8, latest)" + - "lite-cpu (macOS-11, lightning, 3.10, latest)" + - "lite-cpu (ubuntu-20.04, lightning, 3.8, latest)" + - "lite-cpu (ubuntu-20.04, lightning, 3.10, latest)" + - "lite-cpu (windows-2022, lightning, 3.8, latest)" + - "lite-cpu (windows-2022, lightning, 3.10, latest)" + - "lite-cpu (ubuntu-22.04, lightning, 3.10, pre)" - "lightning-lite (GPUs)" - "mypy" # Lite also requires PL checks as it depends on Lite - "pl-cpu (macOS-11, pytorch, 3.9, 1.11)" - "pl-cpu (macOS-11, pytorch, 3.8, 1.10)" - "pl-cpu (windows-2022, pytorch, 3.10, 1.11)" - - "pl-cpu (windows.2022, pytorch, 3.9, 1.10)" + - "pl-cpu (windows-2022, pytorch, 3.9, 1.10)" - "pl-cpu (windows-2022, pytorch, 3.8, 1.9)" - "pl-cpu (ubuntu-20.04, pytorch, 3.8, 1.11)" - "pl-cpu (macOS-11, pytorch, 3.10, 1.12)" + - "pl-cpu (macOS-11, lightning, 3.10, 1.12)" - "pl-cpu (ubuntu-20.04, pytorch, 3.10, 1.12)" + - "pl-cpu (ubuntu-20.04, lightning, 3.10, 1.12)" - "pl-cpu (windows-2022, pytorch, 3.10, 1.12)" + - "pl-cpu (windows-2022, lightning, 3.10, 1.12)" - "pl-cpu (macOS-11, pytorch, 3.7, 1.9, oldest)" + - "pl-cpu (macOS-11, lightning, 3.7, 1.9, oldest)" - "pl-cpu (ubuntu-20.04, pytorch, 3.7, 1.9, oldest)" + - "pl-cpu (ubuntu-20.04, lightning, 3.7, 1.9, oldest)" - "pl-cpu (windows-2022, pytorch, 3.7, 1.9, oldest)" + - "pl-cpu (windows-2022, lighting, 3.7, 1.9, oldest)" - "pl-cpu (macOS-11, pytorch, 3.10, 1.13, pre)" - "pl-cpu (ubuntu-20.04, pytorch, 3.9, 1.13, pre)" - "pl-cpu (windows-2022, pytorch, 3.8, 1.13, pre)" @@ -228,6 +256,16 @@ subprojects: - "lite-cpu (windows-2022, lite, 3.9, oldest, stable)" - "lite-cpu (windows-2022, lite, 3.10, latest, stable)" - "lite-cpu (windows-2022, lite, 3.10, oldest, stable)" + - "lite-cpu (macOS-11, pytorch, 3.10, pre)" + - "lite-cpu (ubuntu-20.04, pytorch, 3.9, pre)" + - "lite-cpu (windows-2022, pytorch, 3.8 pre)" + - "lite-cpu (macOS-11, lightning, 3.8, latest)" + - "lite-cpu (macOS-11, lightning, 3.10, latest)" + - "lite-cpu (ubuntu-20.04, lightning, 3.8, latest)" + - "lite-cpu (ubuntu-20.04, lightning, 3.10, latest)" + - "lite-cpu (windows-2022, lightning, 3.8, latest)" + - "lite-cpu (windows-2022, lightning, 3.10, latest)" + - "lite-cpu (ubuntu-22.04, lightning, 3.10, pre)" - "lightning-lite (GPUs)" - id: "lightning_lite: Azure GPU" @@ -253,18 +291,24 @@ subprojects: - "App.cloud-e2e" - "make-doctest (app)" - "make-html (app)" - - "app-examples (macOS-11, app, 3.8, latest)" - - "app-examples (macOS-11, app, 3.8, oldest)" - - "app-examples (ubuntu-20.04, app, 3.8, latest)" - - "app-examples (ubuntu-20.04, app, 3.8, oldest)" - - "app-examples (windows-2022, app, 3.8, latest)" - - "app-examples (windows-2022, app, 3.8, oldest)" + - "app-examples (macOS-11, app, 3.9, latest)" + - "app-examples (macOS-11, app, 3.9, oldest)" + - "app-examples (ubuntu-20.04, app, 3.9, latest)" + - "app-examples (ubuntu-20.04, app, 3.9, oldest)" + - "app-examples (windows-2022, app, 3.9, latest)" + - "app-examples (windows-2022, app, 3.9, oldest)" + - "app-examples (macOS-11, lightning, 3.9, latest)" + - "app-examples (ubuntu-20.04, lightning, 3.9, latest)" + - "app-examples (windows-2022, lightning, 3.9, latest)" - "app-pytest (macOS-11, app, 3.8, latest)" - "app-pytest (macOS-11, app, 3.8, oldest)" - "app-pytest (ubuntu-20.04, app, 3.8, latest)" - "app-pytest (ubuntu-20.04, app, 3.8, oldest)" - "app-pytest (windows-2022, app, 3.8, latest)" - "app-pytest (windows-2022, app, 3.8, oldest)" + - "app-pytest (macOS-11, lightning, 3.8, latest)" + - "app-pytest (ubuntu-20.04, lightning, 3.8, latest)" + - "app-pytest (windows-2022, lightning, 3.8, latest)" - id: "lightning_app: Azure" paths: @@ -305,15 +349,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 (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 (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)" diff --git a/.github/workflows/ci-pytorch-test-full.yml b/.github/workflows/ci-pytorch-test-full.yml index ba4f19df03e8b..eec91a984e2cf 100644 --- a/.github/workflows/ci-pytorch-test-full.yml +++ b/.github/workflows/ci-pytorch-test-full.yml @@ -42,7 +42,7 @@ jobs: - {os: "macOS-11", pkg-name: "pytorch", python-version: "3.9", pytorch-version: "1.11"} - {os: "macOS-11", pkg-name: "pytorch", python-version: "3.8", pytorch-version: "1.10"} - {os: "windows-2022", pkg-name: "pytorch", python-version: "3.10", pytorch-version: "1.11"} - - {os: "windows.2022", pkg-name: "pytorch", python-version: "3.9", pytorch-version: "1.10"} + - {os: "windows-2022", pkg-name: "pytorch", python-version: "3.9", pytorch-version: "1.10"} - {os: "windows-2022", pkg-name: "pytorch", python-version: "3.8", pytorch-version: "1.9"} - {os: "ubuntu-20.04", pkg-name: "pytorch", python-version: "3.8", pytorch-version: "1.11"} # only run PyTorch latest with Python latest From 570e2a00e4fa26b73042901cc0ef2d29564f46f1 Mon Sep 17 00:00:00 2001 From: manskx Date: Wed, 26 Oct 2022 10:40:12 +0200 Subject: [PATCH 087/104] include frontend dir --- src/lightning/__setup__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lightning/__setup__.py b/src/lightning/__setup__.py index b7d37f797ec54..b9b5d14274d11 100644 --- a/src/lightning/__setup__.py +++ b/src/lightning/__setup__.py @@ -33,7 +33,7 @@ def _adjust_manifest(**kwargs: Any) -> None: lines += [ "recursive-include src/lightning *.md", "recursive-include requirements *.txt", - "recursive-include src/lightning/ui *", + "recursive-include src/lightning/app/ui *", "recursive-include src/lightning/cli/*-template *", # Add templates as build-in # fixme: this is strange, this shall work with setup find package - include "prune src/lightning_app", From 269a45c474d919bb9c291d3af7928c3bfc38eb41 Mon Sep 17 00:00:00 2001 From: Jirka Date: Wed, 26 Oct 2022 12:08:18 +0200 Subject: [PATCH 088/104] cli --- src/lightning/__setup__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lightning/__setup__.py b/src/lightning/__setup__.py index b9b5d14274d11..58f0ee426076b 100644 --- a/src/lightning/__setup__.py +++ b/src/lightning/__setup__.py @@ -76,7 +76,7 @@ def _setup_args(**kwargs: Any) -> Dict[str, Any]: python_requires=">=3.7", # todo: take the lowes based on all packages entry_points={ "console_scripts": [ - "lightning = lightning_app.cli.lightning_cli:main", + "lightning = lightning.app.cli.lightning_cli:main", ], }, setup_requires=[], From bf81fe3dec955c94ee16968657de9013b638cb02 Mon Sep 17 00:00:00 2001 From: thomas chaton Date: Wed, 26 Oct 2022 11:12:56 +0100 Subject: [PATCH 089/104] fix imports and entry point --- src/lightning/__setup__.py | 2 +- src/lightning_app/utilities/packaging/lightning_utils.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lightning/__setup__.py b/src/lightning/__setup__.py index b7d37f797ec54..9730c0febcd79 100644 --- a/src/lightning/__setup__.py +++ b/src/lightning/__setup__.py @@ -76,7 +76,7 @@ def _setup_args(**kwargs: Any) -> Dict[str, Any]: python_requires=">=3.7", # todo: take the lowes based on all packages entry_points={ "console_scripts": [ - "lightning = lightning_app.cli.lightning_cli:main", + "lightning = lightning.app.cli.lightning_cli:main", ], }, setup_requires=[], diff --git a/src/lightning_app/utilities/packaging/lightning_utils.py b/src/lightning_app/utilities/packaging/lightning_utils.py index 224b8e6614f7f..4fc6fba69bc6d 100644 --- a/src/lightning_app/utilities/packaging/lightning_utils.py +++ b/src/lightning_app/utilities/packaging/lightning_utils.py @@ -15,7 +15,7 @@ from lightning_app import _logger, _PROJECT_ROOT, _root_logger from lightning_app.__version__ import version -from lightning_app.core.constants import PACKAGE_LIGHTNING +from lightning_app.core.constants import FRONTEND_DIR, PACKAGE_LIGHTNING from lightning_app.utilities.app_helpers import Logger from lightning_app.utilities.git import check_github_repository, get_dir_name @@ -30,7 +30,7 @@ def download_frontend(root: str = _PROJECT_ROOT): """Downloads an archive file for a specific release of the Lightning frontend and extracts it to the correct directory.""" build_dir = "build" - frontend_dir = pathlib.Path(root, "src", "lightning_app", "ui") + frontend_dir = pathlib.Path(FRONTEND_DIR) download_dir = tempfile.mkdtemp() shutil.rmtree(frontend_dir, ignore_errors=True) From 9df96685b866b1719fcdeb0b2e832255e3a5f8c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mochol=C3=AD?= Date: Wed, 26 Oct 2022 13:42:41 +0200 Subject: [PATCH 090/104] Revert standalone --- tests/tests_pytorch/loops/test_training_loop.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/tests_pytorch/loops/test_training_loop.py b/tests/tests_pytorch/loops/test_training_loop.py index 203bcf38c6f30..dc52a08f068ae 100644 --- a/tests/tests_pytorch/loops/test_training_loop.py +++ b/tests/tests_pytorch/loops/test_training_loop.py @@ -20,7 +20,6 @@ from pytorch_lightning import seed_everything, Trainer from pytorch_lightning.demos.boring_classes import BoringModel from pytorch_lightning.loops import FitLoop -from tests_pytorch.helpers.runif import RunIf def test_outputs_format(tmpdir): @@ -141,7 +140,6 @@ def validation_step(self, *args): assert model.validation_called_at == (0, 5) -@RunIf(standalone=True) def test_fit_loop_done_log_messages(caplog): fit_loop = FitLoop(max_epochs=1) trainer = Mock(spec=Trainer) @@ -212,7 +210,6 @@ def training_step_end(self, outputs): (4, 10, 4, True, True, True), ], ) -@RunIf(standalone=True) def test_should_stop_early_stopping_conditions_met( caplog, min_epochs, min_steps, current_epoch, early_stop, fit_loop_done, raise_debug_msg ): From 20be13a1ddad5141b421c739b0b790669b2d04aa Mon Sep 17 00:00:00 2001 From: Jirka Date: Wed, 26 Oct 2022 15:18:00 +0200 Subject: [PATCH 091/104] rc1 --- src/lightning/__version__.py | 2 +- src/lightning_app/__version__.py | 2 +- src/lightning_lite/__version__.py | 2 +- src/pytorch_lightning/__version__.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lightning/__version__.py b/src/lightning/__version__.py index ea312c65c44f6..037ac1fafe2df 100644 --- a/src/lightning/__version__.py +++ b/src/lightning/__version__.py @@ -1 +1 @@ -version = "1.8.0rc0" +version = "1.8.0rc1" diff --git a/src/lightning_app/__version__.py b/src/lightning_app/__version__.py index ea312c65c44f6..037ac1fafe2df 100644 --- a/src/lightning_app/__version__.py +++ b/src/lightning_app/__version__.py @@ -1 +1 @@ -version = "1.8.0rc0" +version = "1.8.0rc1" diff --git a/src/lightning_lite/__version__.py b/src/lightning_lite/__version__.py index ea312c65c44f6..037ac1fafe2df 100644 --- a/src/lightning_lite/__version__.py +++ b/src/lightning_lite/__version__.py @@ -1 +1 @@ -version = "1.8.0rc0" +version = "1.8.0rc1" diff --git a/src/pytorch_lightning/__version__.py b/src/pytorch_lightning/__version__.py index ea312c65c44f6..037ac1fafe2df 100644 --- a/src/pytorch_lightning/__version__.py +++ b/src/pytorch_lightning/__version__.py @@ -1 +1 @@ -version = "1.8.0rc0" +version = "1.8.0rc1" From 1402dc46eff7b4c3f591bdd570d5973e9853e398 Mon Sep 17 00:00:00 2001 From: Jirka Date: Wed, 26 Oct 2022 16:29:30 +0200 Subject: [PATCH 092/104] e2e on staging --- .azure/app-cloud-e2e.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.azure/app-cloud-e2e.yml b/.azure/app-cloud-e2e.yml index 6af7355626b69..909b8d29a15b9 100644 --- a/.azure/app-cloud-e2e.yml +++ b/.azure/app-cloud-e2e.yml @@ -155,12 +155,12 @@ jobs: TEST_APP_NAME: $(name) HAR_LOCATION: './artifacts/hars' SLOW_MO: '50' - # LAI_USER: $(LAI_USER) - # LAI_PASS: $(LAI_PASS) - LIGHTNING_USER_ID: $(LIGHTNING_USER_ID_PROD) - LIGHTNING_API_KEY: $(LIGHTNING_API_KEY_PROD) + LAI_USER: $(LAI_USER) # for STAGING + LAI_PASS: $(LAI_PASS) # for STAGING + LIGHTNING_USER_ID: $(LIGHTNING_USER_ID_STAGING) + LIGHTNING_API_KEY: $(LIGHTNING_API_KEY_STAGING) LIGHTNING_USERNAME: $(LIGHTNING_USERNAME) - LIGHTNING_CLOUD_URL: $(LIGHTNING_CLOUD_URL_PROD) + LIGHTNING_CLOUD_URL: $(LIGHTNING_CLOUD_URL_STAGING) LIGHTNING_DEBUG: '1' displayName: 'Run the tests' @@ -173,12 +173,12 @@ jobs: time python -c "from lightning.app import testing; testing.delete_cloud_lightning_apps()" condition: always() env: - # LAI_USER: $(LAI_USER) - # LAI_PASS: $(LAI_PASS) - LIGHTNING_USER_ID: $(LIGHTNING_USER_ID_PROD) - LIGHTNING_API_KEY: $(LIGHTNING_API_KEY_PROD) + LAI_USER: $(LAI_USER) # for STAGING + LAI_PASS: $(LAI_PASS) # for STAGING + LIGHTNING_USER_ID: $(LIGHTNING_USER_ID_STAGING) + LIGHTNING_API_KEY: $(LIGHTNING_API_KEY_STAGING) LIGHTNING_USERNAME: $(LIGHTNING_USERNAME) - LIGHTNING_CLOUD_URL: $(LIGHTNING_CLOUD_URL_PROD) + LIGHTNING_CLOUD_URL: $(LIGHTNING_CLOUD_URL_STAGING) PR_NUMBER: $(local_id) TEST_APP_NAME: $(name) # GRID_USER_ID: $(LIGHTNING_USER_ID) # TODO: clarify the meaning From a42f2ec5125664dd793a66e7ed9ffc3b02cf31bd Mon Sep 17 00:00:00 2001 From: Jirka Date: Wed, 26 Oct 2022 19:50:52 +0200 Subject: [PATCH 093/104] Revert "Revert standalone" This reverts commit 9df96685b866b1719fcdeb0b2e832255e3a5f8c0. --- tests/tests_pytorch/loops/test_training_loop.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/tests_pytorch/loops/test_training_loop.py b/tests/tests_pytorch/loops/test_training_loop.py index dc52a08f068ae..203bcf38c6f30 100644 --- a/tests/tests_pytorch/loops/test_training_loop.py +++ b/tests/tests_pytorch/loops/test_training_loop.py @@ -20,6 +20,7 @@ from pytorch_lightning import seed_everything, Trainer from pytorch_lightning.demos.boring_classes import BoringModel from pytorch_lightning.loops import FitLoop +from tests_pytorch.helpers.runif import RunIf def test_outputs_format(tmpdir): @@ -140,6 +141,7 @@ def validation_step(self, *args): assert model.validation_called_at == (0, 5) +@RunIf(standalone=True) def test_fit_loop_done_log_messages(caplog): fit_loop = FitLoop(max_epochs=1) trainer = Mock(spec=Trainer) @@ -210,6 +212,7 @@ def training_step_end(self, outputs): (4, 10, 4, True, True, True), ], ) +@RunIf(standalone=True) def test_should_stop_early_stopping_conditions_met( caplog, min_epochs, min_steps, current_epoch, early_stop, fit_loop_done, raise_debug_msg ): From cda08985235d6e11f0b30d16a115266a5213e834 Mon Sep 17 00:00:00 2001 From: Jirka Date: Wed, 26 Oct 2022 21:38:11 +0200 Subject: [PATCH 094/104] groups --- .github/checkgroup.yml | 48 +++++++++++++++++++++----- .github/workflows/ci-lite-tests.yml | 9 ++--- .github/workflows/ci-pytorch-tests.yml | 8 +++-- 3 files changed, 47 insertions(+), 18 deletions(-) diff --git a/.github/checkgroup.yml b/.github/checkgroup.yml index 124b8786b87f2..352d54630d0cb 100644 --- a/.github/checkgroup.yml +++ b/.github/checkgroup.yml @@ -30,16 +30,24 @@ subprojects: - "pl-cpu (macOS-11, pytorch, 3.10, 1.12)" - "pl-cpu (macOS-11, pytorch, 3.7, 1.9, oldest)" - "pl-cpu (macOS-11, pytorch, 3.10, 1.13, pre)" - - "pl-cpu (ubuntu-20.04, pytorch, 3.8, 1.11)" + - "pl-cpu (ubuntu-20.04, pytorch, 3.8, 1.10)" + - "pl-cpu (ubuntu-20.04, pytorch, 3.9, 1.11)" + - "pl-cpu (ubuntu-20.04, pytorch, 3.10, 1.11)" - "pl-cpu (ubuntu-20.04, pytorch, 3.10, 1.12)" - "pl-cpu (ubuntu-20.04, pytorch, 3.7, 1.9, oldest)" - "pl-cpu (ubuntu-20.04, pytorch, 3.9, 1.13, pre)" - "pl-cpu (windows-2022, pytorch, 3.8, 1.9)" - - "pl-cpu (windows-2022, pytorch, 3.9, 1.10)" + - "pl-cpu (windows-2022, pytorch, 3.9, 1.11)" - "pl-cpu (windows-2022, pytorch, 3.10, 1.11)" - "pl-cpu (windows-2022, pytorch, 3.10, 1.12)" - "pl-cpu (windows-2022, pytorch, 3.7, 1.9, oldest)" - "pl-cpu (windows-2022, pytorch, 3.8, 1.13, pre)" + - "pl-cpu (macOS-11, lightning, 3.10, 1.12)" + - "pl-cpu (macOS-11, lightning, 3.7, 1.9, oldest)" + - "pl-cpu (ubuntu-20.04, lightning, 10, 1.12)" + - "pl-cpu (ubuntu-20.04, lightning, 3.7, 1.9, oldest)" + - "pl-cpu (windows-2022, lightning, 3.10, 1.12)" + - "pl-cpu (windows-2022, lightning, 3.7, 1.9, oldest)" - "make-doctest (pytorch)" - "make-html (pytorch)" - "mypy" @@ -56,21 +64,29 @@ subprojects: paths: - ".github/workflows/ci-pytorch-tests.yml" checks: - - "pl-cpu (macOS-11, pytorch, 3.9, 1.11)" - "pl-cpu (macOS-11, pytorch, 3.8, 1.10)" + - "pl-cpu (macOS-11, pytorch, 3.9, 1.11)" - "pl-cpu (macOS-11, pytorch, 3.10, 1.12)" - "pl-cpu (macOS-11, pytorch, 3.7, 1.9, oldest)" - "pl-cpu (macOS-11, pytorch, 3.10, 1.13, pre)" - - "pl-cpu (ubuntu-20.04, pytorch, 3.8, 1.11)" + - "pl-cpu (ubuntu-20.04, pytorch, 3.8, 1.10)" + - "pl-cpu (ubuntu-20.04, pytorch, 3.9, 1.11)" + - "pl-cpu (ubuntu-20.04, pytorch, 3.10, 1.11)" - "pl-cpu (ubuntu-20.04, pytorch, 3.10, 1.12)" - "pl-cpu (ubuntu-20.04, pytorch, 3.7, 1.9, oldest)" - "pl-cpu (ubuntu-20.04, pytorch, 3.9, 1.13, pre)" - "pl-cpu (windows-2022, pytorch, 3.8, 1.9)" - - "pl-cpu (windows-2022, pytorch, 3.9, 1.10)" + - "pl-cpu (windows-2022, pytorch, 3.9, 1.11)" - "pl-cpu (windows-2022, pytorch, 3.10, 1.11)" - "pl-cpu (windows-2022, pytorch, 3.10, 1.12)" - "pl-cpu (windows-2022, pytorch, 3.7, 1.9, oldest)" - "pl-cpu (windows-2022, pytorch, 3.8, 1.13, pre)" + - "pl-cpu (macOS-11, lightning, 3.10, 1.12)" + - "pl-cpu (macOS-11, lightning, 3.7, 1.9, oldest)" + - "pl-cpu (ubuntu-20.04, lightning, 10, 1.12)" + - "pl-cpu (ubuntu-20.04, lightning, 3.7, 1.9, oldest)" + - "pl-cpu (windows-2022, lightning, 3.10, 1.12)" + - "pl-cpu (windows-2022, lightning, 3.7, 1.9, oldest)" - id: "pytorch_lightning: Slow" paths: @@ -165,24 +181,35 @@ subprojects: - "lite-cpu (windows-2022, lite, 3.10, 1.12)" - "lite-cpu (windows-2022, lite, 3.7, 1.9, oldest)" - "lite-cpu (windows-2022, lite, 3.8, 1.13, pre)" + - "lite-cpu (macOS-11, lightning, 3.8)" + - "lite-cpu (ubuntu-20.04, lightning, 3.8)" + - "lite-cpu (windows-2022, lightning, 3.8)" - "lightning-lite (GPUs)" - "mypy" # Lite also requires PL checks as it depends on Lite - - "pl-cpu (macOS-11, pytorch, 3.9, 1.11)" - "pl-cpu (macOS-11, pytorch, 3.8, 1.10)" + - "pl-cpu (macOS-11, pytorch, 3.9, 1.11)" - "pl-cpu (macOS-11, pytorch, 3.10, 1.12)" - "pl-cpu (macOS-11, pytorch, 3.7, 1.9, oldest)" - "pl-cpu (macOS-11, pytorch, 3.10, 1.13, pre)" - - "pl-cpu (ubuntu-20.04, pytorch, 3.8, 1.11)" + - "pl-cpu (ubuntu-20.04, pytorch, 3.8, 1.10)" + - "pl-cpu (ubuntu-20.04, pytorch, 3.9, 1.11)" + - "pl-cpu (ubuntu-20.04, pytorch, 3.10, 1.11)" - "pl-cpu (ubuntu-20.04, pytorch, 3.10, 1.12)" - "pl-cpu (ubuntu-20.04, pytorch, 3.7, 1.9, oldest)" - "pl-cpu (ubuntu-20.04, pytorch, 3.9, 1.13, pre)" - "pl-cpu (windows-2022, pytorch, 3.8, 1.9)" - - "pl-cpu (windows-2022, pytorch, 3.9, 1.10)" + - "pl-cpu (windows-2022, pytorch, 3.9, 1.11)" - "pl-cpu (windows-2022, pytorch, 3.10, 1.11)" - "pl-cpu (windows-2022, pytorch, 3.10, 1.12)" - "pl-cpu (windows-2022, pytorch, 3.7, 1.9, oldest)" - "pl-cpu (windows-2022, pytorch, 3.8, 1.13, pre)" + - "pl-cpu (macOS-11, lightning, 3.10, 1.12)" + - "pl-cpu (macOS-11, lightning, 3.7, 1.9, oldest)" + - "pl-cpu (ubuntu-20.04, lightning, 10, 1.12)" + - "pl-cpu (ubuntu-20.04, lightning, 3.7, 1.9, oldest)" + - "pl-cpu (windows-2022, lightning, 3.10, 1.12)" + - "pl-cpu (windows-2022, lightning, 3.7, 1.9, oldest)" - "make-doctest (pytorch)" - "make-html (pytorch)" - "pytorch-lightning (GPUs)" @@ -210,6 +237,9 @@ subprojects: - "lite-cpu (windows-2022, lite, 3.10, 1.12)" - "lite-cpu (windows-2022, lite, 3.7, 1.9, oldest)" - "lite-cpu (windows-2022, lite, 3.8, 1.13, pre)" + - "lite-cpu (macOS-11, lightning, 3.8)" + - "lite-cpu (ubuntu-20.04, lightning, 3.8)" + - "lite-cpu (windows-2022, lightning, 3.8)" - "lightning-lite (GPUs)" - id: "lightning_lite: Azure GPU" @@ -236,8 +266,8 @@ subprojects: - "make-doctest (app)" - "make-html (app)" - "app-examples (macOS-11, app, 3.9, latest)" - - "app-examples (macOS-11, lightning, 3.9, latest)" - "app-examples (macOS-11, app, 3.9, oldest)" + - "app-examples (macOS-11, lightning, 3.9, latest)" - "app-examples (ubuntu-20.04, app, 3.9, latest)" - "app-examples (ubuntu-20.04, app, 3.9, oldest)" - "app-examples (ubuntu-20.04, lightning, 3.9, latest)" diff --git a/.github/workflows/ci-lite-tests.yml b/.github/workflows/ci-lite-tests.yml index ed2158ffd874e..64de6d2607591 100644 --- a/.github/workflows/ci-lite-tests.yml +++ b/.github/workflows/ci-lite-tests.yml @@ -55,12 +55,9 @@ jobs: - {os: "ubuntu-20.04", pkg-name: "lite", python-version: "3.9", pytorch-version: "1.13", release: "pre"} - {os: "windows-2022", pkg-name: "lite", python-version: "3.8", pytorch-version: "1.13", release: "pre"} # "lightning" installs the monolithic package - - {os: "macOS-11", pkg-name: "lightning", python-version: "3.8", requires: "latest"} - - {os: "macOS-11", pkg-name: "lightning", python-version: "3.10", requires: "latest"} - - {os: "ubuntu-20.04", pkg-name: "lightning", python-version: "3.8", requires: "latest"} - - {os: "ubuntu-20.04", pkg-name: "lightning", python-version: "3.10", requires: "latest"} - - {os: "windows-2022", pkg-name: "lightning", python-version: "3.8", requires: "latest"} - - {os: "windows-2022", pkg-name: "lightning", python-version: "3.10", requires: "latest"} + - {os: "macOS-11", pkg-name: "lightning", python-version: "3.8"} + - {os: "ubuntu-20.04", pkg-name: "lightning", python-version: "3.8"} + - {os: "windows-2022", pkg-name: "lightning", python-version: "3.8"} timeout-minutes: 10 diff --git a/.github/workflows/ci-pytorch-tests.yml b/.github/workflows/ci-pytorch-tests.yml index f2a4a12652023..785f3abb99ab0 100644 --- a/.github/workflows/ci-pytorch-tests.yml +++ b/.github/workflows/ci-pytorch-tests.yml @@ -42,10 +42,12 @@ jobs: # note: there's no distribution of Torch==1.9 for Python>=3.9 or torch==1.10 for Python>=3.10 - {os: "macOS-11", pkg-name: "pytorch", python-version: "3.9", pytorch-version: "1.11"} - {os: "macOS-11", pkg-name: "pytorch", python-version: "3.8", pytorch-version: "1.10"} + - {os: "ubuntu-20.04", pkg-name: "pytorch", python-version: "3.8", pytorch-version: "1.10"} + - {os: "ubuntu-20.04", pkg-name: "pytorch", python-version: "3.9", pytorch-version: "1.11"} + - {os: "ubuntu-20.04", pkg-name: "pytorch", python-version: "3.10", pytorch-version: "1.11"} + - {os: "windows-2022", pkg-name: "pytorch", python-version: "3.8", pytorch-version: "1.10"} + - {os: "windows-2022", pkg-name: "pytorch", python-version: "3.9", pytorch-version: "1.11"} - {os: "windows-2022", pkg-name: "pytorch", python-version: "3.10", pytorch-version: "1.11"} - - {os: "windows-2022", pkg-name: "pytorch", python-version: "3.9", pytorch-version: "1.10"} - - {os: "windows-2022", pkg-name: "pytorch", python-version: "3.8", pytorch-version: "1.9"} - - {os: "ubuntu-20.04", pkg-name: "pytorch", python-version: "3.8", pytorch-version: "1.11"} # only run PyTorch latest with Python latest - {os: "macOS-11", pkg-name: "pytorch", python-version: "3.10", pytorch-version: "1.12"} - {os: "macOS-11", pkg-name: "lightning", python-version: "3.10", pytorch-version: "1.12"} From 30f4bbb04225c779f9b6a4dfb921cb1b06a6e33d Mon Sep 17 00:00:00 2001 From: Jirka Date: Wed, 26 Oct 2022 23:14:03 +0200 Subject: [PATCH 095/104] to --- .github/workflows/ci-app-examples.yml | 2 +- .github/workflows/ci-app-tests.yml | 2 +- .github/workflows/ci-lite-tests.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci-app-examples.yml b/.github/workflows/ci-app-examples.yml index b2c05a65fa8e4..f18841f306413 100644 --- a/.github/workflows/ci-app-examples.yml +++ b/.github/workflows/ci-app-examples.yml @@ -42,7 +42,7 @@ jobs: - {os: "windows-2022", pkg-name: "lightning", python-version: "3.9", requires: "latest"} # Timeout: https://stackoverflow.com/a/59076067/4521646 - timeout-minutes: 10 + timeout-minutes: 15 steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/ci-app-tests.yml b/.github/workflows/ci-app-tests.yml index 4d644b2b2b5fa..c35a2eb2b09f4 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.9", requires: "latest"} # Timeout: https://stackoverflow.com/a/59076067/4521646 - timeout-minutes: 25 + timeout-minutes: 30 steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/ci-lite-tests.yml b/.github/workflows/ci-lite-tests.yml index 64de6d2607591..1cdf048e9f9fd 100644 --- a/.github/workflows/ci-lite-tests.yml +++ b/.github/workflows/ci-lite-tests.yml @@ -59,7 +59,7 @@ jobs: - {os: "ubuntu-20.04", pkg-name: "lightning", python-version: "3.8"} - {os: "windows-2022", pkg-name: "lightning", python-version: "3.8"} - timeout-minutes: 10 + timeout-minutes: 15 steps: - uses: actions/checkout@v3 From 887919525225bf66b736dd90534569d264877fe3 Mon Sep 17 00:00:00 2001 From: Jirka Date: Wed, 26 Oct 2022 23:15:55 +0200 Subject: [PATCH 096/104] ci: pt ver --- .github/checkgroup.yml | 12 ++++++------ .github/workflows/ci-lite-tests.yml | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/checkgroup.yml b/.github/checkgroup.yml index 352d54630d0cb..68bc99efeb344 100644 --- a/.github/checkgroup.yml +++ b/.github/checkgroup.yml @@ -181,9 +181,9 @@ subprojects: - "lite-cpu (windows-2022, lite, 3.10, 1.12)" - "lite-cpu (windows-2022, lite, 3.7, 1.9, oldest)" - "lite-cpu (windows-2022, lite, 3.8, 1.13, pre)" - - "lite-cpu (macOS-11, lightning, 3.8)" - - "lite-cpu (ubuntu-20.04, lightning, 3.8)" - - "lite-cpu (windows-2022, lightning, 3.8)" + - "lite-cpu (macOS-11, lightning, 3.8, 1.12)" + - "lite-cpu (ubuntu-20.04, lightning, 3.8, 1.12)" + - "lite-cpu (windows-2022, lightning, 3.8, 1.12)" - "lightning-lite (GPUs)" - "mypy" # Lite also requires PL checks as it depends on Lite @@ -237,9 +237,9 @@ subprojects: - "lite-cpu (windows-2022, lite, 3.10, 1.12)" - "lite-cpu (windows-2022, lite, 3.7, 1.9, oldest)" - "lite-cpu (windows-2022, lite, 3.8, 1.13, pre)" - - "lite-cpu (macOS-11, lightning, 3.8)" - - "lite-cpu (ubuntu-20.04, lightning, 3.8)" - - "lite-cpu (windows-2022, lightning, 3.8)" + - "lite-cpu (macOS-11, lightning, 3.8, 1.12)" + - "lite-cpu (ubuntu-20.04, lightning, 3.8, 1.12)" + - "lite-cpu (windows-2022, lightning, 3.8, 1.12)" - "lightning-lite (GPUs)" - id: "lightning_lite: Azure GPU" diff --git a/.github/workflows/ci-lite-tests.yml b/.github/workflows/ci-lite-tests.yml index 1cdf048e9f9fd..6fa7164da1141 100644 --- a/.github/workflows/ci-lite-tests.yml +++ b/.github/workflows/ci-lite-tests.yml @@ -55,9 +55,9 @@ jobs: - {os: "ubuntu-20.04", pkg-name: "lite", python-version: "3.9", pytorch-version: "1.13", release: "pre"} - {os: "windows-2022", pkg-name: "lite", python-version: "3.8", pytorch-version: "1.13", release: "pre"} # "lightning" installs the monolithic package - - {os: "macOS-11", pkg-name: "lightning", python-version: "3.8"} - - {os: "ubuntu-20.04", pkg-name: "lightning", python-version: "3.8"} - - {os: "windows-2022", pkg-name: "lightning", python-version: "3.8"} + - {os: "macOS-11", pkg-name: "lightning", python-version: "3.8", pytorch-version: "1.12"} + - {os: "ubuntu-20.04", pkg-name: "lightning", python-version: "3.8", pytorch-version: "1.12"} + - {os: "windows-2022", pkg-name: "lightning", python-version: "3.8", pytorch-version: "1.12"} timeout-minutes: 15 From 1f2c5d2425356f80231344fdeff0926b67f3dadc Mon Sep 17 00:00:00 2001 From: Jirka Date: Thu, 27 Oct 2022 00:25:08 +0200 Subject: [PATCH 097/104] docker --- dockers/nvidia/Dockerfile | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/dockers/nvidia/Dockerfile b/dockers/nvidia/Dockerfile index 5328d6dea8e97..5e67d2044f46d 100644 --- a/dockers/nvidia/Dockerfile +++ b/dockers/nvidia/Dockerfile @@ -50,9 +50,6 @@ RUN \ RUN pip install jupyterlab[all] -U -RUN pip install lightning-grid -U && \ - pip install "py>=1.10" "protobuf>=3.15.6" --upgrade-strategy only-if-needed - ENV PYTHONPATH="/workspace" RUN \ @@ -63,6 +60,6 @@ RUN \ pip --version && \ pip list | grep torch && \ python -c "import torch; assert torch.__version__.startswith('$TORCH_VERSION'), torch.__version__" && \ - python -c "import pytorch_lightning as pl; print(pl.__version__)" + python -c "import lightning as L; print(L.__version__)" CMD ["jupyter", "notebook", "--port=8888", "--no-browser", "--ip=0.0.0.0", "--allow-root"] From ef13dd8e4b5ec6918db1b7bd7bd6fe2f7004341d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mochol=C3=AD?= Date: Thu, 27 Oct 2022 01:06:09 +0200 Subject: [PATCH 098/104] Apply suggestions from code review --- .github/checkgroup.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/checkgroup.yml b/.github/checkgroup.yml index 68bc99efeb344..bb015f406328c 100644 --- a/.github/checkgroup.yml +++ b/.github/checkgroup.yml @@ -198,7 +198,6 @@ subprojects: - "pl-cpu (ubuntu-20.04, pytorch, 3.10, 1.12)" - "pl-cpu (ubuntu-20.04, pytorch, 3.7, 1.9, oldest)" - "pl-cpu (ubuntu-20.04, pytorch, 3.9, 1.13, pre)" - - "pl-cpu (windows-2022, pytorch, 3.8, 1.9)" - "pl-cpu (windows-2022, pytorch, 3.9, 1.11)" - "pl-cpu (windows-2022, pytorch, 3.10, 1.11)" - "pl-cpu (windows-2022, pytorch, 3.10, 1.12)" @@ -206,7 +205,7 @@ subprojects: - "pl-cpu (windows-2022, pytorch, 3.8, 1.13, pre)" - "pl-cpu (macOS-11, lightning, 3.10, 1.12)" - "pl-cpu (macOS-11, lightning, 3.7, 1.9, oldest)" - - "pl-cpu (ubuntu-20.04, lightning, 10, 1.12)" + - "pl-cpu (ubuntu-20.04, lightning, 3.10, 1.12)" - "pl-cpu (ubuntu-20.04, lightning, 3.7, 1.9, oldest)" - "pl-cpu (windows-2022, lightning, 3.10, 1.12)" - "pl-cpu (windows-2022, lightning, 3.7, 1.9, oldest)" @@ -276,13 +275,13 @@ subprojects: - "app-examples (windows-2022, lightning, 3.9, latest)" - "app-pytest (macOS-11, app, 3.8, latest)" - "app-pytest (macOS-11, app, 3.8, oldest)" - - "app-pytest (macOS-11, lightning, 3.8, latest)" + - "app-pytest (macOS-11, lightning, 3.9, latest)" - "app-pytest (ubuntu-20.04, app, 3.8, latest)" - "app-pytest (ubuntu-20.04, app, 3.8, oldest)" - - "app-pytest (ubuntu-20.04, lightning, 3.8, latest)" + - "app-pytest (ubuntu-20.04, lightning, 3.9, latest)" - "app-pytest (windows-2022, app, 3.8, latest)" - "app-pytest (windows-2022, app, 3.8, oldest)" - - "app-pytest (windows-2022, lightning, 3.8, latest)" + - "app-pytest (windows-2022, lightning, 3.9, latest)" - id: "lightning_app: Azure" paths: From e47a07bffaac653cd84742cd4e9f10c50cd42e93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mochol=C3=AD?= Date: Thu, 27 Oct 2022 01:08:13 +0200 Subject: [PATCH 099/104] Copy over changes from previous commit to other groups --- .github/checkgroup.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/checkgroup.yml b/.github/checkgroup.yml index bb015f406328c..161e8de865264 100644 --- a/.github/checkgroup.yml +++ b/.github/checkgroup.yml @@ -36,7 +36,6 @@ subprojects: - "pl-cpu (ubuntu-20.04, pytorch, 3.10, 1.12)" - "pl-cpu (ubuntu-20.04, pytorch, 3.7, 1.9, oldest)" - "pl-cpu (ubuntu-20.04, pytorch, 3.9, 1.13, pre)" - - "pl-cpu (windows-2022, pytorch, 3.8, 1.9)" - "pl-cpu (windows-2022, pytorch, 3.9, 1.11)" - "pl-cpu (windows-2022, pytorch, 3.10, 1.11)" - "pl-cpu (windows-2022, pytorch, 3.10, 1.12)" @@ -44,7 +43,7 @@ subprojects: - "pl-cpu (windows-2022, pytorch, 3.8, 1.13, pre)" - "pl-cpu (macOS-11, lightning, 3.10, 1.12)" - "pl-cpu (macOS-11, lightning, 3.7, 1.9, oldest)" - - "pl-cpu (ubuntu-20.04, lightning, 10, 1.12)" + - "pl-cpu (ubuntu-20.04, lightning, 3.10, 1.12)" - "pl-cpu (ubuntu-20.04, lightning, 3.7, 1.9, oldest)" - "pl-cpu (windows-2022, lightning, 3.10, 1.12)" - "pl-cpu (windows-2022, lightning, 3.7, 1.9, oldest)" @@ -75,7 +74,6 @@ subprojects: - "pl-cpu (ubuntu-20.04, pytorch, 3.10, 1.12)" - "pl-cpu (ubuntu-20.04, pytorch, 3.7, 1.9, oldest)" - "pl-cpu (ubuntu-20.04, pytorch, 3.9, 1.13, pre)" - - "pl-cpu (windows-2022, pytorch, 3.8, 1.9)" - "pl-cpu (windows-2022, pytorch, 3.9, 1.11)" - "pl-cpu (windows-2022, pytorch, 3.10, 1.11)" - "pl-cpu (windows-2022, pytorch, 3.10, 1.12)" @@ -83,7 +81,7 @@ subprojects: - "pl-cpu (windows-2022, pytorch, 3.8, 1.13, pre)" - "pl-cpu (macOS-11, lightning, 3.10, 1.12)" - "pl-cpu (macOS-11, lightning, 3.7, 1.9, oldest)" - - "pl-cpu (ubuntu-20.04, lightning, 10, 1.12)" + - "pl-cpu (ubuntu-20.04, lightning, 3.10, 1.12)" - "pl-cpu (ubuntu-20.04, lightning, 3.7, 1.9, oldest)" - "pl-cpu (windows-2022, lightning, 3.10, 1.12)" - "pl-cpu (windows-2022, lightning, 3.7, 1.9, oldest)" From c2ec5145ee5a66c848b72a31e94e47645a3a7e72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mochol=C3=AD?= Date: Thu, 27 Oct 2022 01:14:09 +0200 Subject: [PATCH 100/104] Add back changes from bad merge --- .github/checkgroup.yml | 6 ++++++ .github/workflows/ci-lite-tests.yml | 1 + 2 files changed, 7 insertions(+) diff --git a/.github/checkgroup.yml b/.github/checkgroup.yml index 161e8de865264..c658a5dc6a347 100644 --- a/.github/checkgroup.yml +++ b/.github/checkgroup.yml @@ -320,15 +320,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 (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 (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)" diff --git a/.github/workflows/ci-lite-tests.yml b/.github/workflows/ci-lite-tests.yml index 6fa7164da1141..2a49ce883669d 100644 --- a/.github/workflows/ci-lite-tests.yml +++ b/.github/workflows/ci-lite-tests.yml @@ -112,6 +112,7 @@ jobs: PACKAGE_NAME: ${{ matrix.pkg-name }} run: | pip install -e . "pytest-timeout" -r requirements/lite/devel.txt --upgrade --find-links ${TORCH_URL} + pip list - name: Adjust tests if: ${{ matrix.pkg-name == 'lightning' }} From 2a4e9f882c313ceb9a04ec713d0d7444ca6cae8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mochol=C3=AD?= Date: Thu, 27 Oct 2022 01:20:15 +0200 Subject: [PATCH 101/104] Uppercase step name everywhere --- .github/workflows/ci-app-examples.yml | 2 +- .github/workflows/ci-app-tests.yml | 4 ++-- .github/workflows/ci-pytorch-tests.yml | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci-app-examples.yml b/.github/workflows/ci-app-examples.yml index f18841f306413..35c748a4da8d8 100644 --- a/.github/workflows/ci-app-examples.yml +++ b/.github/workflows/ci-app-examples.yml @@ -103,7 +103,7 @@ jobs: 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" - - name: switch coverage scope + - name: Switch coverage scope run: python -c "print('COVERAGE_SCOPE=' + str('lightning' if '${{matrix.pkg-name}}' == 'lightning' else 'lightning_app'))" >> $GITHUB_ENV - name: Tests diff --git a/.github/workflows/ci-app-tests.yml b/.github/workflows/ci-app-tests.yml index c35a2eb2b09f4..2e09c9e8c2c9c 100644 --- a/.github/workflows/ci-app-tests.yml +++ b/.github/workflows/ci-app-tests.yml @@ -71,7 +71,7 @@ jobs: key: ${{ runner.os }}-pip-py${{ matrix.python-version }}-${{ matrix.pkg-name }}-${{ matrix.requires }}-${{ hashFiles('requirements/app/base.txt') }} restore-keys: ${{ runner.os }}-pip-py${{ matrix.python-version }}-${{ matrix.pkg-name }}-${{ matrix.requires }}- - - name: switch PyTorch URL + - 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 package @@ -106,7 +106,7 @@ jobs: 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" - - name: switch coverage scope + - name: Switch coverage scope run: python -c "print('COVERAGE_SCOPE=' + str('lightning' if '${{matrix.pkg-name}}' == 'lightning' else 'lightning_app'))" >> $GITHUB_ENV - name: Tests diff --git a/.github/workflows/ci-pytorch-tests.yml b/.github/workflows/ci-pytorch-tests.yml index 785f3abb99ab0..4595bb65cef77 100644 --- a/.github/workflows/ci-pytorch-tests.yml +++ b/.github/workflows/ci-pytorch-tests.yml @@ -119,7 +119,7 @@ jobs: restore-keys: | ${{ runner.os }}-pip-py${{ matrix.python-version }}-${{ matrix.pkg-name }}-${{ matrix.release }}-${{ matrix.requires }}- - - name: switch PyTorch URL + - 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 package & dependencies @@ -168,7 +168,7 @@ jobs: # needs to run outside of `pytest` run: python utilities/test_warnings.py - - name: switch coverage scope + - name: Switch coverage scope run: python -c "print('COVERAGE_SCOPE=' + str('lightning' if '${{matrix.pkg-name}}' == 'lightning' else 'pytorch_lightning'))" >> $GITHUB_ENV - name: Testing PyTorch From cdcc76c44c9a14500491dd52c64186d2ebfe4a5e Mon Sep 17 00:00:00 2001 From: thomas chaton Date: Thu, 27 Oct 2022 08:22:34 +0100 Subject: [PATCH 102/104] update --- src/lightning_app/storage/payload.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/lightning_app/storage/payload.py b/src/lightning_app/storage/payload.py index 88a6099b1f89b..c7dbf5e0fcdeb 100644 --- a/src/lightning_app/storage/payload.py +++ b/src/lightning_app/storage/payload.py @@ -168,6 +168,9 @@ def get(self) -> Any: _logger.debug(f"Attempting to copy {str(response.path)} -> {str(local_path)}") fs.get(str(response.path), str(local_path), recursive=False) + # Ensure the file is properly written + sleep(0.5) + self._value = self.load(local_path) return self._value From b491089e5fc2251ecbfaedf9156e25286e6b8a14 Mon Sep 17 00:00:00 2001 From: Jirka Date: Thu, 27 Oct 2022 10:01:54 +0200 Subject: [PATCH 103/104] ci --- .github/checkgroup.yml | 18 +++++++++--------- .github/workflows/ci-pytorch-tests.yml | 6 +++--- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/checkgroup.yml b/.github/checkgroup.yml index c658a5dc6a347..4e26e870052fe 100644 --- a/.github/checkgroup.yml +++ b/.github/checkgroup.yml @@ -42,11 +42,11 @@ subprojects: - "pl-cpu (windows-2022, pytorch, 3.7, 1.9, oldest)" - "pl-cpu (windows-2022, pytorch, 3.8, 1.13, pre)" - "pl-cpu (macOS-11, lightning, 3.10, 1.12)" - - "pl-cpu (macOS-11, lightning, 3.7, 1.9, oldest)" + #- "pl-cpu (macOS-11, lightning, 3.7, 1.9, oldest)" - "pl-cpu (ubuntu-20.04, lightning, 3.10, 1.12)" - - "pl-cpu (ubuntu-20.04, lightning, 3.7, 1.9, oldest)" + #- "pl-cpu (ubuntu-20.04, lightning, 3.7, 1.9, oldest)" - "pl-cpu (windows-2022, lightning, 3.10, 1.12)" - - "pl-cpu (windows-2022, lightning, 3.7, 1.9, oldest)" + #- "pl-cpu (windows-2022, lightning, 3.7, 1.9, oldest)" - "make-doctest (pytorch)" - "make-html (pytorch)" - "mypy" @@ -80,11 +80,11 @@ subprojects: - "pl-cpu (windows-2022, pytorch, 3.7, 1.9, oldest)" - "pl-cpu (windows-2022, pytorch, 3.8, 1.13, pre)" - "pl-cpu (macOS-11, lightning, 3.10, 1.12)" - - "pl-cpu (macOS-11, lightning, 3.7, 1.9, oldest)" + #- "pl-cpu (macOS-11, lightning, 3.7, 1.9, oldest)" - "pl-cpu (ubuntu-20.04, lightning, 3.10, 1.12)" - - "pl-cpu (ubuntu-20.04, lightning, 3.7, 1.9, oldest)" + #- "pl-cpu (ubuntu-20.04, lightning, 3.7, 1.9, oldest)" - "pl-cpu (windows-2022, lightning, 3.10, 1.12)" - - "pl-cpu (windows-2022, lightning, 3.7, 1.9, oldest)" + #- "pl-cpu (windows-2022, lightning, 3.7, 1.9, oldest)" - id: "pytorch_lightning: Slow" paths: @@ -202,11 +202,11 @@ subprojects: - "pl-cpu (windows-2022, pytorch, 3.7, 1.9, oldest)" - "pl-cpu (windows-2022, pytorch, 3.8, 1.13, pre)" - "pl-cpu (macOS-11, lightning, 3.10, 1.12)" - - "pl-cpu (macOS-11, lightning, 3.7, 1.9, oldest)" + #- "pl-cpu (macOS-11, lightning, 3.7, 1.9, oldest)" - "pl-cpu (ubuntu-20.04, lightning, 3.10, 1.12)" - - "pl-cpu (ubuntu-20.04, lightning, 3.7, 1.9, oldest)" + #- "pl-cpu (ubuntu-20.04, lightning, 3.7, 1.9, oldest)" - "pl-cpu (windows-2022, lightning, 3.10, 1.12)" - - "pl-cpu (windows-2022, lightning, 3.7, 1.9, oldest)" + #- "pl-cpu (windows-2022, lightning, 3.7, 1.9, oldest)" - "make-doctest (pytorch)" - "make-html (pytorch)" - "pytorch-lightning (GPUs)" diff --git a/.github/workflows/ci-pytorch-tests.yml b/.github/workflows/ci-pytorch-tests.yml index 4595bb65cef77..2dec26b2da1b2 100644 --- a/.github/workflows/ci-pytorch-tests.yml +++ b/.github/workflows/ci-pytorch-tests.yml @@ -57,11 +57,11 @@ jobs: - {os: "windows-2022", pkg-name: "lightning", python-version: "3.10", pytorch-version: "1.12"} # "oldest" versions tests, only on minimum Python - {os: "macOS-11", pkg-name: "pytorch", python-version: "3.7", pytorch-version: "1.9", requires: "oldest"} - - {os: "macOS-11", pkg-name: "lightning", python-version: "3.7", pytorch-version: "1.9", requires: "oldest"} + # - {os: "macOS-11", pkg-name: "lightning", python-version: "3.7", pytorch-version: "1.9", requires: "oldest"} # TODO - {os: "ubuntu-20.04", pkg-name: "pytorch", python-version: "3.7", pytorch-version: "1.9", requires: "oldest"} - - {os: "ubuntu-20.04", pkg-name: "lightning", python-version: "3.7", pytorch-version: "1.9", requires: "oldest"} + # - {os: "ubuntu-20.04", pkg-name: "lightning", python-version: "3.7", pytorch-version: "1.9", requires: "oldest"} # TODO - {os: "windows-2022", pkg-name: "pytorch", python-version: "3.7", pytorch-version: "1.9", requires: "oldest"} - - {os: "windows-2022", pkg-name: "lightning", python-version: "3.7", pytorch-version: "1.9", requires: "oldest"} + # - {os: "windows-2022", pkg-name: "lightning", python-version: "3.7", pytorch-version: "1.9", requires: "oldest"} # TODO # release-candidate tests, mixed Python versions - {os: "macOS-11", pkg-name: "pytorch", python-version: "3.10", pytorch-version: "1.13", release: "pre"} - {os: "ubuntu-20.04", pkg-name: "pytorch", python-version: "3.9", pytorch-version: "1.13", release: "pre"} From 7eb085f610d7ecf6ce70109b844f8bd68e565d5b Mon Sep 17 00:00:00 2001 From: Jirka Date: Thu, 27 Oct 2022 12:30:51 +0200 Subject: [PATCH 104/104] ci: lai oldest --- .github/workflows/ci-pytorch-tests.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci-pytorch-tests.yml b/.github/workflows/ci-pytorch-tests.yml index 2dec26b2da1b2..4595bb65cef77 100644 --- a/.github/workflows/ci-pytorch-tests.yml +++ b/.github/workflows/ci-pytorch-tests.yml @@ -57,11 +57,11 @@ jobs: - {os: "windows-2022", pkg-name: "lightning", python-version: "3.10", pytorch-version: "1.12"} # "oldest" versions tests, only on minimum Python - {os: "macOS-11", pkg-name: "pytorch", python-version: "3.7", pytorch-version: "1.9", requires: "oldest"} - # - {os: "macOS-11", pkg-name: "lightning", python-version: "3.7", pytorch-version: "1.9", requires: "oldest"} # TODO + - {os: "macOS-11", pkg-name: "lightning", python-version: "3.7", pytorch-version: "1.9", requires: "oldest"} - {os: "ubuntu-20.04", pkg-name: "pytorch", python-version: "3.7", pytorch-version: "1.9", requires: "oldest"} - # - {os: "ubuntu-20.04", pkg-name: "lightning", python-version: "3.7", pytorch-version: "1.9", requires: "oldest"} # TODO + - {os: "ubuntu-20.04", pkg-name: "lightning", python-version: "3.7", pytorch-version: "1.9", requires: "oldest"} - {os: "windows-2022", pkg-name: "pytorch", python-version: "3.7", pytorch-version: "1.9", requires: "oldest"} - # - {os: "windows-2022", pkg-name: "lightning", python-version: "3.7", pytorch-version: "1.9", requires: "oldest"} # TODO + - {os: "windows-2022", pkg-name: "lightning", python-version: "3.7", pytorch-version: "1.9", requires: "oldest"} # release-candidate tests, mixed Python versions - {os: "macOS-11", pkg-name: "pytorch", python-version: "3.10", pytorch-version: "1.13", release: "pre"} - {os: "ubuntu-20.04", pkg-name: "pytorch", python-version: "3.9", pytorch-version: "1.13", release: "pre"}