Skip to content

Commit c8fd9a9

Browse files
AbhishekAbhishek9639
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 149d23c commit c8fd9a9

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
@@ -153,7 +153,7 @@ jobs:
153153
marks="not production_server"
154154
fi
155155
156-
pytest -n 4 --durations=0 --timeout=600 --dist load -sv $codecov -o log_cli=true -m "$marks"
156+
pytest -n 4 --durations=20 --dist load -sv $codecov -o log_cli=true -m "$marks"
157157
158158
- name: Run tests on Ubuntu Production
159159
if: matrix.os == 'ubuntu-latest'
@@ -171,14 +171,14 @@ jobs:
171171
marks="production_server"
172172
fi
173173
174-
pytest -n 4 --durations=0 --timeout=600 --dist load -sv $codecov -o log_cli=true -m "$marks"
174+
pytest -n 4 --durations=20 --dist load -sv $codecov -o log_cli=true -m "$marks"
175175
176176
- name: Run tests on Windows
177177
if: matrix.os == 'windows-latest'
178178
env:
179179
OPENML_TEST_SERVER_ADMIN_KEY: ${{ secrets.OPENML_TEST_SERVER_ADMIN_KEY }}
180180
run: | # we need a separate step because of the bash-specific if-statement in the previous one.
181-
pytest -n 4 --durations=0 --timeout=600 --dist load -sv --reruns 5 --reruns-delay 1 -m "not test_server"
181+
pytest -n 4 --durations=20 --dist load -sv --reruns 5 --reruns-delay 1 -m "not test_server"
182182
183183
- name: Upload coverage
184184
if: matrix.code-cov && always()

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ log_level="DEBUG"
130130
testpaths = ["tests"]
131131
minversion = "7.0"
132132
xfail_strict = true
133-
timeout = 600
134133
filterwarnings=[
135134
"ignore:the matrix subclass:PendingDeprecationWarning"
136135
]

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
@@ -276,7 +276,7 @@ def test_apikey_v2() -> str:
276276
return openml.config.get_test_servers()[APIVersion.V2]["apikey"]
277277

278278

279-
@pytest.fixture(autouse=True, scope="module")
279+
@pytest.fixture(autouse=True, scope="function")
280280
def verify_cache_state(test_files_directory) -> Iterator[None]:
281281
assert_static_test_cache_correct(test_files_directory)
282282
yield

0 commit comments

Comments
 (0)