Skip to content

Commit

Permalink
CI: Test NumPy against OpenBLAS weekly builds (#24250)
Browse files Browse the repository at this point in the history
[skip ci]
  • Loading branch information
honno committed Jul 31, 2023
1 parent 9f069ae commit d99dd6d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 8 deletions.
17 changes: 16 additions & 1 deletion .github/workflows/linux_meson.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ jobs:
meson_spin:
if: "github.repository == 'numpy/numpy'"
runs-on: ubuntu-latest
strategy:
matrix:
USE_NIGHTLY_OPENBLAS: [false, true]
env:
USE_NIGHTLY_OPENBLAS: ${{ matrix.USE_NIGHTLY_OPENBLAS }}
name: "Test Linux (${{ matrix.USE_NIGHTLY_OPENBLAS && 'nightly' || 'stable' }} OpenBLAS)"
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
with:
Expand All @@ -35,7 +41,15 @@ jobs:
- name: Install dependencies
run: |
pip install -r build_requirements.txt
sudo apt-get install -y libopenblas-serial-dev
# Install OpenBLAS
set -xe
if [[ $USE_NIGHTLY_OPENBLAS == "true" ]]; then
target=$(python tools/openblas_support.py --nightly)
else
target=$(python tools/openblas_support.py)
fi
sudo cp -r $target/lib/* /usr/lib
sudo cp $target/include/* /usr/include
- name: Build
shell: 'script -q -e -c "bash --noprofile --norc -eo pipefail {0}"'
env:
Expand All @@ -52,6 +66,7 @@ jobs:
shell: 'script -q -e -c "bash --noprofile --norc -eo pipefail {0}"'
env:
TERM: xterm-256color
LD_LIBRARY_PATH: "/usr/local/lib/" # to find libopenblas.so.0
run: |
pip install pytest pytest-xdist hypothesis typing_extensions
spin test -j auto
22 changes: 15 additions & 7 deletions tools/openblas_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@

OPENBLAS_V = '0.3.23.dev'
OPENBLAS_LONG = 'v0.3.23-246-g3d31191b'
BASE_LOC = 'https://anaconda.org/multibuild-wheels-staging/openblas-libs'
BASEURL = f'{BASE_LOC}/{OPENBLAS_LONG}/download'
BASE_LOC = (
'https://anaconda.org/scientific-python-nightly-wheels/openblas-libs'
)
SUPPORTED_PLATFORMS = [
'linux-aarch64',
'linux-x86_64',
Expand Down Expand Up @@ -91,7 +92,7 @@ def get_linux(arch):
return get_musllinux(arch)


def download_openblas(target, plat, ilp64):
def download_openblas(target, plat, ilp64, *, nightly=False):
osname, arch = plat.split("-")
fnsuffix = {None: "", "64_": "64_"}[ilp64]
filename = ''
Expand Down Expand Up @@ -120,7 +121,12 @@ def download_openblas(target, plat, ilp64):

if not suffix:
return None
filename = f'{BASEURL}/openblas{fnsuffix}-{OPENBLAS_LONG}-{suffix}'
openblas_version = "HEAD" if nightly else OPENBLAS_LONG
filename = (
f'{BASE_LOC}/{openblas_version}/download/'
f'openblas{fnsuffix}-{openblas_version}-{suffix}'
)
print(f'Attempting to download {filename}', file=sys.stderr)
req = Request(url=filename, headers=headers)
try:
response = urlopen(req)
Expand All @@ -141,7 +147,7 @@ def download_openblas(target, plat, ilp64):
return typ


def setup_openblas(plat=get_plat(), ilp64=get_ilp64()):
def setup_openblas(plat=get_plat(), ilp64=get_ilp64(), nightly=False):
'''
Download and setup an openblas library for building. If successful,
the configuration script will find it automatically.
Expand All @@ -155,7 +161,7 @@ def setup_openblas(plat=get_plat(), ilp64=get_ilp64()):
_, tmp = mkstemp()
if not plat:
raise ValueError('unknown platform')
typ = download_openblas(tmp, plat, ilp64)
typ = download_openblas(tmp, plat, ilp64, nightly=nightly)
if not typ:
return ''
osname, arch = plat.split("-")
Expand Down Expand Up @@ -346,11 +352,13 @@ def test_version(expected_version=None):
parser.add_argument('--check_version', nargs='?', default='',
help='Check provided OpenBLAS version string '
'against available OpenBLAS')
parser.add_argument('--nightly', action='store_true',
help='If set, use nightly OpenBLAS build.')
args = parser.parse_args()
if args.check_version != '':
test_version(args.check_version)
elif args.test is None:
print(setup_openblas())
print(setup_openblas(nightly=args.nightly))
else:
if len(args.test) == 0 or 'all' in args.test:
test_setup(SUPPORTED_PLATFORMS)
Expand Down

0 comments on commit d99dd6d

Please sign in to comment.