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

ci: proper setting oldest/latest for integrations & PL>=1.9 #2129

Merged
merged 37 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
84e54f4
ci: proper setting oldest for integrations
Borda Oct 2, 2023
b6c2bb8
pool
Borda Oct 2, 2023
13ea27e
pillow
Borda Oct 2, 2023
cc22a13
Apply suggestions from code review
Borda Oct 6, 2023
4fa8058
Merge branch 'master' into ci/oldest
Borda Oct 7, 2023
e3a02db
Merge branch 'master' into ci/oldest
Borda Oct 9, 2023
5cad574
Adjust versions
Borda Oct 9, 2023
a7c49e2
wget
Borda Oct 9, 2023
4446d7e
wget
Borda Oct 9, 2023
e81203e
reorder
Borda Oct 9, 2023
cd9dc5b
cat
Borda Oct 9, 2023
7d3071a
docker
Borda Oct 9, 2023
4a40f0e
2.0.1
Borda Oct 9, 2023
85e0ae3
set -e
Borda Oct 9, 2023
11570d3
pl <1.8
Borda Oct 10, 2023
90abbb9
ci fixing
Borda Oct 10, 2023
992f2c8
wget
Borda Oct 10, 2023
bad4590
install
Borda Oct 10, 2023
fd536bd
Merge branch 'master' into ci/oldest
Borda Oct 10, 2023
8cd7297
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 10, 2023
dedb118
Merge branch 'master' into ci/oldest
Borda Oct 10, 2023
acec6d8
Merge branch 'master' into ci/oldest
Borda Oct 11, 2023
d6d8551
_
Borda Oct 11, 2023
6f783dc
_tests.txt
Borda Oct 11, 2023
89004bc
pytorch-lightning >=1.9.0, <2.1.0
Borda Oct 11, 2023
0f3991b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 11, 2023
ac8f18a
oldest for integrate
Borda Oct 11, 2023
2a69e1f
Merge branch 'ci/oldest' of https://github.com/PyTorchLightning/metri…
Borda Oct 11, 2023
1e5e984
assist
Borda Oct 11, 2023
63ceef8
pytorch-lightning >=1.8.0
Borda Oct 11, 2023
935ea02
cleaning
Borda Oct 11, 2023
352b7ac
Merge branch 'master' into ci/oldest
Borda Oct 11, 2023
3edc415
wget
Borda Oct 11, 2023
0c7f65a
Merge branch 'ci/oldest' of https://github.com/PyTorchLightning/metri…
Borda Oct 11, 2023
178b55e
Merge branch 'master' into ci/oldest
Borda Oct 11, 2023
42e6fef
<2.0
Borda Oct 11, 2023
8392cb5
Merge branch 'master' into ci/oldest
Borda Oct 17, 2023
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
18 changes: 13 additions & 5 deletions .azure/gpu-integrations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
"oldest":
docker-image: "pytorch/pytorch:1.11.0-cuda11.3-cudnn8-runtime"
torch-ver: "1.11.0"
requires: "oldest"
"latest":
docker-image: "pytorch/pytorch:2.1.0-cuda12.1-cudnn8-runtime"
torch-ver: "2.1.0"
Expand All @@ -46,6 +47,8 @@ jobs:
CUDA_version_mm="${CUDA_version//'.'/''}"
echo "##vso[task.setvariable variable=CUDA_VERSION_MM]$CUDA_version_mm"
echo "##vso[task.setvariable variable=TORCH_URL]https://download.pytorch.org/whl/cu${CUDA_version_mm}/torch_stable.html"
# packages for running assistant
pip install -q packaging fire requests wget
displayName: "set Env. vars"
- bash: |
Expand All @@ -63,13 +66,18 @@ jobs:
- bash: |
set -e
pip install -q packaging fire requests wget
python -m wget https://raw.githubusercontent.com/Lightning-AI/utilities/main/scripts/adjust-torch-versions.py
python adjust-torch-versions.py requirements/base.txt $(torch-ver)
python adjust-torch-versions.py requirements/_integrate.txt $(torch-ver)
# FixMe: this shall not be for all integrations/cases
python .github/assistant.py set-oldest-versions --req_files='["requirements/_integrate.txt"]'
cat requirements/_integrate.txt
condition: eq(variables['requires'], 'oldest')
displayName: "Setting oldest req."
- bash: |
set -e
python -m wget https://raw.githubusercontent.com/Lightning-AI/utilities/main/scripts/adjust-torch-versions.py
for fpath in `ls requirements/*.txt`; do
# torch version shall be sourced based on the used docker
python adjust-torch-versions.py $fpath
done
displayName: "Adjust versions"
- bash: |
Expand Down
12 changes: 4 additions & 8 deletions .azure/gpu-unittests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,22 @@ jobs:
- job: unitest_GPU
strategy:
matrix:
"PyTorch | old":
"PyTorch | 1.10":
# Torch does not have build wheels with old Torch versions for newer CUDA
docker-image: "pytorchlightning/torchmetrics:ubuntu20.04-cuda11.3.1-py3.9-torch1.10"
agent-pool: "lit-rtx-3090"
torch-ver: "1.10.2"
"PyTorch | 1.X":
docker-image: "pytorchlightning/torchmetrics:ubuntu22.04-cuda11.8.0-py3.9-torch1.13"
agent-pool: "lit-rtx-3090"
torch-ver: "1.13.1"
"PyTorch | 2.X":
docker-image: "pytorchlightning/torchmetrics:ubuntu22.04-cuda12.1.0-py3.11-torch2.1"
agent-pool: "lit-rtx-3090"
torch-ver: "2.1.0"
# how long to run the job before automatically cancelling
timeoutInMinutes: "120"
# how much time to give 'run always even if cancelled tasks' before stopping them
cancelTimeoutInMinutes: "2"

pool: "$(agent-pool)"
pool: "lit-rtx-3090"

variables:
DEVICES: $( python -c 'name = "$(Agent.Name)" ; gpus = name.split("_")[-1] if "_" in name else "0,1"; print(gpus)' )
Expand Down Expand Up @@ -81,11 +78,10 @@ jobs:
- bash: |
pip install -q packaging
wget https://raw.githubusercontent.com/Lightning-AI/utilities/main/scripts/adjust-torch-versions.py
python adjust-torch-versions.py requirements.txt $(torch-ver)
for fpath in `ls requirements/*.txt`; do
python adjust-torch-versions.py $fpath $(torch-ver)
# torch version shall be sourced based on the used docker
python adjust-torch-versions.py $fpath
done
# FixMe: missing setting minumal configurations for testing
displayName: "Adjust versions"

- bash: |
Expand Down
5 changes: 3 additions & 2 deletions .github/actions/pull-caches/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ runs:
using: "composite"
steps:
- name: install assistant's deps
run: pip install -q fire requests packaging
run: pip install -q fire requests packaging wget
shell: bash

- name: Set PyTorch version
if: inputs.pytorch-version != ''
run: |
curl https://raw.githubusercontent.com/Lightning-AI/utilities/main/scripts/adjust-torch-versions.py -o adjust-torch-versions.py
pip install wget
python -m wget https://raw.githubusercontent.com/Lightning-AI/utilities/main/scripts/adjust-torch-versions.py
python adjust-torch-versions.py requirements/base.txt ${{ inputs.pytorch-version }}
shell: bash

Expand Down
1 change: 1 addition & 0 deletions .github/assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ def set_oldest_versions(req_files: List[str] = REQUIREMENTS_FILES) -> None:
"""Set the oldest version for requirements."""
AssistantCLI.set_min_torch_by_python()
for fpath in req_files:
logging.info(f"processing req: `{fpath}`")
AssistantCLI.replace_min_requirements(fpath)

@staticmethod
Expand Down
29 changes: 16 additions & 13 deletions .github/workflows/ci-integrate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, macOS-12, windows-2022]
os: ["ubuntu-22.04", "macOS-12", "windows-2022"]
python-version: ["3.8", "3.10"]
requires: ["oldest", "latest"]
exclude:
Expand All @@ -52,23 +52,26 @@ jobs:

- name: source cashing
uses: ./.github/actions/pull-caches
with:
requires: ${{ matrix.requires }}

- name: Freeze PIL (hotfix)
# import of PILLOW_VERSION which they recently removed in v9.0 in favor of __version__
run: pip install "Pillow<9.0" # It messes with torchvision
- name: set oldest if/only for integrations
if: matrix.requires == 'oldest'
run: python .github/assistant.py set-oldest-versions --req_files='["requirements/_integrate.txt"]'

- name: Install all dependencies
run: |
set -e
curl https://raw.githubusercontent.com/Lightning-AI/utilities/main/scripts/adjust-torch-versions.py -o adjust-torch-versions.py
pip install -r requirements/_tests.txt -r requirements/_integrate.txt \
--find-links $PYTORCH_URL -f $PYPI_CACHE --upgrade-strategy eager
# this was updated in `source cashing` by optional oldest
cat requirements/_integrate.txt
# to have install pyTorch
pip install -e . --find-links=${PYTORCH_URL}

# adjust version to PT ecosystem based on installed TM
python -m wget https://raw.githubusercontent.com/Lightning-AI/utilities/main/scripts/adjust-torch-versions.py
python adjust-torch-versions.py requirements/base.txt
python adjust-torch-versions.py requirements/image.txt
cat requirements/base.txt
pip install -e . --find-links $PYTORCH_URL -f $PYPI_CACHE

# install package and dependencies
pip install -e . -r requirements/_tests.txt -r requirements/_integrate.txt \
--find-links=${PYTORCH_URL} --find-links=${PYPI_CACHE} \
--upgrade-strategy eager
pip list

- name: Integrations
Expand Down
6 changes: 0 additions & 6 deletions .github/workflows/ci-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ jobs:
pip install -r requirements/_doctest.txt -U -f $PYPI_CACHE
pip list

# todo: copy this to install checks
- name: DocTests
timeout-minutes: 25
working-directory: ./src
Expand All @@ -104,11 +103,6 @@ jobs:
# NOTE: run coverage on tests does not propagate failure status for Win, https://github.com/nedbat/coveragepy/issues/1003
run: python -m pytest torchmetrics --reruns 3 --reruns-delay 2

- name: Freeze PIL (hotfix)
if: ${{ matrix.python-version != '3.11' }}
# import of PILLOW_VERSION which they recently removed in v9.0 in favor of __version__
run: pip install "Pillow<9.0" # It messes with torchvision

- name: Install all dependencies
run: |
curl https://raw.githubusercontent.com/Lightning-AI/utilities/main/scripts/adjust-torch-versions.py -o adjust-torch-versions.py
Expand Down
5 changes: 4 additions & 1 deletion requirements/_integrate.txt
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
pytorch-lightning >=1.6.0, <2.1.0
# contentiously validated integration with these expected ranges

# ToDo: investigate and add validation with 2.0+ on GPU
pytorch-lightning >=1.9.0, <2.0.0
10 changes: 9 additions & 1 deletion src/torchmetrics/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
r"""Root package info."""
"""Root package info."""
import logging as __logging
import os

from lightning_utilities.core.imports import package_available

from torchmetrics.__about__ import * # noqa: F403

_logger = __logging.getLogger("torchmetrics")
Expand All @@ -11,6 +13,12 @@
_PACKAGE_ROOT = os.path.dirname(__file__)
_PROJECT_ROOT = os.path.dirname(_PACKAGE_ROOT)

if package_available("PIL"):
import PIL
Borda marked this conversation as resolved.
Show resolved Hide resolved

if not hasattr(PIL, "PILLOW_VERSION"):
PIL.PILLOW_VERSION = PIL.__version__

from torchmetrics import functional # noqa: E402
from torchmetrics.aggregation import ( # noqa: E402
CatMetric,
Expand Down
Loading