Skip to content
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
20 changes: 0 additions & 20 deletions .github/actions/environment/unit-mpi/action.yml

This file was deleted.

16 changes: 0 additions & 16 deletions .github/actions/environment/unit-serial/action.yml

This file was deleted.

45 changes: 0 additions & 45 deletions .github/actions/tests/unit/action.yml

This file was deleted.

65 changes: 59 additions & 6 deletions .github/workflows/reusable-scheduled.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:

jobs:
test:
name: ${{ matrix.test-type }} (${{ matrix.compile-language }}, ${{ matrix.shard }})
runs-on: ${{ inputs.os }}
env:
OMPI_MCA_rmaps_base_oversubscribe: 1 # Linux
Expand All @@ -19,6 +20,20 @@ jobs:
python-version: ["3.12"]
compile-language: ["fortran", "c"]
test-type: ["unit", "model", "verification"] #"quickstart", "tutorials"]
shard: ["shard-1", "shard-2", "shard-3", "shard-4"]
exclude:
- test-type: model
shard: shard-2
- test-type: model
shard: shard-3
- test-type: model
shard: shard-4
- test-type: verification
shard: shard-2
- test-type: verification
shard: shard-3
- test-type: verification
shard: shard-4

steps:
# Checkout the repository
Expand Down Expand Up @@ -74,22 +89,60 @@ jobs:
language: ${{ matrix.compile-language }}

- name: Set environment for mpi run
uses: ./.github/actions/environment/unit-mpi
run: |
{
echo 'TESTMON_KEY=testmon-unit-mpi'
echo 'RUN_MAXWELL=mpirun -n 1 pytest -m single --testmon-forceselect -v --with-mpi --model-name Maxwell'
echo 'UNINSTALL_MPI='
echo 'PYTEST_CMD=mpirun -n 2 pytest -v --testmon --with-mpi'
} >> "$GITHUB_ENV"

- name: Run unit tests with MPI
if: matrix.test-type == 'unit'
uses: ./.github/actions/tests/unit
with:
struphy-path: ${{ env.STRUPHY_PATH }}
env:
TESTMON_DATAFILE: ${{ github.workspace }}/.testmondata-unit-${{ matrix.shard }}
run: |
case "${{ matrix.shard }}" in
shard-1)
TEST_FILES="bsplines/tests/ console/tests/ fields_background/tests/ geometry/tests/ initial/tests/ kinetic_background/tests/ linear_algebra/tests/"
;;
shard-2)
TEST_FILES="propagators/tests/ ode/tests/ polar/tests/ post_processing/tests/"
;;
shard-3)
TEST_FILES="feec/tests/"
;;
shard-4)
TEST_FILES="pic/tests/"
;;
*)
echo "Unknown test shard: ${{ matrix.shard }}" >&2
exit 1
;;
esac
set +e
source /bin/activate || true
set -e
pip show struphy
struphy compile --status
cd ${{ env.STRUPHY_PATH }}
pwd
echo "Running $RUN_MAXWELL"
$RUN_MAXWELL
echo "Running $UNINSTALL_MPI"
$UNINSTALL_MPI
git status || true
echo "Running $PYTEST_CMD $TEST_FILES"
$PYTEST_CMD $TEST_FILES

- name: Run model tests with MPI
if: matrix.test-type == 'model'
if: matrix.test-type == 'model' && matrix.shard == 'shard-1'
shell: bash
run: |
mpirun -oversubscribe -n 2 pytest -x -m models --with-mpi $STRUPHY_PATH/models/tests/default_params/

- name: Run verification tests with MPI
if: matrix.test-type == 'verification'
if: matrix.test-type == 'verification' && matrix.shard == 'shard-1'
shell: bash
run: |
mpirun --oversubscribe -n 2 pytest -x --with-mpi $STRUPHY_PATH/models/tests/verification/
74 changes: 63 additions & 11 deletions .github/workflows/reusable-unit-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,29 @@ permissions:
contents: read

jobs:
preflight:
runs-on: ${{ inputs.os }}
steps:
- name: Check memory
run: |
free -h
grep -E 'MemTotal|MemAvailable|SwapTotal|SwapFree' /proc/meminfo

unit-tests-in-container-with-struphy:
name: Unit tests (${{ matrix.shard }})
runs-on: ${{ inputs.os }}
strategy:
fail-fast: false
matrix:
include:
- shard: shard-1
test_files: bsplines/tests/ console/tests/ fields_background/tests/ geometry/tests/ initial/tests/ kinetic_background/tests/ linear_algebra/tests/
- shard: shard-2
test_files: propagators/tests/ ode/tests/ polar/tests/ post_processing/tests/
- shard: shard-3
test_files: feec/tests/
- shard: shard-4
test_files: pic/tests/

container:
image: ghcr.io/struphy-hub/struphy/ubuntu-with-struphy:latest
Expand All @@ -34,6 +55,11 @@ jobs:
- name: Check for dockerenv file
run: (ls /.dockerenv && echo Found dockerenv) || (echo No dockerenv)

- name: Memory inside container
run: |
free -h
grep -E 'MemTotal|MemAvailable|SwapTotal|SwapFree' /proc/meminfo

- name: Checkout repo
uses: actions/checkout@v4
with:
Expand All @@ -42,11 +68,23 @@ jobs:

- name: Set environment for serial run
if: inputs.n-procs == 1
uses: ./.github/actions/environment/unit-serial
run: |
{
echo 'TESTMON_KEY=testmon-unit'
echo 'RUN_MAXWELL='
echo 'UNINSTALL_MPI=pip uninstall -y mpi4py'
echo 'PYTEST_CMD=pytest -v --testmon'
} >> "$GITHUB_ENV"

- name: Set environment for mpi run
if: inputs.n-procs > 1
uses: ./.github/actions/environment/unit-mpi
run: |
{
echo 'TESTMON_KEY=testmon-unit-mpi'
echo 'RUN_MAXWELL=mpirun -n 1 pytest -m single --testmon-forceselect -v --with-mpi --model-name Maxwell'
echo 'UNINSTALL_MPI='
echo 'PYTEST_CMD=mpirun -n ${{ inputs.n-procs }} pytest -v --testmon --with-mpi'
} >> "$GITHUB_ENV"

- name: Check .testmondata 1
run: |
Expand All @@ -56,12 +94,12 @@ jobs:
uses: actions/cache@v4
with:
path: |
.testmondata-unit
key: ${{ env.TESTMON_KEY }}-${{ github.ref_name }}-${{ github.event.number }}-${{ github.run_number }}
.testmondata-unit-${{ matrix.shard }}
key: ${{ env.TESTMON_KEY }}-${{ matrix.shard }}-${{ github.ref_name }}-${{ github.event.number }}-${{ github.run_number }}
restore-keys: |
${{ env.TESTMON_KEY }}-${{ github.ref_name }}-${{ github.event.number }}-
${{ env.TESTMON_KEY }}-${{ github.ref_name }}
${{ env.TESTMON_KEY }}-devel
${{ env.TESTMON_KEY }}-${{ matrix.shard }}-${{ github.ref_name }}-${{ github.event.number }}-
${{ env.TESTMON_KEY }}-${{ matrix.shard }}-${{ github.ref_name }}
${{ env.TESTMON_KEY }}-${{ matrix.shard }}-devel
${{ env.TESTMON_KEY }}-

- name: Check .testmondata 2
Expand All @@ -88,7 +126,21 @@ jobs:
env-name: /struphy_fortran_/env_fortran_

- name: Run unit tests
uses: ./.github/actions/tests/unit
with:
struphy-path: ${{ env.STRUPHY_PATH }}
env-name: /struphy_fortran_/env_fortran_
env:
TESTMON_DATAFILE: ${{ github.workspace }}/.testmondata-unit-${{ matrix.shard }}
TEST_FILES: ${{ matrix.test_files }}
run: |
set +e
source /struphy_fortran_/env_fortran_/bin/activate || true
set -e
pip show struphy
struphy compile --status
cd ${{ env.STRUPHY_PATH }}
pwd
echo "Running $RUN_MAXWELL"
$RUN_MAXWELL
echo "Running $UNINSTALL_MPI"
$UNINSTALL_MPI
git status || true
echo "Running $PYTEST_CMD $TEST_FILES"
$PYTEST_CMD $TEST_FILES
44 changes: 23 additions & 21 deletions docker/ubuntu-latest-with-struphy.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,19 @@
FROM ubuntu:latest

ARG DEBIAN_FRONTEND=noninteractive
ARG PYTHON_VERSION=3.13

# install linux packages
RUN apt update -y && apt clean \
&& apt install -y software-properties-common \
&& add-apt-repository -y ppa:deadsnakes/ppa \
&& apt update -y

RUN apt install -y python3 \
&& apt install -y python3-dev \
&& apt install -y python3-pip \
&& apt install -y python3-venv
RUN apt install -y python${PYTHON_VERSION} \
&& apt install -y python${PYTHON_VERSION}-dev \
&& apt install -y python${PYTHON_VERSION}-venv \
&& update-alternatives --install /usr/bin/python3 python3 /usr/bin/python${PYTHON_VERSION} 1 \
&& update-alternatives --set python3 /usr/bin/python${PYTHON_VERSION}

RUN apt install -y gfortran gcc \
&& apt install -y liblapack-dev libblas-dev
Expand All @@ -44,32 +46,32 @@ RUN apt install -y g++ liblapack3 cmake cmake-curses-gui zlib1g-dev libnetcdf-de
&& export CXX=`which g++`

# install three versions of struphy
RUN git clone https://github.com/struphy-hub/struphy.git struphy_c_ \
&& cd struphy_c_ \
&& python3 -m venv env_c_ \
&& . env_c_/bin/activate \
&& pip install -U pip \
&& pip install -e .[phys,mpi,doc] --no-cache-dir \
&& struphy compile \
&& deactivate
# RUN git clone https://github.com/struphy-hub/struphy.git struphy_c_ \
# && cd struphy_c_ \
# && python${PYTHON_VERSION} -m venv env_c_ \
# && . env_c_/bin/activate \
# && pip install -U pip \
# && pip install -e .[phys,mpi,doc] --no-cache-dir \
# && struphy compile \
# && deactivate

RUN git clone https://github.com/struphy-hub/struphy.git struphy_fortran_\
&& cd struphy_fortran_ \
&& python3 -m venv env_fortran_ \
&& python${PYTHON_VERSION} -m venv env_fortran_ \
&& . env_fortran_/bin/activate \
&& pip install -U pip \
&& pip install -e .[phys,mpi,doc] --no-cache-dir \
&& struphy compile --language fortran -y \
&& deactivate

RUN git clone https://github.com/struphy-hub/struphy.git struphy_fortran_--omp-pic\
&& cd struphy_fortran_--omp-pic \
&& python3 -m venv env_fortran_--omp-pic \
&& . env_fortran_--omp-pic/bin/activate \
&& pip install -U pip \
&& pip install -e .[phys,mpi,doc] --no-cache-dir \
&& struphy compile --language fortran --omp-pic -y \
&& deactivate
# RUN git clone https://github.com/struphy-hub/struphy.git struphy_fortran_--omp-pic\
# && cd struphy_fortran_--omp-pic \
# && python${PYTHON_VERSION} -m venv env_fortran_--omp-pic \
# && . env_fortran_--omp-pic/bin/activate \
# && pip install -U pip \
# && pip install -e .[phys,mpi,doc] --no-cache-dir \
# && struphy compile --language fortran --omp-pic -y \
# && deactivate

# allow mpirun as root
ENV OMPI_ALLOW_RUN_AS_ROOT=1
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ dependencies = [
"ipywidgets<=8.1.8",
"plotly<=6.7.0",
"pyvista<=0.48.0",
"trame<=3.12.0",
"trame<=3.13.0",
"trame-vtk<=2.11.8",
"trame-vuetify<=3.2.2",
"nest_asyncio2<=1.7.2",
Expand Down
Loading
Loading