Skip to content

Commit ee612f9

Browse files
authored
[enh] generalize pytest configuration files (#2687)
* Update and rename .pytest-verbosity-args to pytest.ini * Update .licenserc.yaml * Update run_test.sh * Update run_test.bat * Update run_sklearn_tests.sh * Update run_sklearn_tests.py * Update run_sklearn_tests.sh * Update meta.yaml * Update run_test.bat * Update run_test.sh * Update run_test.bat * Update run_test.sh * Update run_sklearn_tests.sh * Update run_sklearn_tests.py * Update run_sklearn_tests.sh * Update run_sklearn_tests.py * Update run_sklearn_tests.sh * Update run_sklearn_tests.py * Update run_sklearn_tests.py * Update run_sklearn_tests.sh * Update run_sklearn_tests.sh * Update run_sklearn_tests.sh * swap to setup.cfg * further fixes * Update setup.cfg * Update run_sklearn_tests.sh * Update run_test.bat
1 parent 73f4602 commit ee612f9

File tree

7 files changed

+36
-23
lines changed

7 files changed

+36
-23
lines changed

.ci/scripts/run_sklearn_tests.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# Args:
1919
# 1 - device name (optional)
2020

21-
ci_dir=$( dirname $( dirname "${BASH_SOURCE[0]}" ) )
21+
ci_dir=$( dirname $( dirname $( realpath "${BASH_SOURCE[0]}" ) ) )
2222
cd $ci_dir
2323

2424
# selected tests might be set externally
@@ -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} $(cat ../.pytest-verbosity-args)
51+
python scripts/run_sklearn_tests.py -d ${1:-none} -c $( dirname $ci_dir )/setup.cfg
5252
exit $?

.github/.licenserc.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ header:
4242
# Clang-format configs
4343
- '.clang-format'
4444
- '_clang-format'
45-
# pytest arguments
46-
- .pytest-verbosity-args
4745
# All .csv and .ipynb files
4846
- '**/*.csv'
4947
- '**/*.ipynb'
@@ -70,7 +68,6 @@ header:
7068
- '.github/Pull_Request_template.md'
7169
- '.github/renovate.json'
7270
# Specific files
73-
- 'setup.cfg'
7471
- 'LICENSE'
7572
# External copies of copyrighted work
7673
- 'onedal/datatypes/dlpack/dlpack.h'

.pytest-verbosity-args

Lines changed: 0 additions & 1 deletion
This file was deleted.

conda-recipe/meta.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ test:
9393
- array-api-strict
9494
source_files:
9595
- .ci
96-
- .pytest-verbosity-args
96+
- setup.cfg
9797
- examples
9898
- tests
9999

conda-recipe/run_test.bat

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +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"
36+
set "PYTEST_CONFIG=-c %1setup.cfg"
3737

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

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

4949
echo "NO_DIST=%NO_DIST%"
5050
setlocal enabledelayedexpansion
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
51+
pytest %PYTEST_CONFIG% -s "%1tests" %PYTEST_ARGS:FILENAME=legacy_report% || set exitcode=1
52+
pytest %PYTEST_CONFIG% --pyargs daal4py %PYTEST_ARGS:FILENAME=daal4py_report% || set exitcode=1
53+
pytest %PYTEST_CONFIG% --pyargs sklearnex %PYTEST_ARGS:FILENAME=sklearnex_report% || set exitcode=1
54+
pytest %PYTEST_CONFIG% --pyargs onedal %PYTEST_ARGS:FILENAME=onedal_report% || set exitcode=1
55+
pytest %PYTEST_CONFIG% "%1.ci\scripts\test_global_patch.py" %PYTEST_ARGS:FILENAME=global_patching_report% || set exitcode=1
5656
if NOT "%NO_DIST%"=="1" (
5757
%PYTHON% "%1tests\helper_mpi_tests.py"^
58-
pytest -k spmd --with-mpi %PYTEST_VERBOSITY_ARGS% -s --pyargs sklearnex %PYTEST_ARGS:FILENAME=sklearnex_spmd%
58+
pytest -k spmd --with-mpi %PYTEST_CONFIG% -s --pyargs sklearnex %PYTEST_ARGS:FILENAME=sklearnex_spmd%
5959
if !errorlevel! NEQ 0 (
6060
set exitcode=1
6161
)
6262
%PYTHON% "%1tests\helper_mpi_tests.py"^
63-
pytest --with-mpi %PYTEST_VERBOSITY_ARGS% -s "%1tests\test_daal4py_spmd_examples.py" %PYTEST_ARGS:FILENAME=mpi_legacy%
63+
pytest --with-mpi %PYTEST_CONFIG% -s "%1tests\test_daal4py_spmd_examples.py" %PYTEST_ARGS:FILENAME=mpi_legacy%
6464
if !errorlevel! NEQ 0 (
6565
set exitcode=1
6666
)

conda-recipe/run_test.sh

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

63-
PYTEST_VERBOSITY_ARGS=$(cat "${sklex_root}/.pytest-verbosity-args")
63+
PYTEST_CONFIG="-c ${sklex_root}/setup.cfg"
6464

6565
${PYTHON} -c "from sklearnex import patch_sklearn; patch_sklearn()"
6666
return_code=$(($return_code + $?))
6767

68-
pytest ${PYTEST_VERBOSITY_ARGS} -s "${sklex_root}/tests" $@ $(generate_pytest_args legacy)
68+
pytest ${PYTEST_CONFIG} -s "${sklex_root}/tests" $@ $(generate_pytest_args legacy)
6969
return_code=$(($return_code + $?))
7070

71-
pytest ${PYTEST_VERBOSITY_ARGS} --pyargs daal4py $@ $(generate_pytest_args daal4py)
71+
pytest ${PYTEST_CONFIG} --pyargs daal4py $@ $(generate_pytest_args daal4py)
7272
return_code=$(($return_code + $?))
7373

74-
pytest ${PYTEST_VERBOSITY_ARGS} --pyargs sklearnex $@ $(generate_pytest_args sklearnex)
74+
pytest ${PYTEST_CONFIG} --pyargs sklearnex $@ $(generate_pytest_args sklearnex)
7575
return_code=$(($return_code + $?))
7676

77-
pytest ${PYTEST_VERBOSITY_ARGS} --pyargs onedal $@ $(generate_pytest_args onedal)
77+
pytest ${PYTEST_CONFIG} --pyargs onedal $@ $(generate_pytest_args onedal)
7878
return_code=$(($return_code + $?))
7979

80-
pytest ${PYTEST_VERBOSITY_ARGS} -s "${sklex_root}/.ci/scripts/test_global_patch.py" $@ $(generate_pytest_args global_patching)
80+
pytest ${PYTEST_CONFIG} -s "${sklex_root}/.ci/scripts/test_global_patch.py" $@ $(generate_pytest_args global_patching)
8181
return_code=$(($return_code + $?))
8282

8383
echo "NO_DIST=$NO_DIST"
@@ -92,10 +92,10 @@ if [[ ! $NO_DIST ]]; then
9292
export EXTRA_MPI_ARGS="-n 4"
9393
fi
9494
mpirun ${EXTRA_MPI_ARGS} python "${sklex_root}/tests/helper_mpi_tests.py" \
95-
pytest -k spmd --with-mpi ${PYTEST_VERBOSITY_ARGS} --pyargs sklearnex $@ $(generate_pytest_args sklearnex_spmd)
95+
pytest -k spmd --with-mpi ${PYTEST_CONFIG} --pyargs sklearnex $@ $(generate_pytest_args sklearnex_spmd)
9696
return_code=$(($return_code + $?))
9797
mpirun ${EXTRA_MPI_ARGS} python "${sklex_root}/tests/helper_mpi_tests.py" \
98-
pytest ${PYTEST_VERBOSITY_ARGS} -s "${sklex_root}/tests/test_daal4py_spmd_examples.py" $@ $(generate_pytest_args mpi_legacy)
98+
pytest ${PYTEST_CONFIG} -s "${sklex_root}/tests/test_daal4py_spmd_examples.py" $@ $(generate_pytest_args mpi_legacy)
9999
return_code=$(($return_code + $?))
100100
fi
101101

setup.cfg

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
# Copyright contributors to the oneDAL project
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
114
[metadata]
215
license_files =
316
LICENSE
@@ -7,3 +20,7 @@ license_files =
720
ignore = E265, E722, E402, F401, F403, W503
821
max-line-length = 90
922
count = true
23+
24+
[tool:pytest]
25+
addopts = --verbose --durations=100 --durations-min=0.05
26+

0 commit comments

Comments
 (0)