Skip to content

Commit 186b799

Browse files
authored
ci: adjust version in all requirements (#16100)
1 parent 8bc78a6 commit 186b799

File tree

9 files changed

+28
-52
lines changed

9 files changed

+28
-52
lines changed

.actions/assistant.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ def _load_aggregate_requirements(req_dir: str = "requirements", freeze_requireme
218218
# TODO: add some smarter version aggregation per each package
219219
requires = list(chain(*requires))
220220
with open(os.path.join(req_dir, "base.txt"), "w") as fp:
221-
fp.writelines([ln + os.linesep for ln in requires])
221+
fp.writelines([ln + os.linesep for ln in requires] + [os.linesep])
222222

223223

224224
def _retrieve_files(directory: str, *ext: str) -> List[str]:
@@ -333,7 +333,7 @@ def _prune_packages(req_file: str, packages: Sequence[str]) -> None:
333333
if req.name not in packages:
334334
final.append(line)
335335
print(final)
336-
path.write_text("\n".join(final))
336+
path.write_text("\n".join(final) + "\n")
337337

338338
@staticmethod
339339
def _replace_min(fname: str) -> None:

.azure/gpu-tests-lite.yml

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

.azure/gpu-tests-pytorch.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,12 @@ jobs:
8787
displayName: 'Image info & NVIDIA'
8888
8989
- bash: |
90-
python -c "fname = 'requirements/pytorch/strategies.txt' ; lines = [line for line in open(fname).readlines() if 'horovod' not in line] ; open(fname, 'w').writelines(lines)"
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)"
90+
python .actions/assistant.py requirements_prune_pkgs --packages="[horovod,bagua,colossalai]"
9391
9492
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}
93+
for fpath in `ls requirements/**/*.txt`; do \
94+
python ./requirements/pytorch/adjust-versions.py $fpath ${PYTORCH_VERSION}; \
95+
done
9896
displayName: 'Adjust dependencies'
9997
10098
- 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
@@ -68,8 +68,9 @@ jobs:
6868
displayName: "Reset IPU devices"
6969
7070
- bash: |
71-
python ./requirements/pytorch/adjust-versions.py requirements/pytorch/extra.txt
72-
python ./requirements/pytorch/adjust-versions.py requirements/pytorch/examples.txt
71+
for fpath in `ls requirements/**/*.txt`; do \
72+
python ./requirements/pytorch/adjust-versions.py $fpath; \
73+
done
7374
pip install -e .[dev]
7475
pip list
7576
env:

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ jobs:
8787
- name: Adjust PyTorch versions in requirements files
8888
if: ${{ matrix.requires != 'oldest' }}
8989
run: |
90-
python ./requirements/pytorch/adjust-versions.py requirements/lite/base.txt ${{ matrix.pytorch-version }}
90+
for fpath in `ls requirements/**/*.txt`; do \
91+
python ./requirements/pytorch/adjust-versions.py $fpath ${{ matrix.pytorch-version }}; \
92+
done
9193
cat requirements/lite/base.txt
9294
9395
- name: Get pip cache dir

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,9 @@ jobs:
104104
- name: Adjust PyTorch versions in requirements files
105105
if: ${{ matrix.requires != 'oldest' }}
106106
run: |
107-
python ./requirements/pytorch/adjust-versions.py requirements/lite/base.txt ${{ matrix.pytorch-version }}
108-
python ./requirements/pytorch/adjust-versions.py requirements/pytorch/base.txt ${{ matrix.pytorch-version }}
109-
python ./requirements/pytorch/adjust-versions.py requirements/pytorch/examples.txt ${{ matrix.pytorch-version }}
107+
for fpath in `ls requirements/**/*.txt`; do \
108+
python ./requirements/pytorch/adjust-versions.py $fpath ${{ matrix.pytorch-version }}; \
109+
done
110110
cat requirements/pytorch/base.txt
111111
112112
- name: Get pip cache dir

dockers/base-cuda/Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ RUN \
9191
# Disable cache \
9292
export CUDA_VERSION_MM=$(python -c "print(''.join('$CUDA_VERSION'.split('.')[:2]))") && \
9393
pip config set global.cache-dir false && \
94-
# set particular PyTorch version
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+
# set particular PyTorch version \
95+
for fpath in `ls requirements/**/*.txt`; do \
96+
python ./requirements/pytorch/adjust-versions.py $fpath ${PYTORCH_VERSION}; \
97+
done && \
9898

9999
# Install base requirements \
100100
pip install -r requirements/pytorch/base.txt --no-cache-dir --find-links https://download.pytorch.org/whl/cu${CUDA_VERSION_MM}/torch_stable.html && \

dockers/release/Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ ARG LIGHTNING_VERSION=""
2424

2525
COPY ./ /home/lightning/
2626

27+
ENV PACKAGE_NAME=pytorch
28+
2729
# install dependencies
2830
RUN \
2931
cd /home && \
@@ -39,9 +41,8 @@ RUN \
3941
fi && \
4042
# otherwise there is collision with folder name ans pkg name on Pypi
4143
cd lightning && \
42-
# remove colossalai from requirements since they are installed separately
43-
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)" ; \
44-
PACKAGE_NAME=pytorch pip install '.[extra,loggers,strategies]' --no-cache-dir && \
44+
pip install setuptools==59.5.0 && \
45+
pip install '.[extra,loggers,strategies]' --no-cache-dir && \
4546
cd .. && \
4647
rm -rf lightning
4748

requirements/pytorch/adjust-versions.py

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def find_latest(ver: str) -> Dict[str, str]:
3232
raise ValueError(f"Missing {ver} in {VERSIONS}")
3333

3434

35-
def main(req: str, torch_version: Optional[str] = None) -> str:
35+
def replace(req: str, torch_version: Optional[str] = None) -> str:
3636
if not torch_version:
3737
import torch
3838

@@ -50,34 +50,7 @@ def main(req: str, torch_version: Optional[str] = None) -> str:
5050
return req
5151

5252

53-
def test_check():
54-
requirements = """
55-
torch>=1.2.*
56-
torch==1.2.3
57-
torch==1.4
58-
torch
59-
future>=0.17.1
60-
pytorch==1.5.6+123dev0
61-
torchvision
62-
torchmetrics>=0.4.1
63-
"""
64-
expected = """
65-
torch==1.12.1
66-
torch==1.12.1
67-
torch==1.12.1
68-
torch==1.12.1
69-
future>=0.17.1
70-
pytorch==1.5.6+123dev0
71-
torchvision==0.13.1
72-
torchmetrics>=0.4.1
73-
""".strip()
74-
actual = main(requirements, "1.12")
75-
assert actual == expected, (actual, expected)
76-
77-
7853
if __name__ == "__main__":
79-
test_check() # sanity check
80-
8154
if len(sys.argv) == 3:
8255
requirements_path, torch_version = sys.argv[1:]
8356
else:
@@ -86,7 +59,7 @@ def test_check():
8659

8760
with open(requirements_path) as fp:
8861
requirements = fp.read()
89-
requirements = main(requirements, torch_version)
62+
requirements = replace(requirements, torch_version)
9063
print(requirements) # on purpose - to debug
9164
with open(requirements_path, "w") as fp:
9265
fp.write(requirements)

0 commit comments

Comments
 (0)