test cached speed #1849
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Tests | |
on: [push] | |
jobs: | |
tests: | |
runs-on: ${{ matrix.os }} | |
timeout-minutes: 30 | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-13] | |
mpi: ["none", openmpi] # mpich | |
python: ["3.10", "3.13"] | |
exclude: | |
- os: macos-latest | |
mpi: mpich | |
python: "3.10" | |
# Only run tests if there is no [skipci] or [skip ci] in the commit message | |
if: | | |
!startsWith(github.event.head_commit.message, '[skip ci]') && | |
!startsWith(github.event.head_commit.message, '[skipci]') | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python }} | |
- name: Install uv | |
uses: astral-sh/setup-uv@v6 | |
env: | |
UV_CACHE_DIR: ~/pip-cache | |
with: | |
python-version: ${{ matrix.python }} | |
enable-cache: true | |
prune-cache: false | |
cache-dependency-glob: | | |
pyproject.toml | |
uv.lock | |
- name: Cache pip | |
uses: actions/cache@v4 | |
with: | |
path: ~/pip-cache | |
key: pip-${{ runner.os }}-${{ matrix.python }}-${{ matrix.mpi }}-${{ secrets.CACHE_VERSION }}-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('uv.lock') }} | |
- name: Ensure wheels cache path exists | |
run: mkdir -p ~/pip-wheels | |
- name: Cache pip wheels | |
uses: actions/cache@v4 | |
with: | |
path: ~/pip-wheels | |
key: pip-wheels-${{ runner.os }}-${{ matrix.python }}-${{ matrix.mpi }}-${{ secrets.CACHE_VERSION }}-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('uv.lock') }} | |
- name: Cache virtual environment | |
uses: actions/cache@v4 | |
with: | |
path: .venv | |
key: venv-${{ runner.os }}-${{ matrix.python }}-${{ matrix.mpi }}-${{ secrets.CACHE_VERSION }}-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('uv.lock') }} | |
# Unfortunately we must use different keys to store the same data, | |
# otherwise GitHub will complain when multiple jobs are going to | |
# store it | |
- name: Cache PySM3 data files | |
id: cache-pysm3 | |
uses: actions/cache@v4 | |
with: | |
path: ~/pysm3-data | |
key: pysm3-data-${{ runner.os }}-${{ matrix.python }}-${{ matrix.mpi }}-${{ secrets.CACHE_VERSION }} | |
- name: Register PySM3 data path | |
run: | | |
echo "PYSM_LOCAL_DATA=$HOME/pysm3-data" >> $GITHUB_ENV | |
- name: Download PySM3 data files | |
if: steps.cache-pysm3.outputs.cache-hit != 'true' | |
run: | | |
git clone --depth 1 https://github.com/galsci/pysm-data "$PYSM_LOCAL_DATA" | |
- name: Install basic dependencies (MPI, FFTW, IMO) | |
run: | | |
./bin/install-deps.sh ${{ matrix.mpi }} | |
mkdir -p $HOME/.config/litebird_imo | |
echo -e "[[repositories]]\nlocation = \"$(pwd)/test/mock_imo/\"\nname = \"Mock IMO\"" | tee $HOME/.config/litebird_imo/imo.toml | |
- name: Install litebird_sim dependencies | |
run: | | |
EXTRAS="--extra dev --extra docs" | |
if [ "${{ matrix.mpi }}" != "none" ]; then | |
EXTRAS="$EXTRAS --extra mpi" | |
fi | |
uv sync $EXTRAS | |
if [ "${{ matrix.mpi }}" != "none" ] && [ "${{ matrix.os }}" == "ubuntu-latest" ]; then | |
git clone --recursive https://github.com/anand-avinash/BrahMap.git | |
(cd BrahMap && uv run pip install .) | |
rm -rf BrahMap | |
fi | |
env: | |
DUCC0_OPTIMIZATION: none | |
PIP_CACHE_DIR: ~/pip-cache | |
UV_CACHE_DIR: ~/pip-cache | |
- name: Tests | |
run: uv run bash ./bin/run_tests.sh | |
- name: Tests MPICH | |
if: ${{ matrix.mpi == 'mpich' }} | |
run: | | |
# See issue #457: <https://github.com/litebird/litebird_sim/issues/457> | |
if [[ "$(uname)" == "Darwin" ]]; then | |
export HDF5_USE_FILE_LOCKING=FALSE | |
fi | |
for proc in 1 2 ; do | |
echo "Running MPI test ($MPI) with $proc processes" | |
PYTHONPATH=. mpiexec -n $proc uv run python ./test/test_mpi.py | |
PYTHONPATH=. mpiexec -n $proc uv run python ./test/test_detector_blocks.py | |
done | |
echo "Running MPI test ($MPI) with 4 processes" | |
PYTHONPATH=. mpiexec --map-by :OVERSUBSCRIBE -n 4 uv run python ./test/test_mpi_n4.py | |
PYTHONPATH=. mpiexec -n $proc uv run python ./test/test_detector_blocks.py | |
- name: Tests OpenMPI | |
if: ${{ matrix.mpi == 'openmpi' }} | |
run: | | |
# See issue #457: <https://github.com/litebird/litebird_sim/issues/457> | |
if [[ "$(uname)" == "Darwin" ]]; then | |
export HDF5_USE_FILE_LOCKING=FALSE | |
fi | |
for proc in 1 2 ; do | |
echo "Running MPI test ($MPI) with $proc processes" | |
PYTHONPATH=. mpiexec -n $proc uv run python ./test/test_mpi.py | |
PYTHONPATH=. mpiexec -n $proc uv run python ./test/test_detector_blocks.py | |
done | |
echo "Running MPI test ($MPI) with 4 processes" | |
PYTHONPATH=. mpiexec --map-by :OVERSUBSCRIBE -n 4 uv run python ./test/test_mpi_n4.py | |
- name: Coverage comment | |
uses: py-cov-action/python-coverage-comment-action@v3 | |
if: runner.os == 'Linux' | |
with: | |
GITHUB_TOKEN: ${{ github.token }} |