Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions environment-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ dependencies:
- flake8-bugbear
- flake8-comprehensions
- flake8-pyi
- pylint
- mccabe
- pep8-naming
- pycodestyle
Expand Down
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ flake8-bugbear
flake8-comprehensions
flake8-executable
flake8-pyi
pylint
mccabe
pep8-naming
pycodestyle
Expand Down
36 changes: 34 additions & 2 deletions runtests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ doBlackFix=false
doIsortFormat=false
doIsortFix=false
doFlake8Format=false
doPylintFormat=false
doClangFormat=false
doCopyRight=false
doPytypeFormat=false
Expand All @@ -56,7 +57,7 @@ NUM_PARALLEL=1
PY_EXE=${MONAI_PY_EXE:-$(which python)}

function print_usage {
echo "runtests.sh [--codeformat] [--autofix] [--black] [--isort] [--flake8] [--clangformat] [--pytype] [--mypy]"
echo "runtests.sh [--codeformat] [--autofix] [--black] [--isort] [--flake8] [--pylint] [--clangformat] [--pytype] [--mypy]"
echo " [--unittests] [--disttests] [--coverage] [--quick] [--min] [--net] [--dryrun] [-j number] [--list_tests]"
echo " [--copyright] [--build] [--clean] [--help] [--version]"
echo ""
Expand All @@ -75,6 +76,7 @@ function print_usage {
echo " --autofix : format code using \"isort\" and \"black\""
echo " --isort : perform \"isort\" import sort checks"
echo " --flake8 : perform \"flake8\" code format checks"
echo " --pylint : perform \"pylint\" code format checks"
echo " --clangformat : format csrc code using \"clang-format\""
echo ""
echo "Python type check options:"
Expand Down Expand Up @@ -241,6 +243,7 @@ do
doBlackFormat=true
doIsortFormat=true
doFlake8Format=true
doPylintFormat=true
doPytypeFormat=true
doMypyFormat=true
doCopyRight=true
Expand All @@ -267,6 +270,9 @@ do
--flake8)
doFlake8Format=true
;;
--pylint)
doPylintFormat=true
;;
--pytype)
doPytypeFormat=true
;;
Expand Down Expand Up @@ -463,7 +469,7 @@ then

# ensure that the necessary packages for code format testing are installed
if ! is_pip_installed flake8
then
then
install_deps
fi
${cmdPrefix}${PY_EXE} -m flake8 --version
Expand All @@ -481,6 +487,32 @@ then
set -e # enable exit on failure
fi

if [ $doPylintFormat = true ]
then
set +e # disable exit on failure so that diagnostics can be given on failure
echo "${separator}${blue}pylint${noColor}"

# ensure that the necessary packages for code format testing are installed
if ! is_pip_installed flake8
then
install_deps
fi
${cmdPrefix}${PY_EXE} -m pylint --version

ignore_codes="E1101,E1102,E0601,E1130,E1123,E0102,E1120,E1137,E1136"
${cmdPrefix}${PY_EXE} -m pylint monai tests -E --disable=$ignore_codes -j $NUM_PARALLEL
pylint_status=$?

if [ ${pylint_status} -ne 0 ]
then
print_style_fail_msg
exit ${pylint_status}
else
echo "${green}passed!${noColor}"
fi
set -e # enable exit on failure
fi


if [ $doPytypeFormat = true ]
then
Expand Down
4 changes: 3 additions & 1 deletion tests/hvd_evenly_divisible_all_gather.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import horovod.torch as hvd
import torch

from monai.utils import evenly_divisible_all_gather
from monai.utils.module import optional_import

hvd, has_hvd = optional_import("horovod", name="torch")


class HvdEvenlyDivisibleAllGather:
Expand Down