Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cache pip dependencies in CI; pin setuptool[_scm] dependencies to fix build; codecov action bump #106

Merged
merged 28 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 79 additions & 15 deletions .github/workflows/tests+pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,72 @@ jobs:
run: |
pylint --unsafe-load-any-extension=y --disable=fixme $(git ls-files '*.py')

tests_setup:
strategy:
matrix:
platform: [ubuntu-latest, macos-latest]
mpi: [ 'mpich', 'openmpi', 'intelmpi']
python-version: ["3.10"]
exclude:
# as of time of writing, mpi4py/setup-mpi does not support it
- platform: macos-latest
mpi: intelmpi

# issues with: *** The MPI_Comm_rank() function was called before MPI_INIT was invoked.
- platform: ubuntu-latest
mpi: intelmpi

# https://github.com/Homebrew/homebrew-core/issues/26974
- platform: macos-latest
mpi: mpich

runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- run: |
echo pip_user_site=$(python -c "import sysconfig; print(sysconfig.get_path('purelib'))") >> $GITHUB_ENV
echo toml_ci_md5=$(cat pyproject.toml .github/workflows/tests+pypi.yml \
| python -c "import hashlib;print(hashlib.md5(open('/dev/stdin','rb').read()).hexdigest())") >> $GITHUB_ENV
- id: cache
uses: actions/cache@v4
with:
path: ${{ env.pip_user_site }}
key: ${{ matrix.platform }}-${{ matrix.mpi }}-${{ matrix.python-version }}-${{ env.toml_ci_md5 }}

- if: steps.cache.outputs.cache-hit != 'true'
uses: mpi4py/setup-mpi@v1
with:
mpi: ${{ matrix.mpi }}
- if: steps.cache.outputs.cache-hit != 'true' && matrix.mpi == 'mpich'
run: echo _ch="ch" >> $GITHUB_ENV
- if: steps.cache.outputs.cache-hit != 'true' && startsWith(matrix.platform, 'ubuntu-')
run: |
sudo apt-get update && sudo apt-get install -y libhdf5-mpi$_ch-dev pkg-config
lscpu
- if: steps.cache.outputs.cache-hit != 'true' && startsWith(matrix.platform, 'ubuntu-') && matrix.mpi == 'mpich'
run: |
echo HDF5_LIBDIR=/usr/lib/x86_64-linux-gnu/hdf5/mpich >> $GITHUB_ENV
echo HDF5_INCLUDEDIR=/usr/include/hdf5/mpich >> $GITHUB_ENV
- if: steps.cache.outputs.cache-hit != 'true' && startsWith(matrix.platform, 'macos-')
run: |
brew install hdf5-mpi && echo HDF5_DIR=/opt/homebrew >> $GITHUB_ENV
sysctl -a | grep cpu | grep hw
- if: steps.cache.outputs.cache-hit != 'true'
run: |
HDF5_MPI="ON" CC=mpicc pip install --no-binary=h5py h5py==3.10.0
pip install -e .[tests]
- run: pip show numpy
- id: cache-save
uses: actions/cache/save@v4
with:
path: ${{ env.pip_user_site }}
key: ${{ matrix.platform }}-${{ matrix.mpi }}-${{ matrix.python-version }}-${{ env.toml_ci_md5 }}

tests:
needs: [zenodo_json, pylint, pdoc, precommit]
needs: [zenodo_json, pylint, pdoc, precommit, tests_setup]
strategy:
matrix:
platform: [ubuntu-latest, macos-latest]
Expand All @@ -108,32 +172,32 @@ jobs:
mpi: mpich

fail-fast: false

runs-on: ${{ matrix.platform }}
timeout-minutes: 60
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- run: |
echo pip_user_site=$(python -c "import sysconfig; print(sysconfig.get_path('purelib'))") >> $GITHUB_ENV
echo toml_ci_md5=$(cat pyproject.toml .github/workflows/tests+pypi.yml \
| python -c "import hashlib;print(hashlib.md5(open('/dev/stdin','rb').read()).hexdigest())") >> $GITHUB_ENV
- uses: mpi4py/setup-mpi@v1
with:
mpi: ${{ matrix.mpi }}
- id: cache
uses: actions/cache/restore@v4
with:
path: ${{ env.pip_user_site }}
key: ${{ matrix.platform }}-${{ matrix.mpi }}-${{ matrix.python-version }}-${{ env.toml_ci_md5 }}
- if: matrix.mpi == 'mpich'
run: echo _ch="ch" >> $GITHUB_ENV
- if: startsWith(matrix.platform, 'ubuntu-')
run: |
sudo apt-get update && sudo apt-get install -y libhdf5-mpi$_ch-dev pkg-config
lscpu
- if: startsWith(matrix.platform, 'ubuntu-') && matrix.mpi == 'mpich'
run: |
echo HDF5_LIBDIR=/usr/lib/x86_64-linux-gnu/hdf5/mpich >> $GITHUB_ENV
echo HDF5_INCLUDEDIR=/usr/include/hdf5/mpich >> $GITHUB_ENV
run: sudo apt-get update && sudo apt-get install -y libhdf5-mpi$_ch-dev pkg-config
- if: startsWith(matrix.platform, 'macos-')
run: |
brew install hdf5-mpi && echo HDF5_DIR=/opt/homebrew >> $GITHUB_ENV
sysctl -a | grep cpu | grep hw
- run: HDF5_MPI="ON" CC=mpicc pip install --no-binary=h5py h5py==3.10.0
- run: pip install -e .[tests]
run: brew install hdf5-mpi && echo HDF5_DIR=/opt/homebrew >> $GITHUB_ENV
- run: python -We -c "import PyMPDATA_MPI"
- if: matrix.mpi == 'openmpi'
run: echo _mpiexec_args="--oversubscribe" >> $GITHUB_ENV
Expand All @@ -150,13 +214,13 @@ jobs:
export COV_ARGS="--cov=./ --cov-report=xml"
pip install pytest-cov
fi
NUMBA_NUM_THREADS=3 mpiexec $_mpiexec_args -n ${{ matrix.mpi-np }} pytest $COV_ARGS --timeout=600 --timeout_method=thread -s -vv -We tests/local;
NUMBA_NUM_THREADS=3 mpiexec $_mpiexec_args -n ${{ matrix.mpi-np }} python -m pytest $COV_ARGS --timeout=600 --timeout_method=thread -s -vv -We tests/local;
- uses: actions/upload-artifact@v2
with:
name: plots
path: plots
- if: env.CODECOV_RUN == '1'
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
[![Github Actions Build Status](https://github.com/open-atmos/PyMPDATA-MPI/workflows/tests+pypi/badge.svg?branch=main)](https://github.com/open-atmos/PyMPDATA-MPI/actions)
[![PyPI version](https://badge.fury.io/py/PyMPDATA-MPI.svg)](https://pypi.org/project/PyMPDATA-MPI)
[![API docs](https://img.shields.io/badge/API_docs-pdoc3-blue.svg)](https://open-atmos.github.io/PyMPDATA-MPI/)
[![Coverage Status](https://codecov.io/gh/open-atmos/PyMPDATA-MPI/branch/main/graph/badge.svg)](https://app.codecov.io/gh/open-atmos/PyMPDATA-MPI)


PyMPDATA-MPI constitutes a [PyMPDATA](https://github.com/open-atmos/PyMPDATA) +
[numba-mpi](https://github.com/numba-mpi/numba-mpi) coupler enabling numerical solutions
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ py-modules = []
[tool.setuptools_scm]

[build-system]
requires = ["setuptools", "setuptools-scm"]
requires = ['setuptools==69.1.0', 'setuptools-scm==7.1.0']
build-backend = "setuptools.build_meta"

[project]
Expand Down
Loading