Skip to content

Commit f78c894

Browse files
authored
Merge branch 'master' into refactor/imports
2 parents e069873 + 80aadb9 commit f78c894

17 files changed

+51
-62
lines changed

.azure/gpu-pipeline.yml

+37-18
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ jobs:
2121
strategy:
2222
matrix:
2323
'PyTorch | old':
24-
docker-image: 'pytorch/pytorch:1.9.0-cuda11.1-cudnn8-runtime'
24+
# Torch does not have build wheels with old Torch versions for newer CUDA
25+
docker-image: 'nvidia/cuda:11.1.1-cudnn8-devel-ubuntu20.04'
2526
agent-pool: 'lit-rtx-3090'
26-
torch-ver: '1.9.0'
27+
torch-ver: '1.8.1'
2728
'PyTorch | 1.X':
2829
docker-image: 'pytorch/pytorch:1.13.1-cuda11.6-cudnn8-runtime'
2930
agent-pool: 'lit-rtx-3090'
@@ -60,10 +61,33 @@ jobs:
6061

6162
steps:
6263

64+
- script: |
65+
container_id=$(head -1 /proc/self/cgroup|cut -d/ -f3)
66+
echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
67+
/tmp/docker exec -t -u 0 $container_id \
68+
sh -c "apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -o Dpkg::Options::="--force-confold" -y install sudo"
69+
echo "##vso[task.setvariable variable=CONTAINER_ID]$container_id"
70+
displayName: 'Install Sudo in container (thanks Microsoft!)'
71+
72+
- script: |
73+
sudo apt-get update -q --fix-missing
74+
sudo apt-get install -q -y --no-install-recommends \
75+
build-essential wget python${PYTHON_VERSION} python${PYTHON_VERSION}-dev python${PYTHON_VERSION}-distutils
76+
sudo update-alternatives --install /usr/bin/python python /usr/bin/python${PYTHON_VERSION} 1
77+
wget https://bootstrap.pypa.io/get-pip.py --progress=bar:force:noscroll --no-check-certificate
78+
python get-pip.py
79+
env:
80+
PYTHON_VERSION: "3.8"
81+
condition: startsWith(variables['docker-image'], 'nvidia/cuda:')
82+
displayName: 'install python & pip'
83+
6384
- bash: |
64-
echo "##vso[task.setvariable variable=CONTAINER_ID]$(head -1 /proc/self/cgroup|cut -d/ -f3)"
6585
echo "##vso[task.setvariable variable=CUDA_VISIBLE_DEVICES]$(DEVICES)"
66-
displayName: 'Set environment variables'
86+
CUDA_version=$(nvcc --version | sed -n 's/^.*release \([0-9]\+\.[0-9]\+\).*$/\1/p')
87+
CUDA_version_mm="${CUDA_version//'.'/''}"
88+
echo "##vso[task.setvariable variable=CUDA_VERSION_MM]$CUDA_version_mm"
89+
echo "##vso[task.setvariable variable=TORCH_URL]https://download.pytorch.org/whl/cu${CUDA_version_mm}/torch_stable.html"
90+
displayName: 'set Env. vars'
6791
6892
- bash: |
6993
whoami && id
@@ -72,23 +96,18 @@ jobs:
7296
nvidia-smi
7397
echo $CUDA_VISIBLE_DEVICES
7498
echo $CONTAINER_ID
99+
echo $TORCH_URL
75100
python --version
76101
pip --version
77102
pip cache dir
78103
pip list
79-
python -c "import torch ; print(torch.cuda.get_arch_list())"
80104
displayName: 'Image info & NVIDIA'
81105
82-
- script: |
83-
/tmp/docker exec -t -u 0 $CONTAINER_ID \
84-
sh -c "apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -o Dpkg::Options::="--force-confold" -y install sudo"
85-
displayName: 'Install Sudo in container (thanks Microsoft!)'
86-
87106
- bash: |
88107
pip install -q packaging
89-
python ./requirements/adjust-versions.py requirements.txt
108+
python ./requirements/adjust-versions.py requirements.txt $(torch-ver)
90109
for fpath in `ls requirements/*.txt`; do
91-
python ./requirements/adjust-versions.py $fpath
110+
python ./requirements/adjust-versions.py $fpath $(torch-ver)
92111
done
93112
displayName: 'Adjust versions'
94113
@@ -97,15 +116,15 @@ jobs:
97116
sudo apt-get update -qq --fix-missing
98117
sudo apt-get install -y build-essential gcc g++ cmake ffmpeg git libsndfile1 unzip --no-install-recommends
99118
# pip install pip -U
100-
pip install -e . -r ./requirements/devel.txt
119+
pip install -e . -U -r ./requirements/devel.txt --find-links ${TORCH_URL}
101120
pip install mkl-service==2.4.0 # needed for the gpu multiprocessing
102121
pip list
103122
displayName: 'Install environment'
104123
105124
- bash: |
106125
set -e
107126
python -c "from torch import __version__ as ver ; assert str(ver).split('+')[0] == '$(torch-ver)', f'PyTorch: {ver}'"
108-
python -c "import torch ; mgpu = torch.cuda.device_count() ; assert mgpu >= 2, f'GPU: {mgpu}'"
127+
python -c "import torch ; mgpu = torch.cuda.device_count() ; assert mgpu >= 2, f'found GPUs: {mgpu}'"
109128
displayName: 'Sanity check'
110129
111130
- bash: |
@@ -117,7 +136,7 @@ jobs:
117136
ls -lh $(TRANSFORMERS_CACHE)
118137
displayName: 'Show caches'
119138
120-
- bash: python -m pytest torchmetrics --timeout=180 --durations=50
139+
- bash: python -m pytest torchmetrics --timeout=240 --durations=50
121140
env:
122141
SKIP_SLOW_DOCTEST: 1
123142
workingDirectory: src
@@ -131,7 +150,7 @@ jobs:
131150
workingDirectory: tests
132151
displayName: 'Pull testing data from S3'
133152
134-
- bash: python -m pytest unittests -v --cov=torchmetrics --timeout=180 --durations=500
153+
- bash: python -m pytest unittests -v --cov=torchmetrics --timeout=240 --durations=500
135154
env:
136155
CUDA_LAUNCH_BLOCKING: 1
137156
workingDirectory: tests
@@ -162,11 +181,11 @@ jobs:
162181
python .github/assistant.py set-oldest-versions --req_files='["requirements/integrate.txt"]'
163182
cat requirements/integrate.txt
164183
displayName: 'Set oldest versions'
165-
condition: eq(variables['torch-ver'], '1.9.0')
184+
condition: eq(variables['torch-ver'], '1.8.1')
166185
167186
- bash: |
168187
pip install -q -r requirements/integrate.txt
169-
pip install -e . # force reinstall TM as it could be overwritten by integration's depenencies
188+
pip install -e . # force reinstall TM as it could be overwritten by integration's dependencies
170189
pip list
171190
displayName: 'Install integrations'
172191

.github/workflows/ci-checks.yml

+5
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,8 @@ jobs:
2626
actions-ref: main
2727
artifact-name: dist-packages-${{ github.sha }}
2828
import-name: "torchmetrics"
29+
testing-matrix: |
30+
{
31+
"os": ["ubuntu-20.04", "macos-11", "windows-2022"],
32+
"python-version": ["3.8", "3.10"]
33+
}

.github/workflows/ci-integrate.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,9 @@ jobs:
2828
fail-fast: false
2929
matrix:
3030
os: [ubuntu-20.04, macOS-11, windows-2022]
31-
python-version: ['3.7', '3.10']
31+
python-version: ['3.8', '3.10']
3232
requires: ['oldest', 'latest']
3333
exclude:
34-
- {python-version: '3.7', requires: 'latest'}
3534
- {python-version: '3.10', requires: 'oldest'}
3635
- {python-version: '3.10', os: 'windows'} # todo: https://discuss.pytorch.org/t/numpy-is-not-available-error/146192
3736
include:

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

-3
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,8 @@ jobs:
4444
- {os: 'windows-2022', python-version: '3.9', pytorch-version: '1.13.1'}
4545
- {os: 'windows-2022', python-version: '3.10', pytorch-version: '2.0.0'}
4646
# the oldest configurations
47-
- {os: 'ubuntu-20.04', python-version: '3.7', pytorch-version: '1.8.1', requires: 'oldest'}
4847
- {os: 'ubuntu-20.04', python-version: '3.8', pytorch-version: '1.8.1', requires: 'oldest'}
49-
- {os: 'macOS-11', python-version: '3.7', pytorch-version: '1.8.1', requires: 'oldest'}
5048
- {os: 'macOS-11', python-version: '3.8', pytorch-version: '1.8.1', requires: 'oldest'}
51-
- {os: 'windows-2019', python-version: '3.7', pytorch-version: '1.8.1', requires: 'oldest'}
5249
- {os: 'windows-2019', python-version: '3.8', pytorch-version: '1.8.1', requires: 'oldest'}
5350
env:
5451
PYTORCH_URL: "https://download.pytorch.org/whl/cpu/torch_stable.html"

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
115115

116116
### Removed
117117

118-
-
118+
- Support for python 3.7 ([#1640](https://github.com/Lightning-AI/metrics/pull/1640))
119119

120120

121121
### Fixed

requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# NOTE: the upper bound for the package version is only set for CI stability, and it is dropped while installing this package
22
# in case you want to preserve/enforce restrictions on the latest compatible version, add "strict" as an in-line comment
33

4-
numpy >=1.17.2
4+
numpy >=1.18.5
55
torch >=1.8.1, <=2.0.0
66
typing-extensions; python_version < '3.9'
77
packaging # hotfix for utils, can be dropped with lit-utils >=0.5

requirements/adjust-versions.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def adjust(requires: str, torch_version: Optional[str] = None) -> str:
8282
requirements_path, torch_version = sys.argv[1:]
8383
else:
8484
requirements_path, torch_version = sys.argv[1], None
85-
logging.info(f"requirements_path='{requirements_path}' with torch_version='{torch_version}'")
85+
logging.info(f"requirements_path='{requirements_path}' with arg torch_version='{torch_version}'")
8686

8787
with open(requirements_path) as fp:
8888
requirements = fp.read()

requirements/classification_test.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# NOTE: the upper bound for the package version is only set for CI stability, and it is dropped while installing this package
22
# in case you want to preserve/enforce restrictions on the latest compatible version, add "strict" as an in-line comment
33

4-
pandas >1.0.0, <=1.5.3
4+
pandas >=1.4.0, <=1.5.3
55
netcal >1.0.0, <=1.3.5 # calibration_error
66
fairlearn # group_fairness

requirements/multimodal.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# NOTE: the upper bound for the package version is only set for CI stability, and it is dropped while installing this package
22
# in case you want to preserve/enforce restrictions on the latest compatible version, add "strict" as an in-line comment
33

4-
transformers >=4.10.0, <4.27.4
4+
transformers >=4.10.0, <4.27.5

requirements/test.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ requests <=2.28.2
1414
fire <=0.5.0
1515

1616
cloudpickle >1.3, <=2.2.1
17-
scikit-learn >1.0, <1.2.3
17+
scikit-learn >=1.1.1, <1.2.3

requirements/text_test.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
jiwer >=2.3.0, <=3.0.1
55
rouge-score >0.1.0, <=0.1.2
66
bert_score ==0.3.13
7-
transformers >4.4.0, <4.27.4
7+
transformers >4.4.0, <4.27.5
88
huggingface-hub <0.14 # hotfix, failing SDR for latest PT 1.11
99
sacrebleu >=2.0.0, <=2.3.1

setup.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ def _prepare_extras(skip_files: Tuple[str] = ("devel.txt", "doctest.txt", "integ
201201
include_package_data=True,
202202
zip_safe=False,
203203
keywords=["deep learning", "machine learning", "pytorch", "metrics", "AI"],
204-
python_requires=">=3.7",
204+
python_requires=">=3.8",
205205
setup_requires=[],
206206
install_requires=BASE_REQUIREMENTS,
207207
extras_require=_prepare_extras(),
@@ -227,7 +227,6 @@ def _prepare_extras(skip_files: Tuple[str] = ("devel.txt", "doctest.txt", "integ
227227
# Specify the Python versions you support here. In particular, ensure
228228
# that you indicate whether you support Python 2, Python 3 or both.
229229
"Programming Language :: Python :: 3",
230-
"Programming Language :: Python :: 3.7",
231230
"Programming Language :: Python :: 3.8",
232231
"Programming Language :: Python :: 3.9",
233232
"Programming Language :: Python :: 3.10",

tests/unittests/classification/test_precision_recall_curve.py

-6
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ class TestBinaryPrecisionRecallCurve(MetricTester):
5555

5656
@pytest.mark.parametrize("ignore_index", [None, -1, 0])
5757
@pytest.mark.parametrize("ddp", [True, False])
58-
@pytest.mark.skipif(compare_version("sklearn", operator.lt, "1.1.0"), reason="Restricted to latest `sklearn`")
5958
def test_binary_precision_recall_curve(self, input, ddp, ignore_index):
6059
"""Test class implementation of metric."""
6160
preds, target = input
@@ -74,7 +73,6 @@ def test_binary_precision_recall_curve(self, input, ddp, ignore_index):
7473
)
7574

7675
@pytest.mark.parametrize("ignore_index", [None, -1, 0])
77-
@pytest.mark.skipif(compare_version("sklearn", operator.lt, "1.1.0"), reason="Restricted to latest `sklearn`")
7876
def test_binary_precision_recall_curve_functional(self, input, ignore_index):
7977
"""Test functional implementation of metric."""
8078
preds, target = input
@@ -182,7 +180,6 @@ class TestMulticlassPrecisionRecallCurve(MetricTester):
182180

183181
@pytest.mark.parametrize("ignore_index", [None, -1])
184182
@pytest.mark.parametrize("ddp", [True, False])
185-
@pytest.mark.skipif(compare_version("sklearn", operator.lt, "1.1.0"), reason="Restricted to latest `sklearn`")
186183
def test_multiclass_precision_recall_curve(self, input, ddp, ignore_index):
187184
"""Test class implementation of metric."""
188185
preds, target = input
@@ -202,7 +199,6 @@ def test_multiclass_precision_recall_curve(self, input, ddp, ignore_index):
202199
)
203200

204201
@pytest.mark.parametrize("ignore_index", [None, -1])
205-
@pytest.mark.skipif(compare_version("sklearn", operator.lt, "1.1.0"), reason="Restricted to latest `sklearn`")
206202
def test_multiclass_precision_recall_curve_functional(self, input, ignore_index):
207203
"""Test functional implementation of metric."""
208204
preds, target = input
@@ -304,7 +300,6 @@ class TestMultilabelPrecisionRecallCurve(MetricTester):
304300

305301
@pytest.mark.parametrize("ignore_index", [None, -1, 0])
306302
@pytest.mark.parametrize("ddp", [True, False])
307-
@pytest.mark.skipif(compare_version("sklearn", operator.lt, "1.1.0"), reason="Restricted to latest `sklearn`")
308303
def test_multilabel_precision_recall_curve(self, input, ddp, ignore_index):
309304
"""Test class implementation of metric."""
310305
preds, target = input
@@ -324,7 +319,6 @@ def test_multilabel_precision_recall_curve(self, input, ddp, ignore_index):
324319
)
325320

326321
@pytest.mark.parametrize("ignore_index", [None, -1, 0])
327-
@pytest.mark.skipif(compare_version("sklearn", operator.lt, "1.1.0"), reason="Restricted to latest `sklearn`")
328322
def test_multilabel_precision_recall_curve_functional(self, input, ignore_index):
329323
"""Test functional implementation of metric."""
330324
preds, target = input

tests/unittests/nominal/test_cramers.py

-6
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,6 @@ def _dython_cramers_v_matrix(matrix, bias_correction, nan_strategy, nan_replace_
9090

9191

9292
@pytest.mark.skipif(compare_version("pandas", operator.lt, "1.3.2"), reason="`dython` package requires `pandas>=1.3.2`")
93-
@pytest.mark.skipif( # TODO: testing on CUDA fails with pandas 1.3.5, and newer is not available for python 3.7
94-
torch.cuda.is_available(), reason="Tests fail on CUDA with the most up-to-date available pandas"
95-
)
9693
@pytest.mark.parametrize(
9794
"preds, target",
9895
[
@@ -167,9 +164,6 @@ def test_cramers_v_differentiability(self, preds, target, bias_correction, nan_s
167164

168165

169166
@pytest.mark.skipif(compare_version("pandas", operator.lt, "1.3.2"), reason="`dython` package requires `pandas>=1.3.2`")
170-
@pytest.mark.skipif( # TODO: testing on CUDA fails with pandas 1.3.5, and newer is not available for python 3.7
171-
torch.cuda.is_available(), reason="Tests fail on CUDA with the most up-to-date available pandas"
172-
)
173167
@pytest.mark.parametrize("bias_correction", [False, True])
174168
@pytest.mark.parametrize(("nan_strategy", "nan_replace_value"), [("replace", 1.0), ("drop", None)])
175169
def test_cramers_v_matrix(cramers_matrix_input, bias_correction, nan_strategy, nan_replace_value):

tests/unittests/nominal/test_pearson.py

-6
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,6 @@ def _pd_pearsons_t_matrix(matrix):
7777

7878

7979
@pytest.mark.skipif(compare_version("pandas", operator.lt, "1.3.2"), reason="`dython` package requires `pandas>=1.3.2`")
80-
@pytest.mark.skipif( # TODO: testing on CUDA fails with pandas 1.3.5, and newer is not available for python 3.7
81-
torch.cuda.is_available(), reason="Tests fail on CUDA with the most up-to-date available pandas"
82-
)
8380
@pytest.mark.parametrize(
8481
"preds, target",
8582
[
@@ -124,9 +121,6 @@ def test_pearsons_t_differentiability(self, preds, target):
124121

125122

126123
@pytest.mark.skipif(compare_version("pandas", operator.lt, "1.3.2"), reason="`dython` package requires `pandas>=1.3.2`")
127-
@pytest.mark.skipif( # TODO: testing on CUDA fails with pandas 1.3.5, and newer is not available for python 3.7
128-
torch.cuda.is_available(), reason="Tests fail on CUDA with the most up-to-date available pandas"
129-
)
130124
def test_pearsons_contingency_coefficient_matrix(pearson_matrix_input):
131125
"""Test matrix version of metric works as expected."""
132126
tm_score = pearsons_contingency_coefficient_matrix(pearson_matrix_input)

tests/unittests/nominal/test_theils_u.py

-6
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,6 @@ def _dython_theils_u_matrix(matrix, nan_strategy, nan_replace_value):
8888

8989

9090
@pytest.mark.skipif(compare_version("pandas", operator.lt, "1.3.2"), reason="`dython` package requires `pandas>=1.3.2`")
91-
@pytest.mark.skipif( # TODO: testing on CUDA fails with pandas 1.3.5, and newer is not available for python 3.7
92-
torch.cuda.is_available(), reason="Tests fail on CUDA with the most up-to-date available pandas"
93-
)
9491
@pytest.mark.parametrize(
9592
"preds, target",
9693
[
@@ -159,9 +156,6 @@ def test_theils_u_differentiability(self, preds, target, nan_strategy, nan_repla
159156

160157

161158
@pytest.mark.skipif(compare_version("pandas", operator.lt, "1.3.2"), reason="`dython` package requires `pandas>=1.3.2`")
162-
@pytest.mark.skipif( # TODO: testing on CUDA fails with pandas 1.3.5, and newer is not available for python 3.7
163-
torch.cuda.is_available(), reason="Tests fail on CUDA with the most up-to-date available pandas"
164-
)
165159
@pytest.mark.parametrize(("nan_strategy", "nan_replace_value"), [("replace", 1.0), ("drop", None)])
166160
def test_theils_u_matrix(theils_u_matrix_input, nan_strategy, nan_replace_value):
167161
"""Test matrix version of metric works as expected."""

tests/unittests/nominal/test_tschuprows.py

-6
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,6 @@ def _pd_tschuprows_t_matrix(matrix):
7474

7575

7676
@pytest.mark.skipif(compare_version("pandas", operator.lt, "1.3.2"), reason="`dython` package requires `pandas>=1.3.2`")
77-
@pytest.mark.skipif( # TODO: testing on CUDA fails with pandas 1.3.5, and newer is not available for python 3.7
78-
torch.cuda.is_available(), reason="Tests fail on CUDA with the most up-to-date available pandas"
79-
)
8077
@pytest.mark.parametrize(
8178
"preds, target",
8279
[
@@ -122,9 +119,6 @@ def test_tschuprows_t_differentiability(self, preds, target):
122119

123120

124121
@pytest.mark.skipif(compare_version("pandas", operator.lt, "1.3.2"), reason="`dython` package requires `pandas>=1.3.2`")
125-
@pytest.mark.skipif( # TODO: testing on CUDA fails with pandas 1.3.5, and newer is not available for python 3.7
126-
torch.cuda.is_available(), reason="Tests fail on CUDA with the most up-to-date available pandas"
127-
)
128122
def test_tschuprows_t_matrix(tschuprows_matrix_input):
129123
"""Test matrix version of metric works as expected."""
130124
tm_score = tschuprows_t_matrix(tschuprows_matrix_input, bias_correction=False)

0 commit comments

Comments
 (0)