Skip to content

Commit

Permalink
Merge pull request #88 from IntelPython/fixes-for-np-1.25
Browse files Browse the repository at this point in the history
Adapt to NumPy 1.25
  • Loading branch information
oleksandr-pavlyk authored Sep 2, 2023
2 parents 7110797 + fc2a036 commit 3ccabb6
Show file tree
Hide file tree
Showing 8 changed files with 154 additions and 21 deletions.
144 changes: 139 additions & 5 deletions .github/workflows/conda-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ env:

jobs:
build:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
strategy:
matrix:
python: [3.9]
python: ['3.10']
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -38,7 +38,7 @@ jobs:
run: conda install conda-build
- name: Build conda package
run: |
CHANNELS="-c intel -c main --override-channels"
CHANNELS="-c conda-forge -c intel --override-channels"
VERSIONS="--python ${{ matrix.python }}"
TEST="--no-test"
Expand All @@ -59,9 +59,9 @@ jobs:

strategy:
matrix:
python: [3.9]
python: ['3.10']
experimental: [false]
runner: [ubuntu-20.04]
runner: [ubuntu-latest]
continue-on-error: ${{ matrix.experimental }}
env:
CHANNELS: -c intel -c main --override-channels
Expand Down Expand Up @@ -115,3 +115,137 @@ jobs:
source $CONDA/etc/profile.d/conda.sh
conda activate test_mkl_fft
pytest -v --pyargs $MODULE_NAME
build_windows:
runs-on: windows-latest

strategy:
matrix:
python: ['3.10']
env:
conda-bld: C:\Miniconda\conda-bld\win-64\
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: conda-incubator/setup-miniconda@v2
with:
auto-activate-base: true
conda-build-version: "*"
activate-environment: true
python-version: ${{ matrix.python }}

- name: Cache conda packages
uses: actions/cache@v3
env:
CACHE_NUMBER: 3 # Increase to reset cache
with:
path: /home/runner/conda_pkgs_dir
key:
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-${{hashFiles('**/meta.yaml') }}
restore-keys: |
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-
- name: Build conda package
run: conda build --no-test --python ${{ matrix.python }} -c intel -c conda-forge --override-channels conda-recipe
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
path: ${{ env.conda-bld }}${{ env.PACKAGE_NAME }}-*.tar.bz2

test_windows:
needs: build_windows
runs-on: ${{ matrix.runner }}
defaults:
run:
shell: cmd /C CALL {0}
strategy:
matrix:
python: ['3.10']
experimental: [false]
runner: [windows-latest]
continue-on-error: ${{ matrix.experimental }}
env:
workdir: '${{ github.workspace }}'
CHANNELS: -c intel -c conda-forge --override-channels

steps:
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
- uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
conda-build-version: '*'
miniconda-version: 'latest'
activate-environment: mkl_fft_test
python-version: ${{ matrix.python }}
- name: Create conda channel with the artifact bit
shell: cmd /C CALL {0}
run: |
echo ${{ env.workdir }}
mkdir ${{ env.workdir }}\channel\win-64
move ${{ env.PACKAGE_NAME }}-*.tar.bz2 ${{ env.workdir }}\channel\win-64
dir ${{ env.workdir }}\channel\win-64
- name: Index the channel
shell: cmd /C CALL {0}
run: conda index ${{ env.workdir }}\channel

- name: Dump mkl_fft version info from created channel into ver.json
shell: cmd /C CALL {0}
run: |
conda search ${{ env.PACKAGE_NAME }} -c ${{ env.workdir }}/channel --override-channels --info --json > ${{ env.workdir }}\ver.json
- name: Output content of produced ver.json
shell: pwsh
run: Get-Content -Path ${{ env.workdir }}\ver.json
- name: Collect dependencies
shell: cmd /C CALL {0}
run: |
IF NOT EXIST ver.json (
copy /Y ${{ env.workdir }}\ver.json .
)
SET "SCRIPT=%VER_SCRIPT1% %VER_SCRIPT2%"
FOR /F "tokens=* USEBACKQ" %%F IN (`python -c "%SCRIPT%"`) DO (
SET PACKAGE_VERSION=%%F
)
conda install -n mkl_fft_test ${{ env.PACKAGE_NAME }}=%PACKAGE_VERSION% python=${{ matrix.python }} -c ${{ env.workdir }}/channel ${{ env.CHANNELS }} --only-deps --dry-run > lockfile
- name: Display lockfile content
shell: pwsh
run: Get-Content -Path .\lockfile
- name: Cache conda packages
uses: actions/cache@v3
env:
CACHE_NUMBER: 0 # Increase to reset cache
with:
path: /home/runner/conda_pkgs_dir
key:
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-${{hashFiles('lockfile') }}
restore-keys: |
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-
- name: Install mkl_fft
shell: cmd /C CALL {0}
run: |
@ECHO ON
IF NOT EXIST ver.json (
copy /Y ${{ env.workdir }}\ver.json .
)
set "SCRIPT=%VER_SCRIPT1% %VER_SCRIPT2%"
FOR /F "tokens=* USEBACKQ" %%F IN (`python -c "%SCRIPT%"`) DO (
SET PACKAGE_VERSION=%%F
)
SET "TEST_DEPENDENCIES=pytest pytest-cov"
conda install -n mkl_fft_test ${{ env.PACKAGE_NAME }}=%PACKAGE_VERSION% %TEST_DEPENDENCIES% python=${{ matrix.python }} -c ${{ env.workdir }}/channel ${{ env.CHANNELS }}
- name: Report content of test environment
shell: cmd /C CALL {0}
run: |
echo "Value of CONDA enviroment variable was: " %CONDA%
echo "Value of CONDA_PREFIX enviroment variable was: " %CONDA_PREFIX%
conda info && conda list -n mkl_fft_test
- name: Run tests
shell: cmd /C CALL {0}
run: >-
conda activate mkl_fft_test && python -m pytest -v -s --pyargs ${{ env.MODULE_NAME }}
4 changes: 1 addition & 3 deletions conda-recipe/bld.bat
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@rem Remember to activate Intel Compiler, or remoe these two lines to ise Microsoft Visual Studio compiler

set MKLROOT=%PREFIX%
%PYTHON% setup.py build --force install --old-and-unmanageable
%PYTHON% -m pip install --no-build-isolation --no-deps .
if errorlevel 1 exit 1
7 changes: 4 additions & 3 deletions conda-recipe/build.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#!/bin/bash -x

# make sure that compiler has been sourced, if necessary

if [ `uname` == Darwin ]; then
export MACOSX_DEPLOYMENT_TARGET=10.9
fi

MKLROOT=$PREFIX CFLAGS="-I$PREFIX/include $CFLAGS" $PYTHON setup.py build --force install --old-and-unmanageable
export MKLROOT=$PREFIX
export CFLAGS="-I$PREFIX/include $CFLAGS"
$PYTHON -m pip install --no-build-isolation --no-deps .

2 changes: 1 addition & 1 deletion conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% set version = "1.3.6" %}
{% set version = "1.3.7" %}
{% set buildnumber = 0 %}

package:
Expand Down
6 changes: 4 additions & 2 deletions mkl_fft/_pydfti.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#cython: language_level=3

# imports
import sys
import numpy as np
from numpy.core._multiarray_tests import internal_overlap
from threading import local as threading_local
Expand All @@ -48,13 +49,14 @@ cdef void _capsule_destructor(object caps) noexcept:
cdef DftiCache *_cache = NULL
cdef int status = 0
if (caps is None):
print("Nothing to destroy")
print("CapsuleDestructorInternalError: Nothing to destroy", file=sys.stderr)
return
_cache = <DftiCache *>cpython.pycapsule.PyCapsule_GetPointer(caps, capsule_name)
status = _free_dfti_cache(_cache)
PyMem_Free(_cache)
if (status != 0):
raise ValueError("Internal Error: Freeing DFTI Cache returned with error = {}".format(status))
print("CapsuleDestructorInternalError: Freeing DFTI Cache "
f"returned with error code = '{status}'", file=sys.stderr)


def _tls_dfti_cache_capsule():
Expand Down
2 changes: 1 addition & 1 deletion mkl_fft/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.3.6'
__version__ = '1.3.7'
6 changes: 2 additions & 4 deletions mkl_fft/tests/test_fft1d.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python
# Copyright (c) 2017-2019, Intel Corporation
# Copyright (c) 2017-2023, Intel Corporation
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
Expand All @@ -26,7 +26,7 @@

import numpy as np
from numpy.testing import (
TestCase, run_module_suite, assert_, assert_raises, assert_equal,
TestCase, assert_, assert_raises, assert_equal,
assert_warns, assert_allclose)
from numpy import random as rnd
import sys
Expand Down Expand Up @@ -387,5 +387,3 @@ def test5(self):
f2 = mkl_fft.rfft(f1, axis=a, overwrite_x=ovwr_x)
assert_allclose(f2, self.t3.astype(dt), atol=atol)

if __name__ == "__main__":
run_module_suite(argv = sys.argv)
4 changes: 2 additions & 2 deletions mkl_fft/tests/test_fftnd.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python
# Copyright (c) 2017-2019, Intel Corporation
# Copyright (c) 2017-2023, Intel Corporation
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
Expand All @@ -26,7 +26,7 @@

import numpy as np
from numpy.testing import (
TestCase, run_module_suite, assert_, assert_raises, assert_equal,
TestCase, assert_, assert_raises, assert_equal,
assert_warns, assert_allclose)
from numpy import random as rnd
import sys
Expand Down

0 comments on commit 3ccabb6

Please sign in to comment.