Skip to content

Add tests folder to dpnp conda package #2116

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

Merged
merged 87 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
3e42166
Move tests to dpnp folder
vlad-perevezentsev Sep 25, 2024
c9a0622
Update import paths for dpnp tests
vlad-perevezentsev Sep 25, 2024
2755aab
Update paths in skipped_tests files
vlad-perevezentsev Sep 25, 2024
223e4a4
Update import paths in tests_perf
vlad-perevezentsev Sep 25, 2024
cda88b5
Update import paths in cupy/testing
vlad-perevezentsev Sep 25, 2024
39fdc4e
Update import paths in all cupy tests
vlad-perevezentsev Sep 26, 2024
0a91a52
Merge master into move_tests_folder
vlad-perevezentsev Oct 16, 2024
be7a9c0
Update tests path in pyproject.toml
vlad-perevezentsev Oct 16, 2024
a976f39
Remove MANIFEST.in
vlad-perevezentsev Oct 17, 2024
82b5568
Add tests folder to conda package
vlad-perevezentsev Oct 17, 2024
4c6c78f
Simplify meta.yaml: move test logic to run_test.sh
vlad-perevezentsev Oct 17, 2024
db2a453
Move pytest config from setup.cfg to conftest.py
vlad-perevezentsev Oct 17, 2024
d4253ae
Update call pytest in gen_coverage.py
vlad-perevezentsev Oct 17, 2024
8088e3a
Update path to cupy.testing in some tests
vlad-perevezentsev Oct 18, 2024
4aded88
Update test paths for github action test_linux
vlad-perevezentsev Oct 18, 2024
7e97155
Undo moving tests to dpnp folder
vlad-perevezentsev Oct 24, 2024
a8b7f75
Copy tests folder to conda package
vlad-perevezentsev Oct 25, 2024
81c0850
Undo updating paths in skipped files
vlad-perevezentsev Oct 25, 2024
5776a63
Undo updating tests paths in pyproject.toml
vlad-perevezentsev Oct 25, 2024
df9e0a4
Optimize test skipping and path normalization in conftest.py
vlad-perevezentsev Oct 25, 2024
6d697db
Merge master into move_tests_folder
vlad-perevezentsev Oct 25, 2024
ec45c7c
Add norecursedirs config for tests_perf in conftest.py
vlad-perevezentsev Oct 25, 2024
ec23647
Use relative imports in tests/testing
vlad-perevezentsev Oct 25, 2024
e6c4ea3
Use relative imports in tests/tests_perf
vlad-perevezentsev Oct 25, 2024
a8e91e0
Use relative imports for dpnp tests
vlad-perevezentsev Oct 25, 2024
b99d7b1
Use relative imports in tests/third_party/cupy/testing/
vlad-perevezentsev Oct 25, 2024
878300e
Update docs for _loops.py
vlad-perevezentsev Oct 25, 2024
ff6d2b3
Use .helper in cupy/testing/__init__.py
vlad-perevezentsev Oct 25, 2024
326276b
Use relative imports in cupy tests
vlad-perevezentsev Oct 25, 2024
66ad5d8
Add empty __init__.py files to cupy tests
vlad-perevezentsev Oct 25, 2024
a342e04
Update import path in test_add_remove.py
vlad-perevezentsev Oct 25, 2024
b80939c
Undo updating call pytest on gen_coverage.py
vlad-perevezentsev Oct 25, 2024
5380aff
Update tests-path for GH Actions
vlad-perevezentsev Oct 28, 2024
a0aba61
Merge master into move_tests_folder
vlad-perevezentsev Oct 28, 2024
4edbbd1
Show extra test summary info in internal CI
vlad-perevezentsev Oct 28, 2024
f410961
Fix normalize_test_name() to support subdirectories
vlad-perevezentsev Oct 28, 2024
6a1ffac
Remove debug lines in conftest.py
vlad-perevezentsev Oct 28, 2024
14e4111
Update normalize_test_name to run pytest from diff paths
vlad-perevezentsev Oct 29, 2024
b996d90
Add run_test.bat to conda-recipe
vlad-perevezentsev Oct 29, 2024
351f101
Fix setting tests_path for Windows in conda-package.yml
vlad-perevezentsev Oct 29, 2024
d5fb73f
Update ser tests_path for windows
vlad-perevezentsev Oct 29, 2024
1388816
Add debug info for test_windows
vlad-perevezentsev Oct 29, 2024
ea9f5fd
Debug info
vlad-perevezentsev Oct 29, 2024
2d6c1a8
Use sysconfig to detect tests_path on Windows
vlad-perevezentsev Oct 30, 2024
4d049e8
Use --rootdir for test_windows in public CI
vlad-perevezentsev Oct 30, 2024
cf22ee8
Update pre-commit settings to move tests folder
vlad-perevezentsev Oct 31, 2024
c2f55a6
Move tests to dpnp folder
vlad-perevezentsev Oct 31, 2024
6f87e4a
Use absolute import paths in cupy tests
vlad-perevezentsev Oct 31, 2024
c7d3811
Update tests path in pyproject.toml
vlad-perevezentsev Oct 31, 2024
bf57f31
Use package_data instead of data_files in setup.py to pack tests
vlad-perevezentsev Oct 31, 2024
8c8b86a
Update args for generate coverage
vlad-perevezentsev Oct 31, 2024
c89e134
Merge master into move_tests_folder
vlad-perevezentsev Nov 3, 2024
1cf7670
Update import path in test_arraypad.py
vlad-perevezentsev Nov 4, 2024
ca4d440
Add debug info for Public CI Win
vlad-perevezentsev Nov 4, 2024
1d44b35
Run only python 3.11 GH Actions
vlad-perevezentsev Nov 4, 2024
c1fe7c2
Use cd %tests_path%
vlad-perevezentsev Nov 4, 2024
76f610b
use pushd to move to tests folder
vlad-perevezentsev Nov 4, 2024
a73b121
Switch to C: drive for test_windows
vlad-perevezentsev Nov 4, 2024
7e253c9
Merge master into move_tests_folder
vlad-perevezentsev Nov 4, 2024
c33e3d3
Remove debug lines
vlad-perevezentsev Nov 4, 2024
26a4b4b
Merge master into move_tests_folder
vlad-perevezentsev Nov 4, 2024
2cdca1e
Rename TEST_SCOPE files to use pytest --pyargs
vlad-perevezentsev Nov 5, 2024
cac52d8
Run tests from test_tmp folder
vlad-perevezentsev Nov 5, 2024
80e7d72
Use --pyargs for tests in public CI
vlad-perevezentsev Nov 5, 2024
61b68ac
Run tests from {github.workspace} and use pytest for public CI
vlad-perevezentsev Nov 6, 2024
ac8ac50
Merge master into move_tests_folder
vlad-perevezentsev Nov 6, 2024
7e410c4
Run all tests by --pyargs dpnp.tests in public CI
vlad-perevezentsev Nov 6, 2024
f76a0e6
Merge master into move_tests_folder
vlad-perevezentsev Nov 7, 2024
0e29f02
Merge master into move_tests_folder
vlad-perevezentsev Nov 7, 2024
9ea9d06
Remove warning filter for pkg_resources
vlad-perevezentsev Nov 7, 2024
8088098
Remove unused imports in test files
vlad-perevezentsev Nov 7, 2024
93566f1
Align import for test_arraypad.py
vlad-perevezentsev Nov 7, 2024
e03cd93
Use absolute import path in cupy/testing
vlad-perevezentsev Nov 7, 2024
f1a023b
Print dpnp version while testing conda package
vlad-perevezentsev Nov 7, 2024
cab2f48
Disable verbose and disable-warnings pytest mode for public CI
vlad-perevezentsev Nov 7, 2024
a1c54cc
Disable quiet, verbose, disable-warnings pytest mode for testing cond…
vlad-perevezentsev Nov 7, 2024
83687e6
Merge master into move_tests_folder
vlad-perevezentsev Nov 7, 2024
f5a6031
Merge master into move_tests_folder
vlad-perevezentsev Nov 13, 2024
5274a5e
Merge master into move_tests_folder
vlad-perevezentsev Nov 14, 2024
af3205d
Merge master into move_tests_folder
vlad-perevezentsev Nov 14, 2024
ce95578
Merge master into move_tests_folder
vlad-perevezentsev Nov 14, 2024
004202f
Remove dublicate env variable MODULE_NAME in conda-package.yaml
vlad-perevezentsev Nov 14, 2024
8d0e646
Remove working-directory usage for Run tests in conda-package.yml
vlad-perevezentsev Nov 14, 2024
38a1472
Merge master into move_tests_folder
vlad-perevezentsev Nov 14, 2024
4c90c59
Merge master into move_tests_folder
vlad-perevezentsev Nov 14, 2024
05bd7fa
Merge master into move_tests_folder
vlad-perevezentsev Nov 15, 2024
6a0c2be
Merge master into move_tests_folder
vlad-perevezentsev Nov 15, 2024
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
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ exclude =
build,
dpnp/to_numba/*.py,
conda.recipe,
tests/*.py,
dpnp/tests/*.py,
tests_external/*.py,
versioneer.py,

Expand Down
16 changes: 5 additions & 11 deletions .github/workflows/conda-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ permissions: read-all

env:
PACKAGE_NAME: dpnp
MODULE_NAME: dpnp
# Follow oneAPI installation instruction for conda, since intel channel is not longer available
# CHANNELS: '-c dppy/label/dev -c intel -c conda-forge --override-channels'
CHANNELS: '-c dppy/label/dev -c https://software.repos.intel.com/python/conda/ -c conda-forge --override-channels'
Expand Down Expand Up @@ -116,7 +115,6 @@ jobs:
channel-path: '${{ github.workspace }}/channel/'
pkg-path-in-channel: '${{ github.workspace }}/channel/linux-64/'
extracted-pkg-path: '${{ github.workspace }}/pkg/'
tests-path: '${{ github.workspace }}/pkg/info/test/tests/'
ver-json-path: '${{ github.workspace }}/version.json'

steps:
Expand Down Expand Up @@ -177,8 +175,7 @@ jobs:
- name: Run tests
if: env.RERUN_TESTS_ON_FAILURE != 'true'
run: |
python -m pytest -q -ra --disable-warnings -vv .
working-directory: ${{ env.tests-path }}
python -m pytest -ra --pyargs ${{ env.PACKAGE_NAME }}.tests

- name: Run tests
if: env.RERUN_TESTS_ON_FAILURE == 'true'
Expand All @@ -192,8 +189,7 @@ jobs:
command: |
. $CONDA/etc/profile.d/conda.sh
conda activate ${{ env.TEST_ENV_NAME }}
cd ${{ env.tests-path }}
python -m pytest -q -ra --disable-warnings -vv .
pytest -ra --pyargs ${{ env.PACKAGE_NAME }}.tests

test_windows:
name: Test ['windows-2019', python='${{ matrix.python }}']
Expand All @@ -216,8 +212,8 @@ jobs:
channel-path: '${{ github.workspace }}\channel\'
pkg-path-in-channel: '${{ github.workspace }}\channel\win-64\'
extracted-pkg-path: '${{ github.workspace }}\pkg'
tests-path: '${{ github.workspace }}\pkg\info\test\tests\'
ver-json-path: '${{ github.workspace }}\version.json'
workdir: '${{ github.workspace }}'

steps:
- name: Download artifact
Expand Down Expand Up @@ -314,8 +310,7 @@ jobs:
- name: Run tests
if: env.RERUN_TESTS_ON_FAILURE != 'true'
run: |
python -m pytest -q -ra --disable-warnings -vv .
working-directory: ${{ env.tests-path }}
pytest -ra --pyargs ${{ env.PACKAGE_NAME }}.tests

- name: Run tests
if: env.RERUN_TESTS_ON_FAILURE == 'true'
Expand All @@ -328,8 +323,7 @@ jobs:
retry_on: any
command: >-
mamba activate ${{ env.TEST_ENV_NAME }}
& cd ${{ env.tests-path }}
& python -m pytest -q -ra --disable-warnings -vv .
& pytest -ra --pyargs ${{ env.PACKAGE_NAME }}.tests

upload:
name: Upload ['${{ matrix.os }}', python='${{ matrix.python }}']
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ repos:
- id: python-no-eval
exclude: |
(?x)^(
tests/test_arraycreation.py|
tests/test_sycl_queue.py|
tests/test_usm_type.py
dpnp/tests/test_arraycreation.py|
dpnp/tests/test_sycl_queue.py|
dpnp/tests/test_usm_type.py
)$
- id: python-no-log-warn
- id: python-use-type-annotations
Expand Down
2 changes: 0 additions & 2 deletions MANIFEST.in

This file was deleted.

8 changes: 0 additions & 8 deletions conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,6 @@ test:
requires:
- pytest
- setuptools
source_files:
- examples
- tests
- setup.cfg
commands:
- python -c "import dpnp; print(dpnp.__version__)"
- python -m dpctl -f
- pytest -s

about:
home: https://github.com/IntelPython/dpnp
Expand Down
41 changes: 41 additions & 0 deletions conda-recipe/run_test.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
@echo on

REM if ONEAPI_ROOT is specified (use all from it)
if defined ONEAPI_ROOT (
set "DPCPPROOT=%ONEAPI_ROOT%\compiler\latest"
set "MKLROOT=%ONEAPI_ROOT%\mkl\latest"
set "TBBROOT=%ONEAPI_ROOT%\tbb\latest"
set "DPLROOT=%ONEAPI_ROOT%\dpl\latest"
)

REM if DPCPPROOT is specified (work with custom DPCPP)
if defined DPCPPROOT (
call "%DPCPPROOT%\env\vars.bat"
)

REM if MKLROOT is specified (work with custom math library)
if defined MKLROOT (
call "%MKLROOT%\env\vars.bat"
)

REM have to activate while SYCL CPU device/driver needs paths
REM if TBBROOT is specified
if defined TBBROOT (
call "%TBBROOT%\env\vars.bat"
)

REM If PYTHON is not set
REM assign it to the Python interpreter from the testing environment
if not defined PYTHON (
for %%I in (python.exe) do set PYTHON=%%~$PATH:I
)


"%PYTHON%" -c "import dpnp; print(dpnp.__version__)"
if errorlevel 1 exit 1

"%PYTHON%" -m dpctl -f
if errorlevel 1 exit 1

"%PYTHON%" -m pytest -ra --pyargs dpnp
if errorlevel 1 exit 1
12 changes: 12 additions & 0 deletions conda-recipe/run_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,15 @@ if [ -n "${TBBROOT}" ]; then
# shellcheck source=/dev/null
. "${TBBROOT}"/env/vars.sh
fi

# If PYTHON is not set
# assign it to the Python interpreter from the testing environment
if [ -z "${PYTHON}" ]; then
PYTHON=$PREFIX/bin/python
fi

set -e

$PYTHON -c "import dpnp; print(dpnp.__version__)"
$PYTHON -m dpctl -f
$PYTHON -m pytest -ra --pyargs dpnp
2 changes: 1 addition & 1 deletion tests/__init__.py → dpnp/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy

from tests import testing
from . import testing

numpy.testing.assert_allclose = testing.assert_allclose
numpy.testing.assert_array_equal = testing.assert_array_equal
Expand Down
76 changes: 70 additions & 6 deletions tests/conftest.py → dpnp/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,66 @@ def get_excluded_tests(test_exclude_file):
if os.path.exists(test_exclude_file):
with open(test_exclude_file) as skip_names_file:
excluded_tests = skip_names_file.readlines()
return excluded_tests
# Remove whitespace and filter out empty lines
return [line.strip() for line in excluded_tests if line.strip()]


# Normalize the nodeid to a relative path starting
# from the "tests/" directory
def normalize_test_name(nodeid):
nodeid = nodeid.replace("\n", "").strip()

# case if run pytest from dpnp folder
if nodeid.startswith("tests/"):
return nodeid

# case if run pytest --pyargs
if "/tests/" in nodeid:
nodeid = nodeid.split("tests/", 1)[-1]
# Add the "tests/" prefix to ensure the nodeid matches
# the paths in the skipped tests files.
normalized_nodeid = "tests/" + nodeid
# case if run pytest from tests folder
else:
normalized_nodeid = "tests/" + nodeid

return normalized_nodeid


def pytest_configure(config):
# By default, tests marked as slow will be deselected.
# To run all tests, use -m "slow or not slow".
# To run only slow tests, use -m "slow".
# Equivalent to addopts = -m "not slow"
if not config.getoption("markexpr"):
config.option.markexpr = "not slow"
# Equivalent to addopts = --tb=short
if not config.getoption("tbstyle"):
config.option.tbstyle = "short"
# Equivalent to addopts = --strict-markers
if not config.getoption("strict_markers"):
config.option.strict_markers = True

# Equivalent to norecursedirs = tests_perf
config.addinivalue_line("norecursedirs", "tests_perf")

# Register pytest markers
config.addinivalue_line(
"markers", "slow: marks tests as slow (deselect with '-m \"not slow\"')"
)
config.addinivalue_line(
"markers",
"multi_gpu: marks tests that require a specified number of GPUs",
)

# NumPy arccosh
# Undefined behavior depends on the backend:
# NumPy with OpenBLAS for np.array[1.0] does not raise a warning
# while numpy with OneMKL raises RuntimeWarning
config.addinivalue_line(
"filterwarnings",
"ignore:invalid value encountered in arccosh:RuntimeWarning",
)


def pytest_collection_modifyitems(config, items):
Expand Down Expand Up @@ -85,16 +144,21 @@ def pytest_collection_modifyitems(config, items):
excluded_tests.extend(get_excluded_tests(test_exclude_file))

for item in items:
# some test name contains '\n' in the parameters
test_name = item.nodeid.replace("\n", "").strip()
test_name = normalize_test_name(item.nodeid)

for item_tbl in excluded_tests:
# remove end-of-line character
item_tbl_str = item_tbl.strip()
# exact match of the test name with items from excluded_list
if test_name == item_tbl_str:
if test_name == item_tbl:
item.add_marker(skip_mark)

# Handle the exclusion of tests marked as "slow"
selected_marker = config.getoption("markexpr")
if "not slow" in selected_marker:
skip_slow = pytest.mark.skip(reason="Skipping slow tests")
for item in items:
if "slow" in item.keywords:
item.add_marker(skip_slow)


@pytest.fixture
def allow_fall_back_on_numpy(monkeypatch):
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import unittest

import numpy

from tests.helper import has_support_aspect64
from tests.third_party.cupy import testing
from .third_party.cupy import testing


class TestArithmetic(unittest.TestCase):
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@
)

import dpnp
from tests.third_party.cupy import testing

from .helper import (
assert_dtype_allclose,
get_all_dtypes,
has_support_aspect64,
)
from .third_party.cupy import testing


class TestArray:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
)

import dpnp
from tests.third_party.cupy import testing

from .helper import get_all_dtypes, get_float_complex_dtypes
from .third_party.cupy import testing


class TestAtleast1d:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_arraypad.py → dpnp/tests/test_arraypad.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

import dpnp
from dpnp.dpnp_utils.dpnp_utils_pad import _as_pairs as dpnp_as_pairs
from tests.third_party.cupy import testing

from .helper import assert_dtype_allclose, get_all_dtypes
from .third_party.cupy import testing


class TestPad:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion tests/test_fft.py → dpnp/tests/test_fft.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
assert_dtype_allclose,
get_all_dtypes,
get_complex_dtypes,
get_float_complex_dtypes,
get_float_dtypes,
)

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy
import pytest
from numpy.testing import assert_array_equal, assert_equal, assert_raises
from numpy.testing import assert_array_equal

import dpnp

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/test_indexing.py → dpnp/tests/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

import dpnp
from dpnp.dpnp_array import dpnp_array
from tests.third_party.cupy import testing

from .helper import get_all_dtypes, get_integer_dtypes, has_support_aspect64
from .third_party.cupy import testing


def _add_keepdims(func):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_linalg.py → dpnp/tests/test_linalg.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
)

import dpnp as inp
from tests.third_party.cupy import testing

from .helper import (
assert_dtype_allclose,
Expand All @@ -25,6 +24,7 @@
has_support_aspect64,
is_cpu_device,
)
from .third_party.cupy import testing


def vvsort(val, vec, size, xp):
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from numpy.testing import assert_array_equal, assert_equal, assert_raises

import dpnp
from tests.third_party.cupy import testing

from .helper import (
assert_dtype_allclose,
Expand All @@ -18,6 +17,7 @@
get_integer_dtypes,
has_support_aspect64,
)
from .third_party.cupy import testing

testdata = []
testdata += [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import dpnp
from dpnp.dpnp_array import dpnp_array
from tests.third_party.cupy import testing

from .helper import (
assert_dtype_allclose,
Expand All @@ -36,6 +35,7 @@
_get_numpy_arrays_2in_1out,
_get_output_data_type,
)
from .third_party.cupy import testing


class TestAngle:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_mixins.py → dpnp/tests/test_mixins.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import unittest

from tests.third_party.cupy import testing
from .third_party.cupy import testing


class TestMatMul(unittest.TestCase):
Expand Down
Loading
Loading