Skip to content

Commit

Permalink
ci: proper setting oldest/latest for integrations & PL>=1.9 (#2129)
Browse files Browse the repository at this point in the history
(cherry picked from commit 045431a)
  • Loading branch information
Borda committed Dec 1, 2023
1 parent 3e85bba commit b670fac
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 34 deletions.
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
9 changes: 3 additions & 6 deletions .azure/gpu-unittests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,16 @@ jobs:
torch-ver: "1.8.1"
"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 +79,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-11, windows-2022]
os: ["ubuntu-22.04", "macOS-12", "windows-2022"]
python-version: ["3.8", "3.10"]
requires: ["oldest", "latest"]
exclude:
Expand All @@ -53,23 +53,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 @@ -99,7 +99,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 @@ -108,11 +107,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

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

0 comments on commit b670fac

Please sign in to comment.