Skip to content

Commit 9c660e7

Browse files
authored
ci/test: validate compatibility with pytorch_lightning (#49)
1 parent 6906993 commit 9c660e7

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

.github/workflows/ci-testing.yml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,15 @@ jobs:
1616
strategy:
1717
fail-fast: false
1818
matrix:
19-
os: ["ubuntu-22.04", "macOS-13", "windows-2022"]
19+
os: ["ubuntu-24.04", "macOS-13", "windows-2022"]
2020
python-version: ["3.9", "3.12"]
2121
requires: ["latest"]
22+
dependency: ["lightning"]
2223
include:
23-
- { os: "ubuntu-20.04", python-version: "3.9", requires: "oldest" }
24+
- { os: "ubuntu-22.04", python-version: "3.9", requires: "oldest", dependency: "lightning" }
25+
- { os: "ubuntu-24.04", python-version: "3.10", requires: "latest", dependency: "pytorch_lightning" }
26+
- { os: "ubuntu-24.04", python-version: "3.12", requires: "latest", dependency: "pytorch_lightning" }
27+
- { os: "macOS-13", python-version: "3.12", requires: "latest", dependency: "pytorch_lightning" }
2428

2529
# Timeout: https://stackoverflow.com/a/59076067/4521646
2630
timeout-minutes: 35
@@ -41,11 +45,23 @@ jobs:
4145
pip install 'lightning-utilities[cli]'
4246
python -m lightning_utilities.cli requirements set-oldest --req_files='["requirements.txt"]'
4347
48+
- name: Adjust requirements
49+
run: |
50+
pip install 'lightning-utilities[cli]' -U -q
51+
python -m lightning_utilities.cli requirements replace-pkg \
52+
--old_package="lightning" \
53+
--new_package="${{matrix.dependency}}" \
54+
--req_files='["_requirements/extra.txt"]'
55+
cat _requirements/extra.txt
56+
4457
- name: Install package & dependencies
4558
run: |
59+
set -e
4660
pip --version
4761
pip install -e '.[test,extra]' -U -q --find-links $TORCH_URL
4862
pip list
63+
# check that right package was installed
64+
python -c "import ${{matrix.dependency}}; print(${{matrix.dependency}}.__version__)"
4965
5066
- name: Tests with mocks
5167
run: |

src/litmodels/integrations/lightning_checkpoint.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
from lightning.pytorch import Trainer
1010
from lightning.pytorch.callbacks import ModelCheckpoint
1111
elif _PYTORCHLIGHTNING_AVAILABLE:
12-
from pytorch_lightning.callbacks import ModelCheckpoint, Trainer
12+
from pytorch_lightning import Trainer
13+
from pytorch_lightning.callbacks import ModelCheckpoint
1314
else:
1415
raise ModuleNotFoundError("No module named 'lightning' or 'pytorch_lightning'")
1516

0 commit comments

Comments
 (0)