Skip to content

Commit cd30ce4

Browse files
tests: ignore future warning for oldest configurations (#21185)
* tests: ignore future warning for oldest configurations * prune_pytest_as_errors * update --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 8215dc0 commit cd30ce4

File tree

5 files changed

+30
-5
lines changed

5 files changed

+30
-5
lines changed

.actions/assistant.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,25 @@ def generate_docker_tags(
459459
tags = [f"{docker_project}:{tag}" for tag in tags]
460460
print(",".join(tags))
461461

462+
@staticmethod
463+
def prune_pytest_as_errors(
464+
pyproject_toml: str = "pyproject.toml", errors: tuple = ("FutureWarning", "DeprecationWarning")
465+
) -> None:
466+
"""Prune pytest warnings as errors from the pyproject.toml file."""
467+
import tomlkit
468+
469+
with open(pyproject_toml, encoding="utf-8") as fopen:
470+
content = fopen.read()
471+
pyproject = tomlkit.parse(content)
472+
filterwarnings = pyproject.get("tool", {}).get("pytest", {}).get("ini_options", {}).get("filterwarnings", [])
473+
if not filterwarnings:
474+
return
475+
filterwarnings = [wrn for wrn in filterwarnings if not any(f"error::{err}" in wrn for err in errors)]
476+
pyproject["tool"]["pytest"]["ini_options"]["filterwarnings"] = filterwarnings
477+
478+
with open(pyproject_toml, "w", encoding="utf-8") as fopen:
479+
fopen.write(tomlkit.dumps(pyproject))
480+
462481

463482
if __name__ == "__main__":
464483
import jsonargparse

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,14 @@ jobs:
9999
- name: Set min. dependencies
100100
if: ${{ matrix.config.requires == 'oldest' }}
101101
run: |
102-
cd requirements/fabric
103102
uv pip install -U "lightning-utilities[cli]"
104-
python -m lightning_utilities.cli requirements set-oldest --req_files "['base.txt', 'strategies.txt', 'test.txt']"
103+
python -m lightning_utilities.cli requirements set-oldest \
104+
--req_files "['requirements/fabric/base.txt', 'requirements/fabric/strategies.txt', 'requirements/fabric/test.txt']"
105105
uv pip install "cython<3.0" wheel
106106
uv pip install "pyyaml==5.4" --no-build-isolation
107+
# This script removes any line containing "error::FutureWarning" from pyproject.toml
108+
uv pip install -r requirements/ci.txt
109+
python .actions/assistant.py prune_pytest_as_errors
107110
108111
- name: Adjust PyTorch versions in requirements files
109112
if: ${{ matrix.config.requires != 'oldest' }}

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,14 @@ jobs:
9898
- name: Set min. dependencies
9999
if: ${{ matrix.config.requires == 'oldest' }}
100100
run: |
101-
cd requirements/pytorch
102101
uv pip install -U "lightning-utilities[cli]"
103-
python -m lightning_utilities.cli requirements set-oldest --req_files "['base.txt', 'extra.txt', 'strategies.txt', 'examples.txt', 'test.txt']"
102+
python -m lightning_utilities.cli requirements set-oldest \
103+
--req_files "['requirements/pytorch/base.txt', 'requirements/pytorch/extra.txt', 'requirements/pytorch/strategies.txt', 'requirements/pytorch/examples.txt', 'requirements/pytorch/test.txt']"
104104
uv pip install "cython<3.0" wheel
105105
uv pip install "pyyaml==5.4" --no-build-isolation
106+
# This script removes any line containing "error::FutureWarning" from pyproject.toml
107+
uv pip install -r requirements/ci.txt
108+
python .actions/assistant.py prune_pytest_as_errors
106109
107110
- name: Adjust PyTorch versions in requirements files
108111
if: ${{ matrix.config.requires != 'oldest' }}

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@ filterwarnings = [
182182
# "error::DeprecationWarning",
183183
"error::FutureWarning",
184184
"ignore::FutureWarning:onnxscript", # Temporary ignore until onnxscript is updated
185-
"ignore:The pynvml package is deprecated:FutureWarning", # Ignore pynvml deprecation warning, since it is not installed by PL directly
186185
]
187186
xfail_strict = true
188187
junit_duration_report = "call"

requirements/ci.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ importlib-metadata <9.0.0
66
wget
77
pkginfo ==1.12.1.2
88
packaging <25.1
9+
tomlkit

0 commit comments

Comments
 (0)