Skip to content

Commit 1f64b26

Browse files
authored
Merge pull request #47 from MP-Gadget/maint
Small maintainence things to fix the github action and update the python build system.
2 parents d04a02a + 503c243 commit 1f64b26

File tree

7 files changed

+135
-84
lines changed

7 files changed

+135
-84
lines changed

.github/workflows/main.yaml

Lines changed: 70 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
name: main
44

55
on:
6-
schedule:
7-
- cron: '* * * * 5' # Runs on every Friday.
86
push:
97
branches: [ '*', $default-branch ]
108
tags: ['[0-9]*'] # anything looks like a version.
@@ -24,78 +22,110 @@ jobs:
2422
defaults:
2523
run:
2624
shell: bash -l {0} # for conda.
27-
2825
strategy:
2926
fail-fast: false
3027
matrix:
3128
os: [ ubuntu-latest, macos-latest ]
32-
numpy-version: [ 1.16 ]
33-
python-version: [ 3.8 ]
34-
include:
35-
- {deploy: true, os: ubuntu-latest, numpy-version: 1.16, python-version: 3.8 }
29+
python-version: [ '3.8', '3.10', '3.13' ]
30+
#Something seems wrong with the conda packages for these python versions.
31+
#pip --upgrade fails for 3.13 and for 3.10 there is an import error.
32+
exclude:
33+
- os: macos-latest
34+
python-version: '3.10'
35+
- os: macos-latest
36+
python-version: '3.13'
3637
steps:
37-
3838
- name: Checkout source code
39-
uses: actions/checkout@v2
40-
39+
uses: actions/checkout@v4
4140
- name: Cache conda
42-
uses: actions/cache@v1
41+
if: matrix.os == 'macos-latest'
42+
uses: actions/cache@v4
4343
env:
4444
# Increase this value to reset cache.
4545
CACHE_NUMBER: 0
4646
with:
4747
path: ~/conda_pkgs_dir
4848
key:
4949
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}
50-
5150
- name: Setup Conda Environment
52-
uses: conda-incubator/setup-miniconda@v2.0.1
51+
if: matrix.os == 'macos-latest'
52+
uses: conda-incubator/setup-miniconda@v3.2.0
5353
with:
5454
activate-environment: test
5555
channels: bccp,conda-forge
5656
show-channel-urls: true
5757
use-only-tar-bz2: true
5858
auto-update-conda: true
5959
python-version: ${{ matrix.python-version }}
60-
61-
- name: Setup test env
60+
- name: Setup mac test env
61+
if: matrix.os == 'macos-latest'
6262
run: |
6363
conda install -q -y \
6464
python=${{ matrix.python-version }} \
65-
numpy=${{ matrix.numpy-version }} \
66-
nose cython mpi4py \
67-
compilers
68-
conda install -q -y cmake gsl
69-
conda install -q -y runtests
70-
65+
numpy cython mpi4py compilers
66+
conda install -q -y cmake gsl pytest pytest-mpi python-build
67+
- name: Setup linux test env
68+
if: matrix.os == 'ubuntu-latest'
69+
run: |
70+
sudo apt update
71+
sudo apt install -y build-essential libopenmpi-dev openmpi-bin python3-numpy cython3 python3-mpi4py cmake libgsl-dev
72+
python -m pip install --upgrade pip
73+
pip install build pytest pytest-mpi
74+
- name: Build
75+
run: |
76+
python -m build
77+
- name: Install
78+
run: |
79+
python -m pip install --user dist/bigfile*whl
80+
- name: Build in place for tests
81+
run: |
82+
python setup.py build_ext --inplace
7183
- name: Build C
7284
run: |
73-
mkdir build
74-
cd build
85+
mkdir Cbuild
86+
cd Cbuild
7587
cmake -DCMAKE_INSTALL_PREFIX:PATH=install ..
7688
make install
77-
7889
- name: C Unit tests
7990
run: |
80-
mpirun -n 4 build/utils/bigfile-iosim -n 1 -s 1024000 create test
81-
mpirun -n 4 build/utils/bigfile-iosim -n 1 -s 1024000 read test
82-
mpirun -n 4 build/utils/bigfile-iosim -n 4 -s 1024000 read test
83-
mpirun -n 4 build/utils/bigfile-iosim -A -n 1 -s 1024000 read test
84-
mpirun -n 4 build/utils/bigfile-iosim -A -n 4 -s 1024000 read test
85-
mpirun -n 8 build/utils/bigfile-iosim -A -n 2 -s 1024000 read test
86-
91+
mpirun -n 4 Cbuild/utils/bigfile-iosim -n 1 -s 1024000 create test
92+
mpirun -n 4 Cbuild/utils/bigfile-iosim -n 1 -s 1024000 read test
93+
mpirun -n 4 Cbuild/utils/bigfile-iosim -n 4 -s 1024000 read test
94+
mpirun -n 4 Cbuild/utils/bigfile-iosim -A -n 1 -s 1024000 read test
95+
mpirun -n 4 Cbuild/utils/bigfile-iosim -A -n 4 -s 1024000 read test
96+
mpirun -n 8 Cbuild/utils/bigfile-iosim -A -n 2 -s 1024000 read test
8797
- name: Python Unit tests
8898
run: |
89-
python ./runtests.py
90-
91-
- name: Build Python sdist
92-
if: startsWith(github.ref, 'refs/tags') && matrix.deploy
99+
python -m pytest --with-mpi
100+
mpirun -n 2 python -m pytest --with-mpi
101+
mpirun -n 4 --oversubscribe python -m pytest --with-mpi
102+
- name: Build Python dist
103+
if: matrix.os == 'ubuntu-latest' && startsWith(github.ref, 'refs/tags')
93104
run: |
94105
bash check_tag.sh "${GITHUB_REF##*/}" bigfile/version.py
95-
python setup.py sdist
106+
- name: Store the distribution packages
107+
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.10' #Only do this once!
108+
uses: actions/upload-artifact@v4
109+
with:
110+
name: python-package-distributions
111+
path: dist/bigfile*.tar.gz
96112

97-
- name: Publish distribution to PyPI
98-
uses: pypa/gh-action-pypi-publish@master
99-
if: startsWith(github.ref, 'refs/tags') && matrix.deploy
113+
publish-to-pypi:
114+
name: Publish to PyPI
115+
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
116+
needs:
117+
- build
118+
runs-on: ubuntu-latest
119+
environment:
120+
name: pypi
121+
url: https://pypi.org/p/bigfile
122+
permissions:
123+
id-token: write # IMPORTANT: mandatory for trusted publishing
124+
steps:
125+
- name: Download the source dist
126+
uses: actions/download-artifact@v4
100127
with:
101-
password: ${{ secrets.PYPI_SECRET }}
128+
name: python-package-distributions
129+
path: dist/
130+
- name: Publish distribution to PyPI
131+
uses: pypa/gh-action-pypi-publish@release/v1

MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ include src/*.c
22
include src/*.h
33
include bigfile/*.pyx
44
include bigfile/*.c
5-
README.rst
5+
include README.rst

bigfile/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def __getitem__(self, key):
115115
return self.open(key)
116116

117117
def __getstate__(self):
118-
return (self.comm, getattr(self, 'blocks', None), FileLowLevelAPI.__getstate__(self))
118+
return (self.comm, getattr(self, 'blocks', None), FileLowLevelAPI.__getstate__(self))
119119

120120
def __setstate__(self, state):
121121
comm, blocks, basestate = state
@@ -155,7 +155,7 @@ def create_from_array(self, blockname, array, Nfile=None, memorylimit=1024 * 102
155155
Parameters
156156
----------
157157
array : array_like,
158-
array shall have a scalar dtype.
158+
array shall have a scalar dtype.
159159
blockname : string
160160
name of the block
161161
Nfile : int or None
@@ -284,7 +284,7 @@ def create_from_array(self, blockname, array, Nfile=None, memorylimit=1024 * 102
284284
Parameters
285285
----------
286286
array : array_like,
287-
array shall have a scalar dtype.
287+
array shall have a scalar dtype.
288288
blockname : string
289289
name of the block
290290
Nfile : int or None
@@ -413,7 +413,7 @@ def check_unique(variable, comm):
413413

414414
def _make_alias(name, origin):
415415
def __init__(self, *args, **kwargs):
416-
warnings.warn('%s deprecated, use %s instead' % (name, origin), DeprecationWarning)
416+
# warnings.warn('%s deprecated, use %s instead' % (name, origin), DeprecationWarning)
417417
origin.__init__(self, *args, **kwargs)
418418

419419
newtype = type(name, (origin,object), {

bigfile/pyxbigfile.pyx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ cdef extern from "bigfile.h":
2525
char * basename
2626
size_t size
2727
int Nfile
28-
unsigned int * fchecksum;
28+
unsigned int * fchecksum;
2929
int dirty
3030
CBigAttrSet * attrset;
3131

@@ -232,9 +232,9 @@ cdef class AttrSet:
232232
attr[0].nmemb)):
233233
raise Error()
234234
if attr[0].dtype[1] == 'S':
235-
return [i.tostring().decode() for i in result]
235+
return [i.tobytes().decode() for i in result]
236236
if attr[0].dtype[1] == 'a':
237-
return result.tostring().decode()
237+
return result.tobytes().decode()
238238
return result
239239

240240
def __delitem__(self, name):
@@ -266,7 +266,7 @@ cdef class AttrSet:
266266

267267
cdef numpy.ndarray buf = value
268268

269-
if(0 != big_block_set_attr(&self.bb.bb, name, buf.data,
269+
if(0 != big_block_set_attr(&self.bb.bb, name, buf.data,
270270
dtype,
271271
buf.shape[0])):
272272
raise Error();
@@ -410,8 +410,8 @@ cdef class ColumnLowLevelAPI:
410410
cdef CBigArray array
411411
cdef CBigBlockPtr ptr
412412

413-
big_array_init(&array, buf.data, buf.dtype.str.encode(),
414-
buf.ndim,
413+
big_array_init(&array, buf.data, buf.dtype.str.encode(),
414+
buf.ndim,
415415
<size_t *> buf.shape,
416416
<ptrdiff_t *> buf.strides)
417417
with nogil:
@@ -464,14 +464,14 @@ cdef class ColumnLowLevelAPI:
464464
return self.write(tail, buf)
465465

466466
def read(self, numpy.intp_t start, numpy.intp_t length, out=None):
467-
""" read from offset `start' a chunk of data of length `length',
467+
""" read from offset `start' a chunk of data of length `length',
468468
into array `out'.
469469
470470
out shall match length and self.dtype
471471
472472
returns out, or a newly allocated array of out is None.
473473
"""
474-
cdef numpy.ndarray result
474+
cdef numpy.ndarray result
475475
cdef CBigArray array
476476
cdef CBigBlockPtr ptr
477477
cdef int i
@@ -488,8 +488,8 @@ cdef class ColumnLowLevelAPI:
488488
if result.dtype.base.itemsize != self.dtype.base.itemsize:
489489
raise ValueError("output array type mismatches with the block")
490490

491-
big_array_init(&array, result.data, self.bb.dtype,
492-
result.ndim,
491+
big_array_init(&array, result.data, self.bb.dtype,
492+
result.ndim,
493493
<size_t *> result.shape,
494494
<ptrdiff_t *> result.strides)
495495

0 commit comments

Comments
 (0)