-
-
Notifications
You must be signed in to change notification settings - Fork 247
[MNT] Diagnose and address long test runtimes (#1633) #1692
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| #!/bin/bash | ||
| # Profile test durations to diagnose slow tests (Issue #1633) | ||
| # | ||
| # Usage: ./scripts/profile_tests.sh [options] | ||
| # | ||
| # Options: | ||
| # -m MARKER Pytest marker filter (default: "not production_server and not test_server") | ||
| # -d DURATION Number of slowest durations to show, 0 for all (default: 20) | ||
| # -t TIMEOUT Per-test timeout in seconds (default: 300) | ||
| # -n WORKERS Number of parallel workers (default: 4) | ||
| # -o OUTPUT Output file path for the report (default: test_durations_report.txt) | ||
| # | ||
| # Examples: | ||
| # ./scripts/profile_tests.sh | ||
| # ./scripts/profile_tests.sh -m "production_server" -d 0 -t 600 | ||
| # ./scripts/profile_tests.sh -m "sklearn" -n 2 -o sklearn_report.txt | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| # Default values | ||
| MARKER_FILTER="not production_server and not test_server" | ||
| DURATIONS=20 | ||
| TIMEOUT=300 | ||
| NUM_WORKERS=4 | ||
| OUTPUT_FILE="test_durations_report.txt" | ||
|
|
||
| # Parse command line arguments | ||
| while getopts "m:d:t:n:o:" opt; do | ||
| case $opt in | ||
| m) MARKER_FILTER="$OPTARG" ;; | ||
| d) DURATIONS="$OPTARG" ;; | ||
| t) TIMEOUT="$OPTARG" ;; | ||
| n) NUM_WORKERS="$OPTARG" ;; | ||
| o) OUTPUT_FILE="$OPTARG" ;; | ||
| *) echo "Usage: $0 [-m marker] [-d durations] [-t timeout] [-n workers] [-o output_file]" && exit 1 ;; | ||
| esac | ||
| done | ||
|
|
||
| echo "=== OpenML Test Duration Profiler ===" | ||
| echo "Marker filter: $MARKER_FILTER" | ||
| echo "Durations to show: $DURATIONS" | ||
| echo "Timeout per test: ${TIMEOUT}s" | ||
| echo "Workers: $NUM_WORKERS" | ||
| echo "Output file: $OUTPUT_FILE" | ||
| echo "" | ||
|
|
||
| pytest \ | ||
| --dist=load \ | ||
| -n="$NUM_WORKERS" \ | ||
| --durations="$DURATIONS" \ | ||
| --timeout="$TIMEOUT" \ | ||
| -m "$MARKER_FILTER" \ | ||
| 2>&1 | tee "$OUTPUT_FILE" | ||
|
Comment on lines
+47
to
+53
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would also prefer additional argument pytest \
+ --dist=load \
+ -n=$NUM_WORKERS \
--durations="$DURATIONS" \
--timeout="$TIMEOUT" \
- -q \
-m "$MARKER_FILTER" \
2>&1 | tee "$OUTPUT_FILE"This would mimic the exact pytest command in CI
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for pointing out the changes. |
||
|
|
||
| echo "" | ||
| echo "=== Report saved to $OUTPUT_FILE ===" | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this file looks fine and we probably need this
duration, timeout and output file path should take value from users like markers and should have default value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update done The script now supports m (marker), d (durations), t (timeout), and o (output file) as CLI arguments, each with sensible default values. Let me know if you'd like any tweaks.