Skip to content

Commit e8f290e

Browse files
authored
Enable common verbosity arguments for pytest (#2647)
* Enable common arguments for pytest * Store pytest verbosity args in common file * Fix typos in script * Linting * Exception for license check * Include pytest args file in conda-recipe testing * Change entry point to pass args to sklearn tests
1 parent 5543aa4 commit e8f290e

File tree

7 files changed

+22
-16
lines changed

7 files changed

+22
-16
lines changed

.ci/scripts/run_sklearn_tests.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
os.environ["SCIPY_ARRAY_API"] = "1"
5050

5151
pytest_args = (
52-
"--verbose --durations=100 --durations-min=0.01 "
5352
f"--rootdir={sklearn_file_dir} "
5453
f'{os.environ["DESELECTED_TESTS"]} {os.environ["SELECTED_TESTS"]}'.split(" ")
5554
)

.ci/scripts/run_sklearn_tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,5 @@ if [ -n "$(pip list | grep dpctl)" ]; then
4848
python -c "import dpctl; print(dpctl.get_devices())"
4949
fi
5050

51-
python scripts/run_sklearn_tests.py -d ${1:-none}
51+
python scripts/run_sklearn_tests.py -d ${1:-none} $(cat ../.pytest-verbosity-args)
5252
exit $?

.github/.licenserc.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ header:
4242
# Clang-format configs
4343
- '.clang-format'
4444
- '_clang-format'
45+
# pytest arguments
46+
- .pytest-verbosity-args
4547
# All .csv and .ipynb files
4648
- '**/*.csv'
4749
- '**/*.ipynb'

.pytest-verbosity-args

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--verbose --durations=100 --durations-min=0.05

conda-recipe/meta.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ test:
9595
- array-api-strict
9696
source_files:
9797
- .ci
98+
- .pytest-verbosity-args
9899
- examples
99100
- tests
100101

conda-recipe/run_test.bat

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ if "%PYTHON%"=="python" (
3333
%PYTHON% -c "from sklearnex import patch_sklearn; patch_sklearn()" || set exitcode=1
3434

3535
set "PYTEST_ARGS= "
36+
set /p PYTEST_VERBOSITY_ARGS=<"%1.pytest-verbosity-args"
3637

3738
IF DEFINED COVERAGE_RCFILE (set "PYTEST_ARGS=--cov=onedal --cov=sklearnex --cov-config=%COVERAGE_RCFILE% --cov-append --cov-branch --cov-report= %PYTEST_ARGS%")
3839

@@ -47,19 +48,19 @@ if "%~2"=="--json-report" (
4748

4849
echo "NO_DIST=%NO_DIST%"
4950
setlocal enabledelayedexpansion
50-
pytest --verbose -s "%1tests" %PYTEST_ARGS:FILENAME=legacy_report% || set exitcode=1
51-
pytest --verbose --pyargs daal4py %PYTEST_ARGS:FILENAME=daal4py_report% || set exitcode=1
52-
pytest --verbose --pyargs sklearnex %PYTEST_ARGS:FILENAME=sklearnex_report% || set exitcode=1
53-
pytest --verbose --pyargs onedal %PYTEST_ARGS:FILENAME=onedal_report% || set exitcode=1
54-
pytest --verbose "%1.ci\scripts\test_global_patch.py" %PYTEST_ARGS:FILENAME=global_patching_report% || set exitcode=1
51+
pytest %PYTEST_VERBOSITY_ARGS% -s "%1tests" %PYTEST_ARGS:FILENAME=legacy_report% || set exitcode=1
52+
pytest %PYTEST_VERBOSITY_ARGS% --pyargs daal4py %PYTEST_ARGS:FILENAME=daal4py_report% || set exitcode=1
53+
pytest %PYTEST_VERBOSITY_ARGS% --pyargs sklearnex %PYTEST_ARGS:FILENAME=sklearnex_report% || set exitcode=1
54+
pytest %PYTEST_VERBOSITY_ARGS% --pyargs onedal %PYTEST_ARGS:FILENAME=onedal_report% || set exitcode=1
55+
pytest %PYTEST_VERBOSITY_ARGS% "%1.ci\scripts\test_global_patch.py" %PYTEST_ARGS:FILENAME=global_patching_report% || set exitcode=1
5556
if NOT "%NO_DIST%"=="1" (
5657
%PYTHON% "%1tests\helper_mpi_tests.py"^
57-
pytest -k spmd --with-mpi --verbose -s --pyargs sklearnex %PYTEST_ARGS:FILENAME=sklearnex_spmd%
58+
pytest -k spmd --with-mpi %PYTEST_VERBOSITY_ARGS% -s --pyargs sklearnex %PYTEST_ARGS:FILENAME=sklearnex_spmd%
5859
if !errorlevel! NEQ 0 (
5960
set exitcode=1
6061
)
6162
%PYTHON% "%1tests\helper_mpi_tests.py"^
62-
pytest --with-mpi --verbose -s "%1tests\test_daal4py_spmd_examples.py" %PYTEST_ARGS:FILENAME=mpi_legacy%
63+
pytest --with-mpi %PYTEST_VERBOSITY_ARGS% -s "%1tests\test_daal4py_spmd_examples.py" %PYTEST_ARGS:FILENAME=mpi_legacy%
6364
if !errorlevel! NEQ 0 (
6465
set exitcode=1
6566
)

conda-recipe/run_test.sh

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,22 +60,24 @@ function generate_pytest_args {
6060
printf -- "${ARGS[*]}"
6161
}
6262

63+
PYTEST_VERBOSITY_ARGS=$(cat "${sklex_root}/.pytest-verbosity-args")
64+
6365
${PYTHON} -c "from sklearnex import patch_sklearn; patch_sklearn()"
6466
return_code=$(($return_code + $?))
6567

66-
pytest --verbose -s "${sklex_root}/tests" $@ $(generate_pytest_args legacy)
68+
pytest ${PYTEST_VERBOSITY_ARGS} -s "${sklex_root}/tests" $@ $(generate_pytest_args legacy)
6769
return_code=$(($return_code + $?))
6870

69-
pytest --verbose --pyargs daal4py $@ $(generate_pytest_args daal4py)
71+
pytest ${PYTEST_VERBOSITY_ARGS} --pyargs daal4py $@ $(generate_pytest_args daal4py)
7072
return_code=$(($return_code + $?))
7173

72-
pytest --verbose --pyargs sklearnex $@ $(generate_pytest_args sklearnex)
74+
pytest ${PYTEST_VERBOSITY_ARGS} --pyargs sklearnex $@ $(generate_pytest_args sklearnex)
7375
return_code=$(($return_code + $?))
7476

75-
pytest --verbose --pyargs onedal $@ $(generate_pytest_args onedal)
77+
pytest ${PYTEST_VERBOSITY_ARGS} --pyargs onedal $@ $(generate_pytest_args onedal)
7678
return_code=$(($return_code + $?))
7779

78-
pytest --verbose -s "${sklex_root}/.ci/scripts/test_global_patch.py" $@ $(generate_pytest_args global_patching)
80+
pytest ${PYTEST_VERBOSITY_ARGS} -s "${sklex_root}/.ci/scripts/test_global_patch.py" $@ $(generate_pytest_args global_patching)
7981
return_code=$(($return_code + $?))
8082

8183
echo "NO_DIST=$NO_DIST"
@@ -90,10 +92,10 @@ if [[ ! $NO_DIST ]]; then
9092
export EXTRA_MPI_ARGS="-n 4"
9193
fi
9294
mpirun ${EXTRA_MPI_ARGS} python "${sklex_root}/tests/helper_mpi_tests.py" \
93-
pytest -k spmd --with-mpi --verbose --pyargs sklearnex $@ $(generate_pytest_args sklearnex_spmd)
95+
pytest -k spmd --with-mpi ${PYTEST_VERBOSITY_ARGS} --pyargs sklearnex $@ $(generate_pytest_args sklearnex_spmd)
9496
return_code=$(($return_code + $?))
9597
mpirun ${EXTRA_MPI_ARGS} python "${sklex_root}/tests/helper_mpi_tests.py" \
96-
pytest --verbose -s "${sklex_root}/tests/test_daal4py_spmd_examples.py" $@ $(generate_pytest_args mpi_legacy)
98+
pytest ${PYTEST_VERBOSITY_ARGS} -s "${sklex_root}/tests/test_daal4py_spmd_examples.py" $@ $(generate_pytest_args mpi_legacy)
9799
return_code=$(($return_code + $?))
98100
fi
99101

0 commit comments

Comments
 (0)