diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5700382e5f..ca40261dea 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -87,7 +87,8 @@ If you intend for any variables/functions/classes to be available outside of the #### Unit testing MONAI tests are located under `tests/`. -- The unit test's file name follows `test_[module_name].py`. +- The unit test's file name currently follows `test_[module_name].py` or `test_[module_name]_dist.py`. +- The `test_[module_name]_dist.py` subset of unit tests requires a distributed environment to verify the module with distributed GPU-based computation. - The integration test's file name follows `test_integration_[workflow_name].py`. A bash script (`runtests.sh`) is provided to run all tests locally. diff --git a/runtests.sh b/runtests.sh index 0e87a3a4e5..38f26347bb 100755 --- a/runtests.sh +++ b/runtests.sh @@ -46,6 +46,7 @@ doClangFormat=false doPytypeFormat=false doMypyFormat=false doCleanup=false +doDistTests=false NUM_PARALLEL=1 @@ -53,7 +54,7 @@ PY_EXE=${MONAI_PY_EXE:-$(which python)} function print_usage { echo "runtests.sh [--codeformat] [--autofix] [--black] [--isort] [--flake8] [--clangformat] [--pytype] [--mypy]" - echo " [--unittests] [--coverage] [--quick] [--net] [--dryrun] [-j number] [--clean] [--help] [--version]" + echo " [--unittests] [--disttests] [--coverage] [--quick] [--net] [--dryrun] [-j number] [--clean] [--help] [--version]" echo "" echo "MONAI unit testing utilities." echo "" @@ -79,6 +80,7 @@ function print_usage { echo "" echo "MONAI unit testing options:" echo " -u, --unittests : perform unit testing" + echo " --disttests : perform distributed unit testing" echo " --coverage : report testing code coverage, to be used with \"--net\", \"--unittests\"" echo " -q, --quick : skip long running unit tests and integration tests" echo " --net : perform integration testing" @@ -232,6 +234,9 @@ do doPytypeFormat=true doMypyFormat=true ;; + --disttests) + doDistTests=true + ;; --black) doBlackFormat=true ;; @@ -519,6 +524,14 @@ then ${cmdPrefix}${cmd} ./tests/runner.py -p "test_((?!integration).)" fi +# distributed test only +if [ $doDistTests = true ] +then + echo "${separator}${blue}run distributed unit test cases${noColor}" + torch_validate + ${cmdPrefix}${cmd} ./tests/runner.py -p "test_.*_dist$" +fi + # network training/inference/eval integration tests if [ $doNetTests = true ] then