-
-
Notifications
You must be signed in to change notification settings - Fork 617
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
Retry tests #3229
Retry tests #3229
Changes from all commits
0d600fa
447256a
50523aa
d827530
30be8f8
69fcf3d
f9c6407
d518be0
c8de5eb
57dfb63
0fa13cc
15acf1d
043e85b
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,102 @@ | ||
#!/bin/bash | ||
|
||
# Will catch exit code 5 when tests are deselected from previous passing run | ||
# (relevent for --last-failed-no-failures none) | ||
last_failed_no_failures_code=5 | ||
|
||
# functions shared across test files | ||
run_tests() { | ||
# Set defaults | ||
local core_args="-vvv tests/ignite" | ||
local cache_dir=".unknown-cache" | ||
local skip_distrib_tests=1 | ||
local match_tests_expression="" | ||
local trap_deselected_exit_code=1 | ||
local use_last_failed=0 | ||
local use_coverage=0 | ||
local world_size=0 | ||
# Always clean up pytest.ini | ||
trap 'rm -f pytest.ini' RETURN | ||
# Parse arguments | ||
while [[ $# -gt 0 ]] | ||
do | ||
key="$1" | ||
case $key in | ||
--core_args) | ||
core_args="$2" | ||
shift | ||
shift | ||
;; | ||
--cache_dir) | ||
cache_dir="$2" | ||
shift | ||
shift | ||
;; | ||
--skip_distrib_tests) | ||
skip_distrib_tests="$2" | ||
shift | ||
shift | ||
;; | ||
--match_tests_expression) | ||
match_tests_expression="$2" | ||
shift | ||
shift | ||
;; | ||
--trap_deselected_exit_code) | ||
trap_deselected_exit_code="$2" | ||
shift | ||
shift | ||
;; | ||
--use_last_failed) | ||
use_last_failed="$2" | ||
shift | ||
shift | ||
;; | ||
--use_coverage) | ||
use_coverage="$2" | ||
shift | ||
shift | ||
;; | ||
--world_size) | ||
world_size="$2" | ||
shift | ||
shift | ||
;; | ||
*) | ||
echo "Error: Unknown argument $key" | ||
exit 1 | ||
shift | ||
;; | ||
esac | ||
done | ||
|
||
if [ "${skip_distrib_tests}" -eq "1" ]; then | ||
# can be overwritten by core_args | ||
skip_distrib_opt="-m 'not distributed and not tpu and not multinode_distributed'" | ||
else | ||
skip_distrib_opt="" | ||
fi | ||
|
||
|
||
echo [pytest] > pytest.ini ; echo "cache_dir=${cache_dir}" >> pytest.ini | ||
|
||
# Assemble options for the pytest command | ||
pytest_args="${skip_distrib_opt} ${core_args} --treat-unrun-as-failed -k '${match_tests_expression}'" | ||
if [ "${use_last_failed:-0}" -eq "1" ] && [ -d "${cache_dir}" ]; then | ||
pytest_args="--last-failed --last-failed-no-failures none ${pytest_args}" | ||
fi | ||
if [ "${use_coverage}" -eq "1" ]; then | ||
pytest_args="--cov ignite --cov-append --cov-report term-missing --cov-report xml ${pytest_args}" | ||
fi | ||
if [ ! "${world_size}" -eq "0" ]; then | ||
export WORLD_SIZE="${world_size}" | ||
pytest_args="--dist=each --tx ${WORLD_SIZE}*popen//python=python ${pytest_args}" | ||
fi | ||
|
||
# Run the command | ||
if [ "$trap_deselected_exit_code" -eq "1" ]; then | ||
CUDA_VISIBLE_DEVICES="" eval "pytest ${pytest_args}" || { exit_code=$?; if [ "$exit_code" -eq ${last_failed_no_failures_code} ]; then echo "All tests deselected"; else exit $exit_code; fi; } | ||
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. why do we need 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 added an eval here because of some bugs I was running into where things like "-k ''" ends up as "-k" in the final command. The horrors of using eval are somewhat mitigated by the "-x" bash flag so that bugs in the command can be spotted more quickly. I think consistently using arrays for assembling commands in bash is a better alternative but I think using python is the best long term solution. |
||
else | ||
CUDA_VISIBLE_DEVICES="" eval "pytest ${pytest_args}" | ||
fi | ||
} |
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.
I wonder whether it would be more simple to write this script in python for later maintenance instead of a bash script and how much effort it would take?
If you think this is feasible we can do that in a follow-up PR
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.
I think it would be easy enough: largely just providing a simple cli, setting environment variables, and assembling commands to run as a subprocess. A few hours probably. Perhaps a few more to iron out issues and add some tests for it.
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.
OK, sounds good, let's make a python script instead of this bash script in a follow-up PR