Skip to content
This repository was archived by the owner on Dec 16, 2022. It is now read-only.

Commit 80fb606

Browse files
authored
Remove upper bounds for dependencies in requirements.txt (#5733)
* Remove upper bounds for dependencies in requirements.txt The stated reason for this pinning was to prevent CI breakage, and there was a bot to help upgrade dependencies automatically. However, now that the library is being retired and Depdendabot was, this upgrade process is no longer happening. Removing these upper bounds will make using the library in the future much easier. To prevent CI breakage after upper bound removal, they can be kept in a constraints file for use in CI. It would be up to end users in the future to limit dependency conflicts if they encounter any. I have checked the history, and as far as I can tell, none of these upper pins exist to prevent a known breakage. Therefore, I moved them all to the constraints file. * Use constraints file in more places I needed to add a new `requirements.in` file and an extra constraint so `pip-compile` resolved all dependencies properly.
1 parent 0dc554f commit 80fb606

File tree

8 files changed

+52
-27
lines changed

8 files changed

+52
-27
lines changed

.github/workflows/ci.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ env:
2121
TORCH_VERSION: 1.12.0
2222
# TORCH_CPU_INSTALL: conda install pytorch torchvision torchaudio cpuonly -c pytorch
2323
# TORCH_GPU_INSTALL: conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch
24-
TORCH_CPU_INSTALL: pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cpu
25-
TORCH_GPU_INSTALL: pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu113
24+
TORCH_CPU_INSTALL: pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cpu -c constraints.txt
25+
TORCH_GPU_INSTALL: pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu113 -c constraints.txt
2626
# Change this to invalidate existing cache.
2727
CACHE_PREFIX: v11
2828
# Disable tokenizers parallelism because this doesn't help, and can cause issues in distributed tests.
@@ -150,7 +150,7 @@ jobs:
150150
id: virtualenv-cache
151151
with:
152152
path: .venv
153-
key: ${{ env.CACHE_PREFIX }}-${{ env.WEEK_NUMBER }}-${{ runner.os }}-${{ env.RUNNER_ARCH }}-${{ env.PYTHON_VERSION }}-${{ matrix.task.torch_platform }}-${{ hashFiles('setup.py') }}-${{ hashFiles('*requirements.txt') }}
153+
key: ${{ env.CACHE_PREFIX }}-${{ env.WEEK_NUMBER }}-${{ runner.os }}-${{ env.RUNNER_ARCH }}-${{ env.PYTHON_VERSION }}-${{ matrix.task.torch_platform }}-${{ hashFiles('setup.py') }}-${{ hashFiles('*requirements.txt', 'constraints.txt') }}
154154

155155
- name: Setup virtual environment (no cache hit)
156156
if: steps.virtualenv-cache.outputs.cache-hit != 'true'
@@ -276,7 +276,7 @@ jobs:
276276
id: virtualenv-cache
277277
with:
278278
path: .venv
279-
key: ${{ env.CACHE_PREFIX }}-${{ env.WEEK_NUMBER }}-${{ runner.os }}-${{ env.RUNNER_ARCH }}-${{ env.PYTHON_VERSION }}-cpu-${{ hashFiles('setup.py') }}-${{ hashFiles('*requirements.txt') }}
279+
key: ${{ env.CACHE_PREFIX }}-${{ env.WEEK_NUMBER }}-${{ runner.os }}-${{ env.RUNNER_ARCH }}-${{ env.PYTHON_VERSION }}-cpu-${{ hashFiles('setup.py') }}-${{ hashFiles('*requirements.txt', 'constraints.txt') }}
280280

281281
- name: Setup virtual environment (no cache hit)
282282
if: steps.virtualenv-cache.outputs.cache-hit != 'true'
@@ -377,7 +377,7 @@ jobs:
377377

378378
- name: Install core package
379379
run: |
380-
pip install $(ls dist/*.whl)${{ matrix.flavor }}
380+
pip install $(ls dist/*.whl)${{ matrix.flavor }} -c constraints.txt
381381
382382
- name: Download NLTK prerequisites
383383
run: |
@@ -484,7 +484,7 @@ jobs:
484484
id: virtualenv-cache
485485
with:
486486
path: .venv
487-
key: ${{ env.CACHE_PREFIX }}-${{ env.WEEK_NUMBER }}-${{ runner.os }}-${{ env.RUNNER_ARCH }}-${{ env.PYTHON_VERSION }}-cpu-${{ hashFiles('setup.py') }}-${{ hashFiles('*requirements.txt') }}
487+
key: ${{ env.CACHE_PREFIX }}-${{ env.WEEK_NUMBER }}-${{ runner.os }}-${{ env.RUNNER_ARCH }}-${{ env.PYTHON_VERSION }}-cpu-${{ hashFiles('setup.py') }}-${{ hashFiles('*requirements.txt', 'constraints.txt') }}
488488

489489
- name: Setup virtual environment (no cache hit)
490490
if: steps.virtualenv-cache.outputs.cache-hit != 'true'

Dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ COPY allennlp/version.py allennlp/version.py
1414
COPY setup.py .
1515
COPY requirements.txt .
1616
COPY dev-requirements.txt .
17+
COPY constraints.txt .
1718
RUN touch allennlp/__init__.py \
1819
&& touch README.md \
19-
&& pip install --no-cache-dir -e .[all]
20+
&& pip install --no-cache-dir -c constraints.txt -e .[all]
2021

2122
# Now add the full package source and re-install just the package.
2223
COPY allennlp allennlp

Dockerfile.test

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ WORKDIR /stage/allennlp
1616
COPY allennlp/version.py allennlp/version.py
1717
COPY setup.py .
1818
COPY dev-requirements.txt .
19+
COPY constraints.txt .
1920
RUN touch allennlp/__init__.py \
2021
&& touch README.md \
21-
&& pip install --no-cache-dir -e . -r dev-requirements.txt
22+
&& pip install --no-cache-dir -c constraints.txt -e . -r dev-requirements.txt
2223

2324
# Now add the full package source and re-install just the package.
2425
COPY . .

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ MD_DOCS_CONF_SRC = mkdocs-skeleton.yml
1010
MD_DOCS_TGT = site/
1111
MD_DOCS_EXTRAS = $(addprefix $(MD_DOCS_ROOT),README.md CHANGELOG.md CONTRIBUTING.md)
1212

13-
TORCH_INSTALL = pip install torch torchvision
13+
TORCH_INSTALL = pip install torch torchvision -c constraints.txt
1414
DOCKER_TORCH_VERSION = 1.12.0-cuda11.3-python3.8
1515
DOCKER_TEST_TORCH_VERSION = 1.12.0-cuda11.3-python3.8
1616

@@ -115,7 +115,7 @@ install :
115115
$(TORCH_INSTALL)
116116
pip install --upgrade pip
117117
pip install pip-tools
118-
pip-compile requirements.txt dev-requirements.txt -o final_requirements.txt --allow-unsafe --rebuild --verbose
118+
pip-compile requirements.in -o final_requirements.txt --allow-unsafe --rebuild --verbose
119119
pip install -e . -r final_requirements.txt
120120
# These nltk packages are used by the 'checklist' module.
121121
$(NLTK_DOWNLOAD_CMD)

constraints.txt

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
################################
2+
###### Core dependencies #######
3+
################################
4+
torch<1.13.0
5+
torchvision<0.14.0
6+
cached-path<1.2.0
7+
spacy<3.4
8+
transformers<4.21
9+
filelock<3.8
10+
wandb<0.13.0
11+
12+
# Protobuf is a dependency of wandb and tensorboard, but they are missing this pin.
13+
protobuf<4.0.0
14+
15+
# Required so pip-compile can properly resolve the pydantic version
16+
inflect<6.0
17+
18+
##################################################
19+
###### Extra dependencies for integrations #######
20+
##################################################
21+
# NOTE: we use a special trailing comment on each line to denote which extras
22+
# each package is needed by. For example, checklist is needed by the 'checklist' extra
23+
# that you install with 'pip install allennlp[checklist]'.
24+
checklist==0.0.11 # needed by: checklist

requirements.in

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-c constraints.txt
2+
-r dev-requirements.txt
3+
-r requirements.txt

requirements.txt

+9-13
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
################################
22
###### Core dependencies #######
33
################################
4-
torch>=1.10.0,<1.13.0
5-
torchvision>=0.8.1,<0.14.0
6-
cached-path>=1.1.3,<1.2.0
4+
torch>=1.10.0
5+
torchvision>=0.8.1
6+
cached-path>=1.1.3
77
fairscale==0.4.6
88
jsonnet>=0.10.0 ; sys.platform != 'win32'
99
nltk>=3.6.5
10-
spacy>=2.1.0,<3.4
10+
spacy>=2.1.0
1111
numpy>=1.21.4
1212
tensorboardX>=1.2
1313
requests>=2.28
@@ -16,14 +16,14 @@ h5py>=3.6.0
1616
scikit-learn>=1.0.1
1717
scipy>=1.7.3
1818
pytest>=6.2.5
19-
transformers>=4.1,<4.21
19+
transformers>=4.1
2020
sentencepiece>=0.1.96
2121
dataclasses;python_version<'3.7'
22-
filelock>=3.3,<3.8
22+
filelock>=3.3
2323
lmdb>=1.2.1
2424
more-itertools>=8.12.0
2525
termcolor==1.1.0
26-
wandb>=0.10.0,<0.13.0
26+
wandb>=0.10.0
2727
huggingface_hub>=0.0.16
2828
dill>=0.3.4
2929
base58>=2.1.1
@@ -34,12 +34,8 @@ sacremoses
3434
# Spacy depends on typer, and typer had a bug. This is how we make sure we get the fixed version of typer.
3535
typer>=0.4.1
3636

37-
# Indirect dependency of cached-path
38-
# pyasn1<0.5.0,>=0.4.8
39-
# pyasn1-modules>=0.2.8
40-
4137
# Protobuf is a dependency of wandb and tensorboard, but they are missing this pin.
42-
protobuf>=3.12.0,<4.0.0
38+
protobuf>=3.12.0
4339

4440
# We need this for building the Docker image
4541
traitlets>5.1.1
@@ -50,4 +46,4 @@ traitlets>5.1.1
5046
# NOTE: we use a special trailing comment on each line to denote which extras
5147
# each package is needed by. For example, checklist is needed by the 'checklist' extra
5248
# that you install with 'pip install allennlp[checklist]'.
53-
checklist==0.0.11 # needed by: checklist
49+
checklist>=0.0.11 # needed by: checklist

scripts/check_torch_version.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,16 @@ def _get_latest_torch_version() -> Tuple[str, str, str]:
4545

4646

4747
def _get_torch_version_upper_limit() -> Tuple[str, str, str]:
48-
with open("requirements.txt") as f:
48+
with open("constraints.txt") as f:
4949
for line in f:
5050
# The torch version line should look like:
51-
# "torch>=X.Y.Z,<X.V.0",
52-
if "torch>=" in line:
51+
# "torch<X.V.0",
52+
if "torch<" in line:
5353
version = tuple(line.split("<")[1].strip().split("."))
5454
assert len(version) == 3, f"Bad parsed version '{version}'"
5555
break
5656
else:
57-
raise RuntimeError("could not find torch version spec in requirements.txt")
57+
raise RuntimeError("could not find torch version spec in constraints.txt")
5858
return cast(Tuple[str, str, str], version)
5959

6060

0 commit comments

Comments
 (0)