Skip to content

Commit 1ad68e5

Browse files
authored
Sync with master changes (#16169)
1 parent 4f02198 commit 1ad68e5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+606
-371
lines changed

.actions/assistant.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ def _augment_requirement(ln: str, comment_char: str = "#", unfreeze: str = "all"
6060
Returns:
6161
adjusted requirement
6262
63-
>>> _augment_requirement("arrow<=1.2.2,>=1.2.0 # anything", unfreeze="")
63+
>>> _augment_requirement("arrow<=1.2.2,>=1.2.0 # anything", unfreeze="none")
6464
'arrow<=1.2.2,>=1.2.0'
65-
>>> _augment_requirement("arrow<=1.2.2,>=1.2.0 # strict", unfreeze="")
65+
>>> _augment_requirement("arrow<=1.2.2,>=1.2.0 # strict", unfreeze="none")
6666
'arrow<=1.2.2,>=1.2.0 # strict'
6767
>>> _augment_requirement("arrow<=1.2.2,>=1.2.0 # my name", unfreeze="all")
6868
'arrow>=1.2.0'
@@ -79,6 +79,7 @@ def _augment_requirement(ln: str, comment_char: str = "#", unfreeze: str = "all"
7979
>>> _augment_requirement("arrow", unfreeze="major")
8080
'arrow'
8181
"""
82+
assert unfreeze in {"none", "major", "all"}
8283
# filer all comments
8384
if comment_char in ln:
8485
comment = ln[ln.index(comment_char) :]
@@ -88,7 +89,7 @@ def _augment_requirement(ln: str, comment_char: str = "#", unfreeze: str = "all"
8889
is_strict = False
8990
req = ln.strip()
9091
# skip directly installed dependencies
91-
if not req or req.startswith("http") or "@" in req:
92+
if not req or any(c in req for c in ["http:", "https:", "@"]):
9293
return ""
9394
# extract the major version from all listed versions
9495
if unfreeze == "major":
@@ -99,7 +100,7 @@ def _augment_requirement(ln: str, comment_char: str = "#", unfreeze: str = "all"
99100
ver_major = None
100101

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

207209

208210
def _load_aggregate_requirements(req_dir: str = "requirements", freeze_requirements: bool = False) -> None:
209-
"""Load all base requirements from all particular packages and prune duplicates."""
211+
"""Load all base requirements from all particular packages and prune duplicates.
212+
213+
>>> _load_aggregate_requirements(os.path.join(_PROJECT_ROOT, "requirements"))
214+
"""
210215
requires = [
211-
load_requirements(d, file_name="base.txt", unfreeze=not freeze_requirements)
216+
# TODO: consider passing unfreeze as string instead
217+
load_requirements(d, file_name="base.txt", unfreeze="none" if freeze_requirements else "major")
212218
for d in glob.glob(os.path.join(req_dir, "*"))
213219
# skip empty folder as git artefacts, and resolving Will's special issue
214220
if os.path.isdir(d) and len(glob.glob(os.path.join(d, "*"))) > 0 and "__pycache__" not in d
215221
]
216222
if not requires:
217223
return None
218224
# TODO: add some smarter version aggregation per each package
219-
requires = list(chain(*requires))
225+
requires = sorted(set(chain(*requires)))
220226
with open(os.path.join(req_dir, "base.txt"), "w") as fp:
221-
fp.writelines([ln + os.linesep for ln in requires])
227+
fp.writelines([ln + os.linesep for ln in requires] + [os.linesep])
222228

223229

224230
def _retrieve_files(directory: str, *ext: str) -> List[str]:
@@ -333,7 +339,7 @@ def _prune_packages(req_file: str, packages: Sequence[str]) -> None:
333339
if req.name not in packages:
334340
final.append(line)
335341
print(final)
336-
path.write_text("\n".join(final))
342+
path.write_text("\n".join(final) + "\n")
337343

338344
@staticmethod
339345
def _replace_min(fname: str) -> None:

.azure/app-cloud-e2e.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,15 @@ jobs:
114114
displayName: 'Info'
115115
116116
# TODO: we are testing it as `lightning`, so add also version for `lightning_app`
117-
- 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
117+
- bash: |
118+
pip install -e .[test] \
119+
-f https://download.pytorch.org/whl/cpu/torch_stable.html
120+
env:
121+
FREEZE_REQUIREMENTS: "1"
118122
displayName: 'Install Lightning & dependencies'
119123
120124
- bash: |
121-
python -m pip install playwright
125+
pip install playwright
122126
python -m playwright install # --with-deps
123127
displayName: 'Install Playwright system dependencies'
124128
@@ -131,7 +135,6 @@ jobs:
131135
condition: eq(variables['name'], 'quick_start')
132136
displayName: 'Clone Quick start Repo'
133137
134-
135138
# - bash: |
136139
# rm -rf examples/app_template_jupyterlab || true
137140
# git clone https://github.com/Lightning-AI/LAI-lightning-template-jupyterlab-App examples/app_template_jupyterlab
@@ -145,7 +148,7 @@ jobs:
145148
condition: eq(variables['name'], 'template_react_ui')
146149
displayName: 'Clone Template React UI Repo'
147150
148-
- bash: python -m pip install -q -r .actions/requirements.txt
151+
- bash: pip install -q -r .actions/requirements.txt
149152
displayName: 'Install assistant dependencies'
150153

151154
# Fix imports to use `lightning` instead of `lightning_app` since we install lightning only ATM

.azure/gpu-tests-fabric.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,9 @@ jobs:
7575
7676
- bash: |
7777
PYTORCH_VERSION=$(python -c "import torch; print(torch.__version__.split('+')[0])")
78-
python ./requirements/pytorch/adjust-versions.py requirements/fabric/base.txt ${PYTORCH_VERSION}
79-
python ./requirements/pytorch/adjust-versions.py requirements/fabric/examples.txt ${PYTORCH_VERSION}
78+
for fpath in `ls requirements/**/*.txt`; do \
79+
python ./requirements/pytorch/adjust-versions.py $fpath ${PYTORCH_VERSION}; \
80+
done
8081
displayName: 'Adjust dependencies'
8182
8283
- bash: |

.azure/gpu-tests-pytorch.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,12 @@ jobs:
8888
displayName: 'Image info & NVIDIA'
8989
9090
- bash: |
91-
python -c "fname = 'requirements/pytorch/strategies.txt' ; lines = [line for line in open(fname).readlines() if 'bagua' not in line] ; open(fname, 'w').writelines(lines)"
92-
python -c "fname = 'requirements/pytorch/strategies.txt' ; lines = [line for line in open(fname).readlines() if 'colossalai' not in line] ; open(fname, 'w').writelines(lines)"
91+
python .actions/assistant.py requirements_prune_pkgs --packages="[bagua,colossalai]"
9392
9493
PYTORCH_VERSION=$(python -c "import torch; print(torch.__version__.split('+')[0])")
95-
python ./requirements/pytorch/adjust-versions.py requirements/pytorch/base.txt ${PYTORCH_VERSION}
96-
python ./requirements/pytorch/adjust-versions.py requirements/pytorch/extra.txt ${PYTORCH_VERSION}
97-
python ./requirements/pytorch/adjust-versions.py requirements/pytorch/examples.txt ${PYTORCH_VERSION}
94+
for fpath in `ls requirements/**/*.txt`; do \
95+
python ./requirements/pytorch/adjust-versions.py $fpath ${PYTORCH_VERSION}; \
96+
done
9897
displayName: 'Adjust dependencies'
9998
10099
- bash: pip install -e .[dev,examples] --find-links ${TORCH_URL}

.azure/ipu-tests.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,9 @@ jobs:
6969
displayName: "Reset IPU devices"
7070
7171
- bash: |
72-
python ./requirements/pytorch/adjust-versions.py requirements/pytorch/extra.txt
73-
python ./requirements/pytorch/adjust-versions.py requirements/pytorch/examples.txt
72+
for fpath in `ls requirements/**/*.txt`; do \
73+
python ./requirements/pytorch/adjust-versions.py $fpath; \
74+
done
7475
pip install -e .[dev]
7576
pip list
7677
env:

.github/actions/pkg-install/action.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,10 @@ runs:
3333
python -c "import ${{ env.PKG_IMPORT }}; print(${{ env.PKG_IMPORT }}.__version__)"
3434
shell: bash
3535

36-
# FIXME !!!
37-
# - name: Install package - archive
38-
# working-directory: ${{ inputs.pkg-folder }}
39-
# run: |
40-
# pip install ${PKG_SOURCE} ${{ inputs.pip-flags }}
41-
# pip list | grep lightning
42-
# python -c "import ${{ env.PKG_IMPORT }}; print(${{ env.PKG_IMPORT }}.__version__)"
43-
# shell: bash
36+
- name: Install package - archive
37+
working-directory: ${{ inputs.pkg-folder }}
38+
run: |
39+
pip install ${PKG_SOURCE} ${{ inputs.pip-flags }}
40+
pip list | grep lightning
41+
python -c "import ${{ env.PKG_IMPORT }}; print(${{ env.PKG_IMPORT }}.__version__)"
42+
shell: bash

.github/workflows/_build-packages.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ jobs:
5050
python-version: 3.9
5151

5252
- run: python -c "print('NB_DIRS=' + str(2 if '${{ matrix.pkg-name }}' == 'pytorch' else 1))" >> $GITHUB_ENV
53-
- uses: ./.github/actions/pkg-check
53+
- name: Build & check package
54+
uses: ./.github/actions/pkg-check
5455
with:
5556
pkg-name: ${{ matrix.pkg-name }}
5657
nb-dirs: ${{ env.NB_DIRS }}

.github/workflows/ci-examples-app.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,13 @@ jobs:
7272
key: ${{ runner.os }}-pip-py${{ matrix.python-version }}-${{ matrix.pkg-name }}-${{ matrix.requires }}-${{ hashFiles('requirements/app/base.txt') }}
7373
restore-keys: ${{ runner.os }}-pip-py${{ matrix.python-version }}-${{ matrix.pkg-name }}-${{ matrix.requires }}-
7474

75-
- name: Install dependencies
75+
- name: Install Lightning package & dependencies
76+
env:
77+
PACKAGE_NAME: ${{ matrix.pkg-name }}
78+
FREEZE_REQUIREMENTS: 1
7679
run: |
77-
pip --version
78-
pip install -r requirements/app/devel.txt --find-links https://download.pytorch.org/whl/cpu/torch_stable.html
80+
# do not use `-e` because it will make both packages available since it adds `src` to `sys.path` automatically
81+
pip install .[dev] --find-links https://download.pytorch.org/whl/cpu/torch_stable.html
7982
pip list
8083
8184
- name: Setup Node.js
@@ -86,12 +89,6 @@ jobs:
8689
- name: Install Yarn
8790
run: npm install -g yarn
8891

89-
- name: Install Lightning package
90-
env:
91-
PACKAGE_NAME: ${{ matrix.pkg-name }}
92-
# do not use -e because it will make both packages available since it adds `src` to `sys.path` automatically
93-
run: pip install .
94-
9592
- name: Adjust tests
9693
if: ${{ matrix.pkg-name == 'lightning' }}
9794
run: |
@@ -116,7 +113,10 @@ jobs:
116113
AWS_DEFAULT_REGION: us-east-1
117114
PYTEST_ARTIFACT: results-${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.requires }}.xml
118115
run: |
119-
coverage run --source ${COVERAGE_SCOPE} -m pytest -m "not cloud" tests_examples_app --timeout=300 -vvvv --junitxml=$PYTEST_ARTIFACT --durations=0
116+
python -m coverage run --source ${COVERAGE_SCOPE} \
117+
-m pytest -m "not cloud" tests_examples_app \
118+
--timeout=300 --durations=0 -vvvv \
119+
--junitxml=$PYTEST_ARTIFACT
120120
121121
- name: Upload pytest test results
122122
uses: actions/upload-artifact@v3

.github/workflows/ci-pkg-install.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ jobs:
5858

5959
- run: |
6060
python -c "print('PKG_DIR=' + {'notset': 'lightning'}.get('${{matrix.pkg-name}}', '${{matrix.pkg-name}}'))" >> $GITHUB_ENV
61-
- uses: ./.github/actions/pkg-install
61+
- name: Install package - wheel & archive
62+
uses: ./.github/actions/pkg-install
6263
with:
6364
pkg-folder: dist/${{ env.PKG_DIR }}
6465
pkg-name: ${{ matrix.pkg-name }}

.github/workflows/ci-tests-app.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ concurrency:
2222
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref }}
2323
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}
2424

25-
env:
26-
FREEZE_REQUIREMENTS: 1
27-
2825
defaults:
2926
run:
3027
shell: bash
@@ -77,11 +74,12 @@ jobs:
7774
- name: Switch PyTorch URL
7875
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
7976

80-
- name: Install package & depenencies
77+
- name: Install package & dependencies
8178
env:
8279
PACKAGE_NAME: ${{ matrix.pkg-name }}
80+
FREEZE_REQUIREMENTS: 1
8381
run: |
84-
pip install -e . -r requirements/app/devel.txt -U -q --find-links ${TORCH_URL}
82+
pip install -e .[dev] --upgrade --find-links ${TORCH_URL}
8583
pip list
8684
8785
- name: Setup Node.js
@@ -117,7 +115,10 @@ jobs:
117115
AWS_DEFAULT_REGION: us-east-1
118116
PYTEST_ARTIFACT: results-${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.requires }}.xml
119117
run: |
120-
coverage run --source ${COVERAGE_SCOPE} -m pytest -m "not cloud" tests_app --timeout=300 -vvvv --junitxml=$PYTEST_ARTIFACT --durations=50
118+
python -m coverage run --source ${COVERAGE_SCOPE} \
119+
-m pytest -m "not cloud" tests_app \
120+
--timeout=300 -vvvv --durations=50 \
121+
--junitxml=$PYTEST_ARTIFACT
121122
122123
- name: Upload pytest test results
123124
uses: actions/upload-artifact@v3

0 commit comments

Comments
 (0)