Skip to content

Commit e01c969

Browse files
authored
update puclic CI workflow for all integer dtypes (#2298)
In this PR, the GitHub workflow is update to run the test suit with all integer dtypes when the lates python is used. In addition, newly added tests are updated to pass with all integer dtypes.
1 parent 6592abc commit e01c969

File tree

6 files changed

+63
-250
lines changed

6 files changed

+63
-250
lines changed

.github/workflows/conda-package.yml

Lines changed: 27 additions & 234 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ env:
1616
CONDA_BUILD_INDEX_ENV_PY_VER: '3.12' # conda does not support python 3.13
1717
CONDA_BUILD_VERSION: '25.1.1'
1818
CONDA_INDEX_VERSION: '0.5.0'
19+
LATEST_PYTHON: '3.13'
1920
RERUN_TESTS_ON_FAILURE: 'true'
2021
RUN_TESTS_MAX_ATTEMPTS: 2
2122
TEST_ENV_NAME: 'test'
@@ -211,127 +212,32 @@ jobs:
211212
- name: Run tests
212213
if: env.RERUN_TESTS_ON_FAILURE != 'true'
213214
run: |
214-
python -m pytest -n auto -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
215+
if [[ ${{ matrix.python }} == ${{ env.LATEST_PYTHON }} ]]; then
216+
export DPNP_TEST_ALL_INT_TYPES=1
217+
python -m pytest -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
218+
else
219+
python -m pytest -n auto -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
220+
fi
215221
216222
- name: Run tests
217223
if: env.RERUN_TESTS_ON_FAILURE == 'true'
218224
id: run_tests_linux
219225
uses: nick-fields/retry@7152eba30c6575329ac0576536151aca5a72780e # v3.0.0
220226
with:
221-
timeout_minutes: 15
227+
timeout_minutes: 25
222228
max_attempts: ${{ env.RUN_TESTS_MAX_ATTEMPTS }}
223229
retry_on: any
224230
command: |
225231
. $CONDA/etc/profile.d/conda.sh
226232
. $CONDA/etc/profile.d/mamba.sh
227233
mamba activate ${{ env.TEST_ENV_NAME }}
228234
229-
python -m pytest -n auto -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
230-
231-
test_linux_all_dtypes:
232-
name: Test_All_dtypes
233-
234-
needs: build
235-
236-
runs-on: ${{ matrix.os }}
237-
238-
defaults:
239-
run:
240-
shell: bash -el {0}
241-
242-
strategy:
243-
fail-fast: false
244-
matrix:
245-
python: ['3.12']
246-
os: [ubuntu-latest]
247-
248-
env:
249-
channel-path: '${{ github.workspace }}/channel/'
250-
pkg-path-in-channel: '${{ github.workspace }}/channel/linux-64/'
251-
ver-json-path: '${{ github.workspace }}/version.json'
252-
253-
steps:
254-
- name: Download artifact
255-
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
256-
with:
257-
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
258-
path: ${{ env.pkg-path-in-channel }}
259-
260-
- name: Setup miniconda
261-
id: setup_miniconda
262-
continue-on-error: true
263-
uses: conda-incubator/setup-miniconda@505e6394dae86d6a5c7fbb6e3fb8938e3e863830 # v3.1.1
264-
with:
265-
miniforge-version: latest
266-
use-mamba: 'true'
267-
channels: conda-forge
268-
conda-remove-defaults: 'true'
269-
python-version: ${{ env.CONDA_BUILD_INDEX_ENV_PY_VER}}
270-
activate-environment: ${{ env.TEST_ENV_NAME }}
271-
272-
- name: ReSetup miniconda
273-
if: steps.setup_miniconda.outcome == 'failure'
274-
uses: conda-incubator/setup-miniconda@505e6394dae86d6a5c7fbb6e3fb8938e3e863830 # v3.1.1
275-
with:
276-
miniforge-version: latest
277-
use-mamba: 'true'
278-
channels: conda-forge
279-
conda-remove-defaults: 'true'
280-
python-version: ${{ env.CONDA_BUILD_INDEX_ENV_PY_VER}}
281-
activate-environment: ${{ env.TEST_ENV_NAME }}
282-
283-
- name: Install conda-index
284-
run: |
285-
mamba install conda-index=${{ env.CONDA_INDEX_VERSION }}
286-
287-
- name: Create conda channel
288-
run: |
289-
python -m conda_index ${{ env.channel-path }}
290-
291-
- name: Test conda channel
292-
run: |
293-
conda search ${{ env.PACKAGE_NAME }} -c ${{ env.channel-path }} --override-channels --info --json > ${{ env.ver-json-path }}
294-
cat ${{ env.ver-json-path }}
295-
296-
- name: Get package version
297-
run: |
298-
export PACKAGE_VERSION=$(python -c "${{ env.VER_SCRIPT1 }} ${{ env.VER_SCRIPT2 }}")
299-
300-
echo PACKAGE_VERSION=${PACKAGE_VERSION}
301-
echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV
302-
303-
# conda-index does not support python 3.13
304-
- name: Remove conda-index
305-
run: mamba remove conda-index
306-
307-
- name: Install dpnp
308-
id: install_dpnp
309-
continue-on-error: true
310-
run: |
311-
mamba install ${{ env.PACKAGE_NAME }}=${{ env.PACKAGE_VERSION }} pytest python=${{ matrix.python }} ${{ env.TEST_CHANNELS }}
312-
env:
313-
TEST_CHANNELS: '-c ${{ env.channel-path }} ${{ env.CHANNELS }}'
314-
315-
- name: ReInstall dpnp
316-
if: steps.install_dpnp.outcome == 'failure'
317-
run: |
318-
mamba install ${{ env.PACKAGE_NAME }}=${{ env.PACKAGE_VERSION }} pytest python=${{ matrix.python }} ${{ env.TEST_CHANNELS }}
319-
env:
320-
TEST_CHANNELS: '-c ${{ env.channel-path }} ${{ env.CHANNELS }}'
321-
322-
- name: List installed packages
323-
run: mamba list
324-
325-
- name: Smoke test
326-
run: |
327-
python -c "import dpctl; dpctl.lsplatform()"
328-
python -c "import dpnp; print(dpnp.__version__)"
329-
330-
- name: Run tests for all dtypes
331-
env:
332-
DPNP_TEST_ALL_INT_TYPES: 1
333-
run: |
334-
python -m pytest -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
235+
if [[ ${{ matrix.python }} == ${{ env.LATEST_PYTHON }} ]]; then
236+
export DPNP_TEST_ALL_INT_TYPES=1
237+
python -m pytest -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
238+
else
239+
python -m pytest -n auto -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
240+
fi
335241
336242
test_windows:
337243
name: Test
@@ -453,141 +359,28 @@ jobs:
453359
- name: Run tests
454360
if: env.RERUN_TESTS_ON_FAILURE != 'true'
455361
run: |
456-
python -m pytest -n auto -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
362+
if (${{ matrix.python }} -eq ${{ env.LATEST_PYTHON }}) {
363+
set DPNP_TEST_ALL_INT_TYPES=1
364+
python -m pytest -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
365+
} else {
366+
python -m pytest -n auto -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
367+
}
457368
458369
- name: Run tests
459370
if: env.RERUN_TESTS_ON_FAILURE == 'true'
460371
id: run_tests_win
461372
uses: nick-fields/retry@7152eba30c6575329ac0576536151aca5a72780e # v3.0.0
462373
with:
463-
timeout_minutes: 17
374+
timeout_minutes: 35
464375
max_attempts: ${{ env.RUN_TESTS_MAX_ATTEMPTS }}
465376
retry_on: any
466377
command: |
467-
python -m pytest -n auto -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
468-
469-
test_windows_all_dtypes:
470-
name: Test_All_dtypes
471-
472-
needs: build
473-
474-
runs-on: ${{ matrix.os }}
475-
476-
defaults:
477-
run:
478-
shell: cmd /C CALL {0}
479-
480-
strategy:
481-
fail-fast: false
482-
matrix:
483-
python: ['3.12']
484-
os: [windows-2019]
485-
486-
env:
487-
channel-path: '${{ github.workspace }}\channel\'
488-
pkg-path-in-channel: '${{ github.workspace }}\channel\win-64\'
489-
ver-json-path: '${{ github.workspace }}\version.json'
490-
workdir: '${{ github.workspace }}'
491-
492-
steps:
493-
- name: Download artifact
494-
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
495-
with:
496-
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
497-
path: ${{ env.pkg-path-in-channel }}
498-
499-
- name: Store a path to package archive
500-
run: |
501-
@echo on
502-
503-
set SEARCH_SCRIPT="DIR ${{ env.pkg-path-in-channel }} /s/b | FINDSTR /r "dpnp-.*\.conda""
504-
FOR /F "tokens=* USEBACKQ" %%F IN (`%SEARCH_SCRIPT%`) DO (
505-
SET FULL_PACKAGE_PATH=%%F
506-
)
507-
echo FULL_PACKAGE_PATH: %FULL_PACKAGE_PATH%
508-
(echo FULL_PACKAGE_PATH=%FULL_PACKAGE_PATH%) >> %GITHUB_ENV%
509-
510-
- name: Setup miniconda
511-
uses: conda-incubator/setup-miniconda@505e6394dae86d6a5c7fbb6e3fb8938e3e863830 # v3.1.1
512-
with:
513-
miniforge-version: latest
514-
use-mamba: 'true'
515-
channels: conda-forge
516-
conda-remove-defaults: 'true'
517-
python-version: ${{ env.CONDA_BUILD_INDEX_ENV_PY_VER}}
518-
activate-environment: ${{ env.TEST_ENV_NAME }}
519-
520-
- name: Store conda paths as envs
521-
run: |
522-
@echo on
523-
(echo CONDA_LIB_PATH=%CONDA_PREFIX%\Library\lib\) >> %GITHUB_ENV%
524-
(echo CONDA_LIB_BIN_PATH=%CONDA_PREFIX%\Library\bin\) >> %GITHUB_ENV%
525-
526-
- name: Install conda-index
527-
run: |
528-
mamba install conda-index=${{ env.CONDA_INDEX_VERSION }}
529-
530-
- name: Create conda channel
531-
run: |
532-
@echo on
533-
python -m conda_index ${{ env.channel-path }}
534-
535-
- name: Test conda channel
536-
run: |
537-
@echo on
538-
conda search ${{ env.PACKAGE_NAME }} -c ${{ env.channel-path }} --override-channels --info --json > ${{ env.ver-json-path }}
539-
540-
- name: Dump version.json
541-
run: more ${{ env.ver-json-path }}
542-
543-
- name: Get package version
544-
run: |
545-
@echo on
546-
set "SCRIPT=${{ env.VER_SCRIPT1 }} ${{ env.VER_SCRIPT2 }}"
547-
FOR /F "tokens=* USEBACKQ" %%F IN (`python -c "%SCRIPT%"`) DO (
548-
set PACKAGE_VERSION=%%F
549-
)
550-
echo PACKAGE_VERSION: %PACKAGE_VERSION%
551-
(echo PACKAGE_VERSION=%PACKAGE_VERSION%) >> %GITHUB_ENV%
552-
553-
# conda-index does not support python 3.13
554-
- name: Remove conda-index
555-
run: mamba remove conda-index
556-
557-
- name: Install dpnp
558-
run: |
559-
@echo on
560-
mamba install ${{ env.PACKAGE_NAME }}=${{ env.PACKAGE_VERSION }} pytest python=${{ matrix.python }} ${{ env.TEST_CHANNELS }}
561-
env:
562-
TEST_CHANNELS: '-c ${{ env.channel-path }} ${{ env.CHANNELS }}'
563-
MAMBA_NO_LOW_SPEED_LIMIT: 1
564-
565-
- name: List installed packages
566-
run: mamba list
567-
568-
- name: Activate OCL CPU RT
569-
shell: pwsh
570-
run: |
571-
$script_path="$env:CONDA_PREFIX\Scripts\set-intel-ocl-icd-registry.ps1"
572-
if (Test-Path $script_path) {
573-
&$script_path
574-
} else {
575-
Write-Warning "File $script_path was NOT found!"
576-
}
577-
# Check the variable assisting OpenCL CPU driver to find TBB DLLs which are not located where it expects them by default
578-
$cl_cfg="$env:CONDA_PREFIX\Library\lib\cl.cfg"
579-
Get-Content -Tail 5 -Path $cl_cfg
580-
581-
- name: Smoke test
582-
run: |
583-
python -c "import dpctl; dpctl.lsplatform()"
584-
python -c "import dpnp; print(dpnp.__version__)"
585-
586-
- name: Run tests for all dtypes
587-
env:
588-
DPNP_TEST_ALL_INT_TYPES: 1
589-
run: |
590-
python -m pytest -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
378+
if ( ${{ matrix.python }} -eq ${{ env.LATEST_PYTHON }} ) {
379+
set DPNP_TEST_ALL_INT_TYPES=1
380+
python -m pytest -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
381+
} else {
382+
python -m pytest -n auto -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
383+
}
591384
592385
upload:
593386
name: Upload

dpnp/dpnp_utils/dpnp_utils_linearalgebra.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -509,8 +509,8 @@ def _gemm_special_case(x1, x2, res_dtype, call_flag):
509509
while `gemv` does not.
510510
511511
"""
512-
# TODO: replace with dpnp.int8 when it is added
513-
is_int8 = x1.dtype == numpy.int8 and x2.dtype == numpy.int8
512+
513+
is_int8 = x1.dtype == dpnp.int8 and x2.dtype == dpnp.int8
514514
is_int32_or_f32 = res_dtype in [dpnp.int32, dpnp.float32]
515515
flag = is_int8 and is_int32_or_f32 and call_flag in ["gemm", "gemm_batch"]
516516

dpnp/tests/test_indexing.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ def test_input_1d(self, a_dt, indices, ind_dt, ivals, mode):
473473
b.put(ind, vals, mode=mode)
474474
ib.put(iind, ivals, mode=mode)
475475
assert_array_equal(ib, b)
476-
elif numpy.issubdtype(ind_dt, numpy.uint64):
476+
elif ind_dt == numpy.uint64:
477477
# For this special case, NumPy raises an error but dpnp works
478478
assert_raises(TypeError, numpy.put, a, ind, vals, mode=mode)
479479
assert_raises(TypeError, b.put, ind, vals, mode=mode)
@@ -508,7 +508,7 @@ def test_input_2d(self, a_dt, indices, ind_dt, mode):
508508
ind = get_abs_array(indices, ind_dt)
509509
iind = dpnp.array(ind)
510510

511-
if numpy.issubdtype(ind_dt, numpy.uint64):
511+
if ind_dt == numpy.uint64:
512512
# For this special case, NumPy raises an error but dpnp works
513513
assert_raises(TypeError, numpy.put, a, ind, vals, mode=mode)
514514

@@ -656,7 +656,7 @@ def test_broadcast(self, arr_dt, idx_dt):
656656
ind = numpy.arange(10, dtype=idx_dt).reshape((1, 2, 5)) % 4
657657
ia, iind = dpnp.array(a), dpnp.array(ind)
658658

659-
if numpy.issubdtype(idx_dt, numpy.uint64):
659+
if idx_dt == numpy.uint64:
660660
numpy.put_along_axis(a, ind, 20, axis=1)
661661
dpnp.put_along_axis(ia, iind, 20, axis=1)
662662
assert_array_equal(ia, a)
@@ -701,7 +701,7 @@ def test_1d(self, a_dt, ind_dt, indices, mode):
701701
result = dpnp.take(ia, iind, mode=mode)
702702
expected = numpy.take(a, ind, mode=mode)
703703
assert_array_equal(result, expected)
704-
elif numpy.issubdtype(ind_dt, numpy.uint64):
704+
elif ind_dt == numpy.uint64:
705705
# For this special case, although casting `ind_dt` to numpy.intp
706706
# is not safe, both NumPy and dpnp work properly
707707
# NumPy < "2.2.0" raises an error
@@ -726,7 +726,7 @@ def test_2d(self, a_dt, ind_dt, indices, mode, axis):
726726
ind = get_abs_array(indices, ind_dt)
727727
ia, iind = dpnp.array(a), dpnp.array(ind)
728728

729-
if numpy.issubdtype(ind_dt, numpy.uint64):
729+
if ind_dt == numpy.uint64:
730730
# For this special case, NumPy raises an error on Windows
731731
result = ia.take(iind, axis=axis, mode=mode)
732732
expected = a.take(ind.astype(numpy.int64), axis=axis, mode=mode)
@@ -1461,6 +1461,16 @@ def test_choose_inds_all_dtypes(self, dtype):
14611461
chcs = dpnp.ones(1, dtype=dtype)
14621462
with pytest.raises(TypeError):
14631463
dpnp.choose(inds, chcs)
1464+
elif dtype == numpy.uint64:
1465+
# For this special case, NumPy raises an error but dpnp works
1466+
inds_np = numpy.array([1, 0, 1], dtype=dtype)
1467+
inds = dpnp.array(inds_np)
1468+
chcs_np = numpy.array([1, 2, 3], dtype=dtype)
1469+
chcs = dpnp.array(chcs_np)
1470+
assert_raises(TypeError, numpy.choose, inds_np, chcs_np)
1471+
expected = numpy.choose(inds_np.astype(numpy.int64), chcs_np)
1472+
result = dpnp.choose(inds, chcs)
1473+
assert_array_equal(expected, result)
14641474
else:
14651475
inds_np = numpy.array([1, 0, 1], dtype=dtype)
14661476
inds = dpnp.array(inds_np)

dpnp/tests/test_linalg.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2401,10 +2401,10 @@ def test_qr(self, dtype, shape, mode):
24012401
decimal=5,
24022402
)
24032403
else: # mode=="raw"
2404-
assert_dtype_allclose(dpnp_q, np_q)
2404+
assert_dtype_allclose(dpnp_q, np_q, factor=24)
24052405

24062406
if mode in ("raw", "r"):
2407-
assert_dtype_allclose(dpnp_r, np_r)
2407+
assert_dtype_allclose(dpnp_r, np_r, factor=24)
24082408

24092409
@pytest.mark.parametrize("dtype", get_all_dtypes(no_bool=True))
24102410
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)