Skip to content

Commit ede2e0d

Browse files
AbhishekAbhishek
authored andcommitted
Address review feedback: revert CI/conftest changes, improve profile script
- Revert CI workflow to original --durations=20 (no timeout) - Remove global timeout from pyproject.toml - Revert conftest.py verify_cache_state scope to function - Update profile_tests.sh: accept CLI args (-m, -d, -t, -o) with defaults
1 parent 07243d1 commit ede2e0d

4 files changed

Lines changed: 38 additions & 15 deletions

File tree

.github/workflows/test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ jobs:
119119
marks="not production_server and not test_server"
120120
fi
121121
122-
pytest -n 4 --durations=0 --timeout=600 --dist load -sv $codecov -o log_cli=true -m "$marks"
122+
pytest -n 4 --durations=20 --dist load -sv $codecov -o log_cli=true -m "$marks"
123123
124124
- name: Run tests on Ubuntu Production
125125
if: matrix.os == 'ubuntu-latest'
@@ -136,14 +136,14 @@ jobs:
136136
marks="production_server and not test_server"
137137
fi
138138
139-
pytest -n 4 --durations=0 --timeout=600 --dist load -sv $codecov -o log_cli=true -m "$marks"
139+
pytest -n 4 --durations=20 --dist load -sv $codecov -o log_cli=true -m "$marks"
140140
141141
- name: Run tests on Windows
142142
if: matrix.os == 'windows-latest'
143143
env:
144144
OPENML_TEST_SERVER_ADMIN_KEY: ${{ secrets.OPENML_TEST_SERVER_ADMIN_KEY }}
145145
run: | # we need a separate step because of the bash-specific if-statement in the previous one.
146-
pytest -n 4 --durations=0 --timeout=600 --dist load -sv --reruns 5 --reruns-delay 1 -m "not test_server"
146+
pytest -n 4 --durations=20 --dist load -sv --reruns 5 --reruns-delay 1 -m "not test_server"
147147
148148
- name: Check for files left behind by test
149149
if: matrix.os != 'windows-latest' && always()

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ version = {attr = "openml.__version__.__version__"}
129129
testpaths = ["tests"]
130130
minversion = "7.0"
131131
xfail_strict = true
132-
timeout = 600
133132
filterwarnings=[
134133
"ignore:the matrix subclass:PendingDeprecationWarning"
135134
]

scripts/profile_tests.sh

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,51 @@
11
#!/bin/bash
22
# Profile test durations to diagnose slow tests (Issue #1633)
3-
# Usage: ./scripts/profile_tests.sh [marker_filter]
3+
#
4+
# Usage: ./scripts/profile_tests.sh [options]
5+
#
6+
# Options:
7+
# -m MARKER Pytest marker filter (default: "not production_server and not test_server")
8+
# -d DURATION Number of slowest durations to show, 0 for all (default: 20)
9+
# -t TIMEOUT Per-test timeout in seconds (default: 300)
10+
# -o OUTPUT Output file path for the report (default: test_durations_report.txt)
411
#
512
# Examples:
6-
# ./scripts/profile_tests.sh # non-server tests
7-
# ./scripts/profile_tests.sh "production_server" # production server tests only
8-
# ./scripts/profile_tests.sh "sklearn" # sklearn tests only
13+
# ./scripts/profile_tests.sh
14+
# ./scripts/profile_tests.sh -m "production_server" -d 0 -t 600
15+
# ./scripts/profile_tests.sh -m "sklearn" -o sklearn_report.txt
916

1017
set -euo pipefail
1118

12-
MARKER_FILTER="${1:-not production_server and not test_server}"
19+
# Default values
20+
MARKER_FILTER="not production_server and not test_server"
21+
DURATIONS=20
22+
TIMEOUT=300
23+
OUTPUT_FILE="test_durations_report.txt"
24+
25+
# Parse command line arguments
26+
while getopts "m:d:t:o:" opt; do
27+
case $opt in
28+
m) MARKER_FILTER="$OPTARG" ;;
29+
d) DURATIONS="$OPTARG" ;;
30+
t) TIMEOUT="$OPTARG" ;;
31+
o) OUTPUT_FILE="$OPTARG" ;;
32+
*) echo "Usage: $0 [-m marker] [-d durations] [-t timeout] [-o output_file]" && exit 1 ;;
33+
esac
34+
done
1335

1436
echo "=== OpenML Test Duration Profiler ==="
1537
echo "Marker filter: $MARKER_FILTER"
16-
echo "Timeout per test: 300s"
38+
echo "Durations to show: $DURATIONS"
39+
echo "Timeout per test: ${TIMEOUT}s"
40+
echo "Output file: $OUTPUT_FILE"
1741
echo ""
1842

1943
pytest \
20-
--durations=0 \
21-
--timeout=300 \
44+
--durations="$DURATIONS" \
45+
--timeout="$TIMEOUT" \
2246
-q \
2347
-m "$MARKER_FILTER" \
24-
2>&1 | tee test_durations_report.txt
48+
2>&1 | tee "$OUTPUT_FILE"
2549

2650
echo ""
27-
echo "=== Report saved to test_durations_report.txt ==="
51+
echo "=== Report saved to $OUTPUT_FILE ==="

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ def test_api_key() -> str:
255255
return TestBase.user_key
256256

257257

258-
@pytest.fixture(autouse=True, scope="module")
258+
@pytest.fixture(autouse=True, scope="function")
259259
def verify_cache_state(test_files_directory) -> Iterator[None]:
260260
assert_static_test_cache_correct(test_files_directory)
261261
yield

0 commit comments

Comments
 (0)