Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unify extras & minor CI cleaning: move env. var #15942

Merged
merged 47 commits into from
Dec 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
1c59175
move freeze & rerun
Borda Dec 7, 2022
0d7beb8
typo
Borda Dec 7, 2022
4599748
-m
Borda Dec 7, 2022
876818f
Apply suggestions from code review
Borda Dec 17, 2022
16c6ead
examples
Borda Dec 17, 2022
5e62232
extras
Borda Dec 17, 2022
ad96708
ci
Borda Dec 17, 2022
6c0e0ed
install
Borda Dec 17, 2022
c0a22da
Merge branch 'master' into ci/tests-rerun
Borda Dec 19, 2022
6dda30e
Merge branch 'master' into ci/tests-rerun
Borda Dec 20, 2022
ec55cd7
drop rerun
Borda Dec 20, 2022
7ce4d69
typo
Borda Dec 20, 2022
caeda13
Apply suggestions from code review
Borda Dec 20, 2022
a0ef759
examples
Borda Dec 21, 2022
e447df4
Merge branch 'master' into ci/tests-rerun
Borda Dec 21, 2022
89e09c5
Merge branch 'ci/tests-rerun' of https://github.com/PyTorchLightning/…
Borda Dec 21, 2022
d355529
Merge branch 'master' into ci/tests-rerun
Borda Dec 21, 2022
ebafd4c
Merge branch 'master' into ci/tests-rerun
Borda Dec 21, 2022
a43b5ac
strategies
Borda Dec 21, 2022
7f018bc
drop
Borda Dec 21, 2022
500e7c6
freeze
Borda Dec 21, 2022
f7732ae
Merge branch 'master' into ci/tests-rerun
Borda Dec 21, 2022
ff631a7
typing
Borda Dec 21, 2022
d349384
typing
Borda Dec 21, 2022
851d93b
Merge branch 'master' into ci/tests-rerun
Borda Dec 21, 2022
28734ff
Merge branch 'master' into ci/tests-rerun
Borda Dec 22, 2022
2752be5
drop
Borda Dec 22, 2022
abc2fdf
typing
Borda Dec 22, 2022
3a85230
revert Literal
Borda Dec 22, 2022
42bcc23
all
Borda Dec 22, 2022
f7523de
dev
Borda Dec 22, 2022
1484987
Merge branch 'master' into ci/tests-rerun
Borda Dec 22, 2022
243c3e2
major
Borda Dec 22, 2022
851328d
fix httpx
Borda Dec 22, 2022
464697f
major
Borda Dec 22, 2022
d2a21f7
Apply suggestions from code review
Borda Dec 22, 2022
c959265
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 22, 2022
c95bec7
.
Borda Dec 22, 2022
631891e
Merge branch 'ci/tests-rerun' of https://github.com/PyTorchLightning/…
Borda Dec 22, 2022
62c7e4a
extra
Borda Dec 22, 2022
01a5b70
Empty-Commit
Borda Dec 22, 2022
8d9d0a7
??
Borda Dec 22, 2022
850c7b7
?
Borda Dec 22, 2022
e25e9dc
wheel!
Borda Dec 22, 2022
7ce9bd8
wheel!?!
Borda Dec 22, 2022
d4b78c2
...
Borda Dec 22, 2022
a96cb75
freeze
Borda Dec 22, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions .actions/assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ def _augment_requirement(ln: str, comment_char: str = "#", unfreeze: str = "all"
Returns:
adjusted requirement

>>> _augment_requirement("arrow<=1.2.2,>=1.2.0 # anything", unfreeze="")
>>> _augment_requirement("arrow<=1.2.2,>=1.2.0 # anything", unfreeze="none")
'arrow<=1.2.2,>=1.2.0'
>>> _augment_requirement("arrow<=1.2.2,>=1.2.0 # strict", unfreeze="")
>>> _augment_requirement("arrow<=1.2.2,>=1.2.0 # strict", unfreeze="none")
'arrow<=1.2.2,>=1.2.0 # strict'
>>> _augment_requirement("arrow<=1.2.2,>=1.2.0 # my name", unfreeze="all")
'arrow>=1.2.0'
Expand All @@ -79,6 +79,7 @@ def _augment_requirement(ln: str, comment_char: str = "#", unfreeze: str = "all"
>>> _augment_requirement("arrow", unfreeze="major")
'arrow'
"""
assert unfreeze in {"none", "major", "all"}
# filer all comments
if comment_char in ln:
comment = ln[ln.index(comment_char) :]
Expand All @@ -88,7 +89,7 @@ def _augment_requirement(ln: str, comment_char: str = "#", unfreeze: str = "all"
is_strict = False
req = ln.strip()
# skip directly installed dependencies
if not req or req.startswith("http") or "@" in req:
if not req or any(c in req for c in ["http:", "https:", "@"]):
return ""
# extract the major version from all listed versions
if unfreeze == "major":
Expand All @@ -99,7 +100,7 @@ def _augment_requirement(ln: str, comment_char: str = "#", unfreeze: str = "all"
ver_major = None

# remove version restrictions unless they are strict
if unfreeze and "<" in req and not is_strict:
if unfreeze != "none" and "<" in req and not is_strict:
req = re.sub(r",? *<=? *[\d\.\*]+,? *", "", req).strip()
if ver_major is not None and not is_strict:
# add , only if there are already some versions
Expand All @@ -121,6 +122,7 @@ def load_requirements(
>>> load_requirements(path_req, "docs.txt", unfreeze="major") # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
['sphinx>=4.0, <6.0 # strict', ...]
"""
assert unfreeze in {"none", "major", "all"}
with open(os.path.join(path_dir, file_name)) as file:
lines = [ln.strip() for ln in file.readlines()]
reqs = [_augment_requirement(ln, comment_char=comment_char, unfreeze=unfreeze) for ln in lines]
Expand Down Expand Up @@ -206,17 +208,21 @@ def _download_frontend(pkg_path: str):


def _load_aggregate_requirements(req_dir: str = "requirements", freeze_requirements: bool = False) -> None:
"""Load all base requirements from all particular packages and prune duplicates."""
"""Load all base requirements from all particular packages and prune duplicates.

>>> _load_aggregate_requirements(os.path.join(_PROJECT_ROOT, "requirements"))
"""
requires = [
load_requirements(d, file_name="base.txt", unfreeze=not freeze_requirements)
# TODO: consider passing unfreeze as string instead
load_requirements(d, file_name="base.txt", unfreeze="none" if freeze_requirements else "major")
for d in glob.glob(os.path.join(req_dir, "*"))
# skip empty folder as git artefacts, and resolving Will's special issue
if os.path.isdir(d) and len(glob.glob(os.path.join(d, "*"))) > 0 and "__pycache__" not in d
]
if not requires:
return None
# TODO: add some smarter version aggregation per each package
requires = list(chain(*requires))
requires = sorted(set(chain(*requires)))
with open(os.path.join(req_dir, "base.txt"), "w") as fp:
fp.writelines([ln + os.linesep for ln in requires] + [os.linesep])

Expand Down
11 changes: 7 additions & 4 deletions .azure/app-cloud-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,15 @@ jobs:
displayName: 'Info'

# 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
- bash: |
pip install -e .[test] \
-f https://download.pytorch.org/whl/cpu/torch_stable.html
env:
FREEZE_REQUIREMENTS: "1"
displayName: 'Install Lightning & dependencies'

- bash: |
python -m pip install playwright
pip install playwright
python -m playwright install # --with-deps
displayName: 'Install Playwright system dependencies'

Expand All @@ -130,7 +134,6 @@ jobs:
condition: eq(variables['name'], 'quick_start')
displayName: 'Clone Quick start Repo'


# - bash: |
# rm -rf examples/app_template_jupyterlab || true
# git clone https://github.com/Lightning-AI/LAI-lightning-template-jupyterlab-App examples/app_template_jupyterlab
Expand All @@ -144,7 +147,7 @@ jobs:
condition: eq(variables['name'], 'template_react_ui')
displayName: 'Clone Template React UI Repo'

- bash: python -m pip install -q -r .actions/requirements.txt
- bash: 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
Expand Down
1 change: 1 addition & 0 deletions .azure/gpu-tests-lite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ jobs:
- bash: python -m coverage run --source lightning_lite -m pytest --ignore benchmarks -v --junitxml=$(Build.StagingDirectory)/test-results.xml --durations=50
env:
PL_RUN_CUDA_TESTS: "1"
CUDA_LAUNCH_BLOCKING: "1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be added. This will slow down tests and is meant for debugging only

workingDirectory: tests/tests_lite
displayName: 'Testing: Lite standard'
timeoutInMinutes: "10"
Expand Down
20 changes: 10 additions & 10 deletions .github/workflows/ci-examples-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,13 @@ 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: Install dependencies
- name: Install Lightning package & dependencies
env:
PACKAGE_NAME: ${{ matrix.pkg-name }}
FREEZE_REQUIREMENTS: 1
run: |
pip --version
pip install -r requirements/app/devel.txt --find-links https://download.pytorch.org/whl/cpu/torch_stable.html
# do not use `-e` because it will make both packages available since it adds `src` to `sys.path` automatically
pip install .[dev] --find-links https://download.pytorch.org/whl/cpu/torch_stable.html
pip list

- name: Setup Node.js
Expand All @@ -86,12 +89,6 @@ jobs:
- name: Install Yarn
run: npm install -g yarn

- name: Install Lightning package
env:
PACKAGE_NAME: ${{ matrix.pkg-name }}
# do not use -e because it will make both packages available since it adds `src` to `sys.path` automatically
run: pip install .

- name: Adjust tests
if: ${{ matrix.pkg-name == 'lightning' }}
run: |
Expand All @@ -116,7 +113,10 @@ jobs:
AWS_DEFAULT_REGION: us-east-1
PYTEST_ARTIFACT: results-${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.requires }}.xml
run: |
coverage run --source ${COVERAGE_SCOPE} -m pytest -m "not cloud" tests_examples_app --timeout=300 -vvvv --junitxml=$PYTEST_ARTIFACT --durations=0
python -m coverage run --source ${COVERAGE_SCOPE} \
-m pytest -m "not cloud" tests_examples_app \
--timeout=300 --durations=0 -vvvv \
--junitxml=$PYTEST_ARTIFACT

- name: Upload pytest test results
uses: actions/upload-artifact@v3
Expand Down
13 changes: 7 additions & 6 deletions .github/workflows/ci-tests-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}

env:
FREEZE_REQUIREMENTS: 1

defaults:
run:
shell: bash
Expand Down Expand Up @@ -77,11 +74,12 @@ jobs:
- name: Switch PyTorch URL
run: python -c "print('TORCH_URL=https://download.pytorch.org/whl/' + str('test/cpu/torch_test.html' if '${{matrix.release}}' == 'pre' else 'cpu/torch_stable.html'))" >> $GITHUB_ENV

- name: Install package & depenencies
- name: Install package & dependencies
env:
PACKAGE_NAME: ${{ matrix.pkg-name }}
FREEZE_REQUIREMENTS: 1
run: |
pip install -e . -r requirements/app/devel.txt -U -q --find-links ${TORCH_URL}
pip install -e .[dev] --upgrade --find-links ${TORCH_URL}
pip list

- name: Setup Node.js
Expand Down Expand Up @@ -117,7 +115,10 @@ jobs:
AWS_DEFAULT_REGION: us-east-1
PYTEST_ARTIFACT: results-${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.requires }}.xml
run: |
coverage run --source ${COVERAGE_SCOPE} -m pytest -m "not cloud" tests_app --timeout=300 -vvvv --junitxml=$PYTEST_ARTIFACT --durations=50
python -m coverage run --source ${COVERAGE_SCOPE} \
-m pytest -m "not cloud" tests_app \
--timeout=300 -vvvv --durations=50 \
--junitxml=$PYTEST_ARTIFACT

- name: Upload pytest test results
uses: actions/upload-artifact@v3
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/ci-tests-lite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,9 @@ jobs:
- name: Install package & dependencies
env:
PACKAGE_NAME: ${{ matrix.pkg-name }}
FREEZE_REQUIREMENTS: 1
run: |
pip install -e . "pytest-timeout" -r requirements/lite/devel.txt --upgrade --find-links ${TORCH_URL}
pip install -e .[test] "pytest-timeout" --upgrade --find-links ${TORCH_URL}
pip list

- name: Adjust tests
Expand All @@ -133,7 +134,10 @@ jobs:
- name: Testing Lite
working-directory: tests/tests_lite
# NOTE: do not include coverage report here, see: https://github.com/nedbat/coveragepy/issues/1003
run: coverage run --source ${COVERAGE_SCOPE} -m pytest -v --timeout=30 --durations=50 --junitxml=results-${{ runner.os }}-py${{ matrix.python-version }}-${{ matrix.requires }}-${{ matrix.release }}.xml
run: |
python -m coverage run --source ${COVERAGE_SCOPE} \
-m pytest -v --timeout=30 --durations=50 \
--junitxml=results-${{ runner.os }}-py${{ matrix.python-version }}-${{ matrix.requires }}-${{ matrix.release }}.xml

- name: Upload pytest results
if: failure()
Expand Down
12 changes: 10 additions & 2 deletions .github/workflows/ci-tests-pytorch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,11 @@ jobs:
- name: Install package & dependencies
env:
PACKAGE_NAME: ${{ matrix.pkg-name }}
FREEZE_REQUIREMENTS: 1
run: |
pip install -e . "pytest-timeout" -r requirements/pytorch/devel.txt --upgrade --find-links ${TORCH_URL}
pip install -e .[extra,test] "pytest-timeout" --upgrade --find-links ${TORCH_URL}
# TODO: installing the strategies from file as deepspeed expects already installed PyTorch and extras do not install base first
# pip install -r requirements/pytorch/strategies.txt --find-links ${TORCH_URL}
pip list

- name: Reinstall Horovod if necessary
Expand Down Expand Up @@ -184,7 +187,12 @@ jobs:
- name: Testing PyTorch
working-directory: tests/tests_pytorch
# NOTE: do not include coverage report here, see: https://github.com/nedbat/coveragepy/issues/1003
run: coverage run --source ${COVERAGE_SCOPE} -m pytest -v --timeout=${TEST_TIMEOUT} --durations=50 --junitxml=results-${{ runner.os }}-py${{ matrix.python-version }}-${{ matrix.requires }}-${{ matrix.release }}.xml
run: |
python -m coverage run --source ${COVERAGE_SCOPE} \
-m pytest . -v \
--timeout=${TEST_TIMEOUT} --durations=50 \
--reruns 3 --reruns-delay 1 \
--junitxml=results-${{ runner.os }}-py${{ matrix.python-version }}-${{ matrix.requires }}-${{ matrix.release }}.xml

- name: Upload pytest results
if: failure()
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/docs-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref }}
cancel-in-progress: ${{ ! (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release/')) }}

env:
FREEZE_REQUIREMENTS: "1"

defaults:
run:
shell: bash
Expand Down Expand Up @@ -78,6 +75,8 @@ jobs:
- name: Install LAI package
# This is needed as App docs is heavily using/referring to lightning package
if: ${{ matrix.pkg-name == 'app' }}
env:
FREEZE_REQUIREMENTS: 1
run: |
pip install -e . -U -v -f https://download.pytorch.org/whl/cpu/torch_stable.html -f pypi

Expand All @@ -92,6 +91,7 @@ jobs:
- name: Install this package
env:
PACKAGE_NAME: ${{ matrix.pkg-name }}
FREEZE_REQUIREMENTS: 1
run: |
pip install -e .[extra,cloud,ui] -U -r requirements/${{ matrix.pkg-name }}/docs.txt -f pypi
pip list
Expand All @@ -110,8 +110,6 @@ jobs:
fail-fast: false
matrix:
pkg-name: ["app", "pytorch"]
env:
FREEZE_REQUIREMENTS: "1"
steps:
- uses: actions/checkout@v3
with:
Expand Down Expand Up @@ -145,6 +143,7 @@ jobs:
- name: Install package & dependencies
env:
PACKAGE_NAME: ${{ matrix.pkg-name }}
FREEZE_REQUIREMENTS: 1
run: |
sudo apt-get update
sudo apt-get install -y cmake pandoc texlive-latex-extra dvipng texlive-pictures
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/docs-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ on:
- ".github/workflows/docs-deploy.yml"
# TODO: this workflow is just for debugging. extend the paths that should trigger it

env:
FREEZE_REQUIREMENTS: 1

defaults:
run:
shell: bash
Expand Down Expand Up @@ -48,6 +45,8 @@ jobs:
${{ runner.os }}-deploy-docs-pip-

- name: Install package & dependencies
env:
FREEZE_REQUIREMENTS: 1
run: |
sudo apt-get update
sudo apt-get install -y cmake pandoc
Expand Down
17 changes: 9 additions & 8 deletions src/lightning/__setup__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def _prepare_extras() -> Dict[str, Any]:
# From remote, use like `pip install pytorch-lightning[dev, docs]`
# From local copy of repo, use like `pip install ".[dev, docs]"`
req_files = [Path(p) for p in glob.glob(os.path.join(_PATH_REQUIREMENTS, "*", "*.txt"))]
common_args = dict(unfreeze="major" if _FREEZE_REQUIREMENTS else "all")
common_args = dict(unfreeze="none" if _FREEZE_REQUIREMENTS else "major")
extras = {
f"{p.parent.name}-{p.stem}": _ASSISTANT.load_requirements(file_name=p.name, path_dir=p.parent, **common_args)
for p in req_files
Expand All @@ -41,12 +41,11 @@ def _prepare_extras() -> Dict[str, Any]:
for extra in list(extras):
name = "-".join(extra.split("-")[1:])
extras[name] = extras.get(name, []) + extras[extra]
# todo
# extras["extra"] = extras["cloud"] + extras["ui"]
# extras["dev"] = extras["extra"] + extras["test"] # + extras['docs']
# extras["all"] = extras["dev"]
extras = {name: list(set(reqs)) for name, reqs in extras.items()}
print("The extras are", extras)
extras["extra"] += extras["cloud"] + extras["ui"] + extras["components"]
extras["all"] = extras["extra"]
extras["dev"] = extras["all"] + extras["test"] # + extras['docs']
extras = {name: sorted(set(reqs)) for name, reqs in extras.items()}
print("The extras are: ", extras)
return extras


Expand Down Expand Up @@ -84,7 +83,9 @@ def _setup_args() -> Dict[str, Any]:
],
},
setup_requires=[],
install_requires=_ASSISTANT.load_requirements(_PATH_REQUIREMENTS, unfreeze="all"),
install_requires=_ASSISTANT.load_requirements(
_PATH_REQUIREMENTS, unfreeze="none" if _FREEZE_REQUIREMENTS else "major"
),
extras_require=_prepare_extras(),
project_urls={
"Bug Tracker": "https://github.com/Lightning-AI/lightning/issues",
Expand Down
22 changes: 12 additions & 10 deletions src/lightning_app/__setup__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import glob
import os
from importlib.util import module_from_spec, spec_from_file_location
from pathlib import Path
from types import ModuleType
from typing import Any, Dict

Expand Down Expand Up @@ -32,16 +34,16 @@ def _prepare_extras() -> Dict[str, Any]:
# Define package extras. These are only installed if you specify them.
# From remote, use like `pip install pytorch-lightning[dev, docs]`
# From local copy of repo, use like `pip install ".[dev, docs]"`
common_args = dict(path_dir=_PATH_REQUIREMENTS, unfreeze="major" if _FREEZE_REQUIREMENTS else "all")
req_files = [Path(p) for p in glob.glob(os.path.join(_PATH_REQUIREMENTS, "*.txt"))]
common_args = dict(path_dir=_PATH_REQUIREMENTS, unfreeze="none" if _FREEZE_REQUIREMENTS else "major")
extras = {
# 'docs': load_requirements(file_name='docs.txt'),
"cloud": assistant.load_requirements(file_name="cloud.txt", **common_args),
"ui": assistant.load_requirements(file_name="ui.txt", **common_args),
"test": assistant.load_requirements(file_name="test.txt", **common_args),
p.stem: assistant.load_requirements(file_name=p.name, **common_args)
for p in req_files
if p.name not in ("docs.txt", "devel.txt", "base.txt")
}
extras["extra"] = extras["cloud"] + extras["ui"]
extras["dev"] = extras["extra"] + extras["test"] # + extras['docs']
extras["all"] = extras["dev"]
extras["extra"] = extras["cloud"] + extras["ui"] + extras["components"]
extras["all"] = extras["extra"]
extras["dev"] = extras["all"] + extras["test"] # + extras['docs']
return extras


Expand Down Expand Up @@ -78,9 +80,9 @@ def _setup_args() -> Dict[str, Any]:
"lightning = lightning_app.cli.lightning_cli:main",
],
},
setup_requires=["wheel"],
setup_requires=[],
install_requires=assistant.load_requirements(
_PATH_REQUIREMENTS, unfreeze="major" if _FREEZE_REQUIREMENTS else "all"
_PATH_REQUIREMENTS, unfreeze="none" if _FREEZE_REQUIREMENTS else "major"
),
extras_require=_prepare_extras(),
project_urls={
Expand Down
Loading