Skip to content

Commit d6a1ad2

Browse files
authored
ci: fix filtering existing dirs & bump numprocesses (#2988)
1 parent 9cc3ad5 commit d6a1ad2

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

.azure/gpu-unittests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ jobs:
182182
- bash: |
183183
du -h --max-depth=1 .
184184
python -m pytest $(TEST_DIRS) \
185-
-m "not DDP" --numprocesses=5 --dist=loadfile \
185+
-m "not DDP" --numprocesses=9 --dist=loadfile \
186186
--cov=torchmetrics --timeout=240 --durations=100 \
187187
--reruns 3 --reruns-delay 1
188188
workingDirectory: "tests/"

.github/assistant.py

+14-5
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,23 @@
1616
import os
1717
import re
1818
import sys
19+
from pathlib import Path
1920
from typing import Optional, Union
2021

2122
import fire
2223
from packaging.version import parse
2324

2425
_REQUEST_TIMEOUT = 10
25-
_PATH_ROOT = os.path.dirname(os.path.dirname(__file__))
26+
_PATH_REPO_ROOT = Path(__file__).resolve().parent.parent
27+
_PATH_DIR_TESTS = _PATH_REPO_ROOT / "tests"
2628
_PKG_WIDE_SUBPACKAGES = ("utilities", "helpers")
2729
LUT_PYTHON_TORCH = {
2830
"3.8": "1.4",
2931
"3.9": "1.7.1",
3032
"3.10": "1.11",
3133
"3.11": "1.13",
3234
}
33-
_path_root = lambda *ds: os.path.join(_PATH_ROOT, *ds)
35+
_path_root = lambda *ds: os.path.join(_PATH_REPO_ROOT, *ds)
3436
REQUIREMENTS_FILES = (*glob.glob(_path_root("requirements", "*.txt")), _path_root("requirements.txt"))
3537

3638

@@ -190,10 +192,17 @@ def _crop_path(fname: str, paths: tuple[str] = ("src/torchmetrics/", "tests/unit
190192
if as_list: # keep only unique
191193
return list(test_modules)
192194

193-
test_modules = [f"unittests/{md}" for md in set(test_modules)]
194-
not_exists = [p for p in test_modules if os.path.exists(p)]
195+
test_modules = [os.path.join("unittests", fp) for fp in set(test_modules)]
196+
# filter only existing modules
197+
not_exists = [fp for fp in test_modules if not (_PATH_DIR_TESTS / fp).exists()]
195198
if not_exists:
196-
raise ValueError(f"Missing following paths: {not_exists}")
199+
logging.debug(f"Missing following paths: {not_exists}")
200+
# filter only existing path in repo
201+
test_modules = [fp for fp in test_modules if (_PATH_DIR_TESTS / fp).exists()]
202+
if not test_modules:
203+
logging.debug("No tests were changed -> rather test everything...")
204+
return _return_all
205+
197206
return " ".join(test_modules)
198207

199208
@staticmethod

0 commit comments

Comments
 (0)