Skip to content

Commit 002a465

Browse files
authored
Fix filtering test names in run_standalone_tests.sh when checking for errors (#19176)
1 parent 6d47bf1 commit 002a465

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

tests/run_standalone_tests.sh

100644100755
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,13 @@ parametrizations_arr=($parametrizations)
4141
report=''
4242

4343
rm -f standalone_test_output.txt # in case it exists, remove it
44+
rm -f testnames.txt
45+
4446
function show_batched_output {
4547
if [ -f standalone_test_output.txt ]; then # if exists
4648
cat standalone_test_output.txt
4749
# heuristic: stop if there's mentions of errors. this can prevent false negatives when only some of the ranks fail
48-
if grep -iE 'error|exception|traceback|failed' standalone_test_output.txt | grep -qvE 'on_exception|xfailed'; then
50+
if grep -iE 'error|exception|traceback|failed' standalone_test_output.txt | grep -vE 'on_exception|xfailed' | grep -qv -f testnames.txt; then
4951
echo "Potential error! Stopping."
5052
rm standalone_test_output.txt
5153
exit 1
@@ -57,11 +59,13 @@ trap show_batched_output EXIT # show the output on exit
5759

5860
# remove the "tests/tests_pytorch/" path suffixes
5961
path_prefix=$(basename "$(dirname "$(pwd)")")/$(basename "$(pwd)")"/" # https://stackoverflow.com/a/8223345
62+
6063
for i in "${!parametrizations_arr[@]}"; do
6164
parametrization=${parametrizations_arr[$i]//$path_prefix/}
6265
prefix="$((i+1))/${#parametrizations_arr[@]}"
6366

6467
echo "$prefix: Running $parametrization"
68+
echo $parametrization | sed 's/\[[^][]*\]//g' >> testnames.txt
6569

6670
# fix the port to avoid race condition when batched distributed tests select the port randomly
6771
export MASTER_PORT=$((29500 + $i % $test_batch_size))

tests/tests_pytorch/strategies/test_ddp_integration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ def test_find_unused_parameters_ddp_spawn_raises():
212212

213213

214214
@RunIf(standalone=True)
215-
def test_find_unused_parameters_ddp_raises():
215+
def test_find_unused_parameters_ddp_exception():
216216
"""Test that the DDP strategy can change PyTorch's error message so that it's more useful for Lightning users."""
217217
trainer = Trainer(accelerator="cpu", devices=1, strategy="ddp", max_steps=2, logger=False)
218218
with pytest.raises(RuntimeError, match="It looks like your LightningModule has parameters that were not used in"):

0 commit comments

Comments
 (0)