Skip to content

Commit 19ec9db

Browse files
committed
update puclic CI workflow and newly added tests
1 parent 6592abc commit 19ec9db

File tree

4 files changed

+73
-236
lines changed

4 files changed

+73
-236
lines changed

.github/workflows/conda-package.yml

Lines changed: 41 additions & 224 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'
@@ -209,12 +210,19 @@ jobs:
209210
python -c "import dpnp; print(dpnp.__version__)"
210211
211212
- name: Run tests
212-
if: env.RERUN_TESTS_ON_FAILURE != 'true'
213+
if: ${{ env.RERUN_TESTS_ON_FAILURE != 'true' && matrix.python != env.LATEST_PYTHON }}
213214
run: |
214215
python -m pytest -n auto -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
215216
217+
- name: Run tests for all dtypes
218+
if: ${{ env.RERUN_TESTS_ON_FAILURE != 'true' && matrix.python == env.LATEST_PYTHON }}
219+
env:
220+
DPNP_TEST_ALL_INT_TYPES: 1
221+
run: |
222+
python -m pytest -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
223+
216224
- name: Run tests
217-
if: env.RERUN_TESTS_ON_FAILURE == 'true'
225+
if: env.RERUN_TESTS_ON_FAILURE == 'true' && matrix.python != env.LATEST_PYTHON
218226
id: run_tests_linux
219227
uses: nick-fields/retry@7152eba30c6575329ac0576536151aca5a72780e # v3.0.0
220228
with:
@@ -228,110 +236,22 @@ jobs:
228236
229237
python -m pytest -n auto -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
230238
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-
330239
- name: Run tests for all dtypes
240+
if: env.RERUN_TESTS_ON_FAILURE == 'true' && matrix.python == env.LATEST_PYTHON
241+
id: run_tests_linux_all_dtypes
242+
uses: nick-fields/retry@7152eba30c6575329ac0576536151aca5a72780e # v3.0.0
331243
env:
332244
DPNP_TEST_ALL_INT_TYPES: 1
333-
run: |
334-
python -m pytest -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
245+
with:
246+
timeout_minutes: 20
247+
max_attempts: ${{ env.RUN_TESTS_MAX_ATTEMPTS }}
248+
retry_on: any
249+
command: |
250+
. $CONDA/etc/profile.d/conda.sh
251+
. $CONDA/etc/profile.d/mamba.sh
252+
mamba activate ${{ env.TEST_ENV_NAME }}
253+
254+
python -m pytest -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
335255
336256
test_windows:
337257
name: Test
@@ -451,12 +371,19 @@ jobs:
451371
python -c "import dpnp; print(dpnp.__version__)"
452372
453373
- name: Run tests
454-
if: env.RERUN_TESTS_ON_FAILURE != 'true'
374+
if: ${{ env.RERUN_TESTS_ON_FAILURE != 'true' && matrix.python != env.LATEST_PYTHON }}
455375
run: |
456376
python -m pytest -n auto -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
457377
378+
- name: Run tests for all dtypes
379+
if: ${{ env.RERUN_TESTS_ON_FAILURE != 'true' && matrix.python == env.LATEST_PYTHON }}
380+
env:
381+
DPNP_TEST_ALL_INT_TYPES: 1
382+
run: |
383+
python -m pytest -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
384+
458385
- name: Run tests
459-
if: env.RERUN_TESTS_ON_FAILURE == 'true'
386+
if: env.RERUN_TESTS_ON_FAILURE == 'true' && matrix.python != env.LATEST_PYTHON
460387
id: run_tests_win
461388
uses: nick-fields/retry@7152eba30c6575329ac0576536151aca5a72780e # v3.0.0
462389
with:
@@ -466,128 +393,18 @@ jobs:
466393
command: |
467394
python -m pytest -n auto -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
468395
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-
586396
- name: Run tests for all dtypes
397+
if: env.RERUN_TESTS_ON_FAILURE == 'true' && matrix.python == env.LATEST_PYTHON
398+
id: run_tests_win_all_dtypes
399+
uses: nick-fields/retry@7152eba30c6575329ac0576536151aca5a72780e # v3.0.0
587400
env:
588401
DPNP_TEST_ALL_INT_TYPES: 1
589-
run: |
590-
python -m pytest -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
402+
with:
403+
timeout_minutes: 30
404+
max_attempts: ${{ env.RUN_TESTS_MAX_ATTEMPTS }}
405+
retry_on: any
406+
command: |
407+
python -m pytest -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
591408
592409
upload:
593410
name: Upload

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)

0 commit comments

Comments
 (0)