diff --git a/.github/actions/install/struphy_in_container/action.yml b/.github/actions/install/struphy_in_container/action.yml new file mode 100644 index 000000000..0bfaf30c7 --- /dev/null +++ b/.github/actions/install/struphy_in_container/action.yml @@ -0,0 +1,26 @@ +name: "Install Struphy in Container" + +runs: + using: composite + steps: + - name: Git branch name + id: git-branch-name + uses: EthanSK/git-branch-name-action@v1 + - name: Echo the branch name + shell: bash + run: echo "Branch name ${GIT_BRANCH_NAME}" + - name: Install struphy + shell: bash + run: | + ls / -a + which python3 + cd /struphy_c_ + git status + git fetch origin + echo ${GIT_BRANCH_NAME} + git checkout ${GIT_BRANCH_NAME} + git pull + source env_c_/bin/activate + which python3 + struphy -p + pip install -e ".[phys,mpi,doc]" \ No newline at end of file diff --git a/.github/workflows/testing.yml b/.github/workflows/reusable-testing.yml similarity index 100% rename from .github/workflows/testing.yml rename to .github/workflows/reusable-testing.yml diff --git a/.github/workflows/test-PR-models.yml b/.github/workflows/test-PR-models.yml new file mode 100644 index 000000000..9dfeb3ebc --- /dev/null +++ b/.github/workflows/test-PR-models.yml @@ -0,0 +1,72 @@ +name: PR - model tests in Container + +on: + pull_request: + branches: + - main + - devel + workflow_dispatch: + +defaults: + run: + shell: bash + +permissions: + contents: read + +# concurrency: +# group: "pages" +# cancel-in-progress: false + +jobs: + model-tests-in-container-with-struphy: + runs-on: ubuntu-latest + container: + image: ghcr.io/struphy-hub/struphy/ubuntu-with-struphy:latest + credentials: + username: spossann + password: ${{ secrets.GHCR_TOKEN }} + steps: + + - name: Check for dockerenv file + run: (ls /.dockerenv && echo Found dockerenv) || (echo No dockerenv) + + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Install Struphy in Container + uses: ./.github/actions/install/struphy_in_container + + - name: Compile Struphy + run: | + which python3 + source /struphy_c_/env_c_/bin/activate + which python3 + struphy compile --status + struphy compile + + - name: Model tests + shell: bash + run: | + which python3 + source /struphy_c_/env_c_/bin/activate + which python3 + struphy compile --status + struphy test LinearMHD + struphy test toy + struphy test models + struphy test verification + + - name: Model tests with MPI + shell: bash + run: | + which python3 + source /struphy_c_/env_c_/bin/activate + which python3 + struphy compile --status + struphy test models + struphy test models --mpi 2 + struphy test verification --mpi 1 + struphy test verification --mpi 4 + struphy test verification --mpi 4 --nclones 2 + struphy test VlasovAmpereOneSpecies --mpi 2 --nclones 2 diff --git a/.github/workflows/test-PR-unit.yml b/.github/workflows/test-PR-unit.yml new file mode 100644 index 000000000..1f6df8cf4 --- /dev/null +++ b/.github/workflows/test-PR-unit.yml @@ -0,0 +1,68 @@ +name: PR - unit tests in Container + +on: + pull_request: + branches: + - main + - devel + workflow_dispatch: + +defaults: + run: + shell: bash + +permissions: + contents: read + +# concurrency: +# group: "pages" +# cancel-in-progress: false + +jobs: + unit-tests-in-container-with-struphy: + runs-on: ubuntu-latest + container: + image: ghcr.io/struphy-hub/struphy/ubuntu-with-struphy:latest + credentials: + username: spossann + password: ${{ secrets.GHCR_TOKEN }} + steps: + + - name: Check for dockerenv file + run: (ls /.dockerenv && echo Found dockerenv) || (echo No dockerenv) + + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Install Struphy in Container + uses: ./.github/actions/install/struphy_in_container + + - name: Compile Struphy + run: | + which python3 + source /struphy_c_/env_c_/bin/activate + which python3 + struphy compile --status + struphy compile + + - name: Run unit tests with MPI + shell: bash + run: | + which python3 + source /struphy_c_/env_c_/bin/activate + which python3 + struphy compile --status + struphy --refresh-models + struphy test unit --mpi 2 + + - name: Run unit tests + shell: bash + run: | + which python3 + source /struphy_c_/env_c_/bin/activate + which python3 + struphy compile --status + struphy --refresh-models + pip show mpi4py + pip uninstall -y mpi4py + struphy test unit diff --git a/.github/workflows/ubuntu-latest.yml b/.github/workflows/ubuntu-latest.yml index e66aeb3b3..8fd73272e 100644 --- a/.github/workflows/ubuntu-latest.yml +++ b/.github/workflows/ubuntu-latest.yml @@ -1,20 +1,11 @@ -name: Ubuntu +name: Ubuntu latest - cronjob on: - push: - branches: - - main - - devel - pull_request: - branches: - - main - - devel - -# concurrency: -# group: ${{ github.ref }} -# cancel-in-progress: true + schedule: + # run at 1 a.m. on Sunday + - cron: "0 1 * * 0" jobs: ubuntu-latest-build: - uses: ./.github/workflows/testing.yml + uses: ./.github/workflows/reusable-testing.yml with: os: ubuntu-latest \ No newline at end of file diff --git a/docker/almalinux-latest.dockerfile b/docker/almalinux-latest.dockerfile index acb1824fd..8d84d5e45 100644 --- a/docker/almalinux-latest.dockerfile +++ b/docker/almalinux-latest.dockerfile @@ -1,12 +1,13 @@ -# Here is how to build the image and upload it to the mpcdf gitlab registry: +# Here is how to build the image and upload it to the Github package registry: # # We suppose you are in the struphy repo directory. -# Start the docker engine and run "docker login" with the following token: +# Start the docker engine and login to the Github package registry using a github personal acces token (classic): # -# TOKEN=gldt-CgMRBMtePbSwdWTxKw4Q; echo "$TOKEN" | docker login gitlab-registry.mpcdf.mpg.de -u gitlab+deploy-token-162 --password-stdin +# export CR_PAT=YOUR_TOKEN +# echo $CR_PAT | docker login ghcr.io -u USERNAME --password-stdin # docker info -# docker build -t gitlab-registry.mpcdf.mpg.de/struphy/struphy/almalinux-latest --provenance=false -f docker/almalinux-latest.dockerfile . -# docker push gitlab-registry.mpcdf.mpg.de/struphy/struphy/almalinux-latest +# docker build -t ghcr.io/struphy-hub/struphy/almalinux-with-reqs:latest --provenance=false -f docker/almalinux-latest.dockerfile . +# docker push ghcr.io/struphy-hub/struphy/almalinux-with-reqs:latest FROM almalinux:latest @@ -42,9 +43,6 @@ RUN echo "Installing additional tools..." \ && export CC=`which gcc` \ && export CXX=`which g++` -# create new working dir -WORKDIR /install_struphy_here/ - # allow mpirun as root ENV OMPI_ALLOW_RUN_AS_ROOT=1 ENV OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1 diff --git a/docker/fedora-latest.dockerfile b/docker/fedora-latest.dockerfile index 9cf384454..79c3ed6a7 100644 --- a/docker/fedora-latest.dockerfile +++ b/docker/fedora-latest.dockerfile @@ -1,12 +1,13 @@ -# Here is how to build the image and upload it to the mpcdf gitlab registry: +# Here is how to build the image and upload it to the Github package registry: # # We suppose you are in the struphy repo directory. -# Start the docker engine and run "docker login" with the following token: +# Start the docker engine and login to the Github package registry using a github personal acces token (classic): # -# TOKEN=gldt-CgMRBMtePbSwdWTxKw4Q; echo "$TOKEN" | docker login gitlab-registry.mpcdf.mpg.de -u gitlab+deploy-token-162 --password-stdin +# export CR_PAT=YOUR_TOKEN +# echo $CR_PAT | docker login ghcr.io -u USERNAME --password-stdin # docker info -# docker build -t gitlab-registry.mpcdf.mpg.de/struphy/struphy/fedora-latest --provenance=false -f docker/fedora-latest.dockerfile . -# docker push gitlab-registry.mpcdf.mpg.de/struphy/struphy/fedora-latest +# docker build -t ghcr.io/struphy-hub/struphy/fedora-with-reqs:latest --provenance=false -f docker/fedora-latest.dockerfile . +# docker push ghcr.io/struphy-hub/struphy/fedora-with-reqs:latest FROM fedora:latest @@ -34,9 +35,6 @@ RUN echo "Installing additional tools..." \ && export CC=`which gcc` \ && export CXX=`which g++` - # create new working dir -WORKDIR /install_struphy_here/ - # allow mpirun as root ENV OMPI_ALLOW_RUN_AS_ROOT=1 ENV OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1 diff --git a/docker/mpcdf-gcc-openmpi-with-struphy.dockerfile b/docker/mpcdf-gcc-openmpi-with-struphy.dockerfile deleted file mode 100644 index 1b64254f9..000000000 --- a/docker/mpcdf-gcc-openmpi-with-struphy.dockerfile +++ /dev/null @@ -1,56 +0,0 @@ -# Here is how to build the image and upload it to the mpcdf gitlab registry: -# -# We suppose you are in the struphy repo directory. -# Start the docker engine and run "docker login" with the following token: -# -# TOKEN=gldt-CgMRBMtePbSwdWTxKw4Q; echo "$TOKEN" | docker login gitlab-registry.mpcdf.mpg.de -u gitlab+deploy-token-162 --password-stdin -# docker info -# docker build -t gitlab-registry.mpcdf.mpg.de/struphy/struphy/mpcdf-gcc-openmpi-with-struphy --provenance=false -f docker/mpcdf-gcc-openmpi-with-struphy.dockerfile . -# docker push gitlab-registry.mpcdf.mpg.de/struphy/struphy/mpcdf-gcc-openmpi-with-struphy - -FROM gitlab-registry.mpcdf.mpg.de/mpcdf/ci-module-image/gcc_14-openmpi_5_0:latest - -RUN source ./mpcdf/soft/SLE_15/packages/x86_64/Modules/5.4.0/etc/profile.d/modules.sh \ - && module load gcc/14 openmpi/5.0 python-waterboa/2024.06 git graphviz/8 \ - && module load cmake netcdf-serial mkl hdf5-serial \ - && export FC=`which gfortran` \ - && export CC=`which gcc` \ - && export CXX=`which g++` \ - && git clone https://gitlab.mpcdf.mpg.de/struphy/struphy.git struphy_c_ \ - && cd struphy_c_ \ - && python3 -m venv env_c_ \ - && source env_c_/bin/activate \ - && pip install -U pip \ - && pip install -e .[phys] --no-cache-dir --no-binary mpi4py \ - && struphy compile \ - && deactivate - -RUN source ./mpcdf/soft/SLE_15/packages/x86_64/Modules/5.4.0/etc/profile.d/modules.sh \ - && module load gcc/14 openmpi/5.0 python-waterboa/2024.06 git graphviz/8 \ - && module load cmake netcdf-serial mkl hdf5-serial \ - && export FC=`which gfortran` \ - && export CC=`which gcc` \ - && export CXX=`which g++` \ - && git clone https://gitlab.mpcdf.mpg.de/struphy/struphy.git struphy_fortran_\ - && cd struphy_fortran_ \ - && python3 -m venv env_fortran_ \ - && source env_fortran_/bin/activate \ - && pip install -U pip \ - && pip install -e .[phys] --no-cache-dir --no-binary mpi4py \ - && struphy compile --language fortran -y \ - && deactivate - -RUN source ./mpcdf/soft/SLE_15/packages/x86_64/Modules/5.4.0/etc/profile.d/modules.sh \ - && module load gcc/14 openmpi/5.0 python-waterboa/2024.06 git graphviz/8 \ - && module load cmake netcdf-serial mkl hdf5-serial \ - && export FC=`which gfortran` \ - && export CC=`which gcc` \ - && export CXX=`which g++` \ - && git clone https://gitlab.mpcdf.mpg.de/struphy/struphy.git struphy_fortran_--omp-pic\ - && cd struphy_fortran_--omp-pic \ - && python3 -m venv env_fortran_--omp-pic \ - && source env_fortran_--omp-pic/bin/activate \ - && pip install -U pip \ - && pip install -e .[phys] --no-cache-dir --no-binary mpi4py \ - && struphy compile --language fortran --omp-pic -y \ - && deactivate \ No newline at end of file diff --git a/docker/opensuse-latest.dockerfile b/docker/opensuse-latest.dockerfile index 04ecff4e4..ef7fc47f4 100644 --- a/docker/opensuse-latest.dockerfile +++ b/docker/opensuse-latest.dockerfile @@ -1,12 +1,13 @@ -# Here is how to build the image and upload it to the mpcdf gitlab registry: +# Here is how to build the image and upload it to the Github package registry: # # We suppose you are in the struphy repo directory. -# Start the docker engine and run "docker login" with the following token: +# Start the docker engine and login to the Github package registry using a github personal acces token (classic): # -# TOKEN=gldt-CgMRBMtePbSwdWTxKw4Q; echo "$TOKEN" | docker login gitlab-registry.mpcdf.mpg.de -u gitlab+deploy-token-162 --password-stdin +# export CR_PAT=YOUR_TOKEN +# echo $CR_PAT | docker login ghcr.io -u USERNAME --password-stdin # docker info -# docker build -t gitlab-registry.mpcdf.mpg.de/struphy/struphy/opensuse-latest --provenance=false -f docker/opensuse-latest.dockerfile . -# docker push gitlab-registry.mpcdf.mpg.de/struphy/struphy/opensuse-latest +# docker build -t ghcr.io/struphy-hub/struphy/opensuse-with-reqs:latest --provenance=false -f docker/opensuse-latest.dockerfile . +# docker push ghcr.io/struphy-hub/struphy/opensuse-with-reqs:latest FROM opensuse/tumbleweed:latest @@ -42,9 +43,6 @@ RUN echo "Installing additional tools..." \ && export CXX=`which g++` \ && zypper clean --all -# Create a new working directory -WORKDIR /install_struphy_here/ - # Allow mpirun to run as root (for OpenMPI) ENV OMPI_ALLOW_RUN_AS_ROOT=1 ENV OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1 diff --git a/docker/ubuntu-latest-with-struphy.dockerfile b/docker/ubuntu-latest-with-struphy.dockerfile index c7fea9c9b..5b8d8c0fd 100644 --- a/docker/ubuntu-latest-with-struphy.dockerfile +++ b/docker/ubuntu-latest-with-struphy.dockerfile @@ -1,12 +1,13 @@ -# Here is how to build the image and upload it to the mpcdf gitlab registry: +# Here is how to build the image and upload it to the Github package registry: # # We suppose you are in the struphy repo directory. -# Start the docker engine and run "docker login" with the following token: +# Start the docker engine and login to the Github package registry using a github personal acces token (classic): # -# TOKEN=gldt-CgMRBMtePbSwdWTxKw4Q; echo "$TOKEN" | docker login gitlab-registry.mpcdf.mpg.de -u gitlab+deploy-token-162 --password-stdin +# export CR_PAT=YOUR_TOKEN +# echo $CR_PAT | docker login ghcr.io -u USERNAME --password-stdinn # docker info -# docker build -t gitlab-registry.mpcdf.mpg.de/struphy/struphy/ubuntu-latest-with-struphy --provenance=false -f docker/ubuntu-latest-with-struphy.dockerfile . -# docker push gitlab-registry.mpcdf.mpg.de/struphy/struphy/ubuntu-latest-with-struphy +# docker build -t ghcr.io/struphy-hub/struphy/ubuntu-with-struphy:latest --provenance=false -f docker/ubuntu-latest-with-struphy.dockerfile . +# docker push ghcr.io/struphy-hub/struphy/ubuntu-with-struphy:latest FROM ubuntu:latest @@ -16,49 +17,57 @@ ARG DEBIAN_FRONTEND=noninteractive RUN apt update -y && apt clean \ && apt install -y software-properties-common \ && add-apt-repository -y ppa:deadsnakes/ppa \ - && apt update -y \ - && apt install -y python3 \ + && apt update -y + +RUN apt install -y python3 \ && apt install -y python3-dev \ && apt install -y python3-pip \ - && apt install -y python3-venv \ - && apt install -y gfortran gcc \ - && apt install -y liblapack-dev libblas-dev \ - && apt install -y libopenmpi-dev openmpi-bin \ - && apt install -y libomp-dev libomp5 \ - && apt install -y git \ + && apt install -y python3-venv + +RUN apt install -y gfortran gcc \ + && apt install -y liblapack-dev libblas-dev + +RUN apt install -y libopenmpi-dev openmpi-bin \ + && apt install -y libomp-dev libomp5 + +RUN apt install -y git \ && apt install -y pandoc graphviz \ - && bash -c "source ~/.bashrc" \ - # for gvec - && apt install -y g++ liblapack3 cmake cmake-curses-gui zlib1g-dev libnetcdf-dev libnetcdff-dev \ + && bash -c "source ~/.bashrc" + +# for gvec +RUN apt install -y g++ liblapack3 cmake cmake-curses-gui zlib1g-dev libnetcdf-dev libnetcdff-dev \ && export FC=`which gfortran` \ && export CC=`which gcc` \ && export CXX=`which g++` # install three versions of struphy -RUN git clone https://gitlab.mpcdf.mpg.de/struphy/struphy.git struphy_c_ \ +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] --no-cache-dir \ + && pip install -e .[phys,mpi,doc] --no-cache-dir \ + && struphy compile --status \ && struphy compile \ && deactivate -RUN git clone https://gitlab.mpcdf.mpg.de/struphy/struphy.git struphy_fortran_\ +RUN git clone https://github.com/struphy-hub/struphy.git struphy_fortran_\ && cd struphy_fortran_ \ && python3 -m venv env_fortran_ \ && . env_fortran_/bin/activate \ && pip install -U pip \ - && pip install -e .[phys] --no-cache-dir \ + && pip install -e .[phys,mpi,doc] --no-cache-dir \ + && struphy compile --status \ && struphy compile --language fortran -y \ && deactivate -RUN git clone https://gitlab.mpcdf.mpg.de/struphy/struphy.git struphy_fortran_--omp-pic\ +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] --no-cache-dir \ + && pip install -e .[phys,mpi,doc] --no-cache-dir \ + && struphy compile --status \ && struphy compile --language fortran --omp-pic -y \ && deactivate diff --git a/docker/ubuntu-latest.dockerfile b/docker/ubuntu-latest.dockerfile index adcf65609..386426c29 100644 --- a/docker/ubuntu-latest.dockerfile +++ b/docker/ubuntu-latest.dockerfile @@ -1,12 +1,13 @@ -# Here is how to build the image and upload it to the mpcdf gitlab registry: +# Here is how to build the image and upload it to the Github package registry: # # We suppose you are in the struphy repo directory. -# Start the docker engine and run "docker login" with the following token: +# Start the docker engine and login to the Github package registry using a github personal acces token (classic): # -# TOKEN=gldt-CgMRBMtePbSwdWTxKw4Q; echo "$TOKEN" | docker login gitlab-registry.mpcdf.mpg.de -u gitlab+deploy-token-162 --password-stdin +# export CR_PAT=YOUR_TOKEN +# echo $CR_PAT | docker login ghcr.io -u USERNAME --password-stdin # docker info -# docker build -t gitlab-registry.mpcdf.mpg.de/struphy/struphy/ubuntu-latest --provenance=false -f docker/ubuntu-latest.dockerfile . -# docker push gitlab-registry.mpcdf.mpg.de/struphy/struphy/ubuntu-latest +# docker build -t ghcr.io/struphy-hub/struphy/ubuntu-with-reqs:latest --provenance=false -f docker/ubuntu-latest.dockerfile . +# docker push ghcr.io/struphy-hub/struphy/ubuntu-with-reqs:latest FROM ubuntu:latest @@ -16,27 +17,29 @@ ARG DEBIAN_FRONTEND=noninteractive RUN apt update -y && apt clean \ && apt install -y software-properties-common \ && add-apt-repository -y ppa:deadsnakes/ppa \ - && apt update -y \ - && apt install -y python3 \ + && apt update -y + +RUN apt install -y python3 \ && apt install -y python3-dev \ && apt install -y python3-pip \ - && apt install -y python3-venv \ - && apt install -y gfortran gcc \ - && apt install -y liblapack-dev libblas-dev \ - && apt install -y libopenmpi-dev openmpi-bin \ - && apt install -y libomp-dev libomp5 \ - && apt install -y git \ + && apt install -y python3-venv + +RUN apt install -y gfortran gcc \ + && apt install -y liblapack-dev libblas-dev + +RUN apt install -y libopenmpi-dev openmpi-bin \ + && apt install -y libomp-dev libomp5 + +RUN apt install -y git \ && apt install -y pandoc graphviz \ - && bash -c "source ~/.bashrc" \ - # for gvec - && apt install -y g++ liblapack3 cmake cmake-curses-gui zlib1g-dev libnetcdf-dev libnetcdff-dev \ + && bash -c "source ~/.bashrc" + +# for gvec +RUN apt install -y g++ liblapack3 cmake cmake-curses-gui zlib1g-dev libnetcdf-dev libnetcdff-dev \ && export FC=`which gfortran` \ && export CC=`which gcc` \ && export CXX=`which g++` -# Create a new working directory -WORKDIR /install_struphy_here/ - # allow mpirun as root ENV OMPI_ALLOW_RUN_AS_ROOT=1 ENV OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1 diff --git a/src/struphy/console/test.py b/src/struphy/console/test.py index ebcff34d4..ab64707e3 100644 --- a/src/struphy/console/test.py +++ b/src/struphy/console/test.py @@ -42,14 +42,14 @@ def struphy_test( str(mpi), "pytest", "-k", - "not _models and not _tutorial and not pproc", + "not _models and not _tutorial and not pproc and not _verif_", "--with-mpi", ] else: cmd = [ "pytest", "-k", - "not _models and not _tutorial and not pproc", + "not _models and not _tutorial and not pproc and not _verif_", ] if with_desc: diff --git a/src/struphy/feec/tests/test_l2_projectors.py b/src/struphy/feec/tests/test_l2_projectors.py index 7da42eff4..2e9f611eb 100644 --- a/src/struphy/feec/tests/test_l2_projectors.py +++ b/src/struphy/feec/tests/test_l2_projectors.py @@ -15,7 +15,7 @@ @pytest.mark.parametrize("p", [[2, 1, 1], [3, 2, 1]]) @pytest.mark.parametrize("spl_kind", [[False, True, True]]) @pytest.mark.parametrize("array_input", [False, True]) -def test_l2_projectors_mappings(Nel, p, spl_kind, array_input, with_desc, do_plot=False): +def test_l2_projectors_mappings(Nel, p, spl_kind, array_input, with_gvec=False, with_desc=False, do_plot=False): """Tests the L2-projectors for all available mappings. Both callable and array inputs to the projectors are tested. @@ -50,6 +50,10 @@ def test_l2_projectors_mappings(Nel, p, spl_kind, array_input, with_desc, do_plo print(f"Testing {dom_class =}") print("#" * 80) + if "GVEC" in dom_type and not with_gvec: + print(f"Attention: {with_gvec =}, GVEC not tested here !!") + continue + if "DESC" in dom_type and not with_desc: print(f"Attention: {with_desc =}, DESC not tested here !!") continue @@ -260,5 +264,5 @@ def f(x, y, z): spl_kind = [False, True, True] array_input = True test_l2_projectors_mappings(Nel, p, spl_kind, array_input, do_plot=False, with_desc=False) - # test_l2_projectors_convergence(0, 1, True, do_plot=True) + test_l2_projectors_convergence(0, 1, True, do_plot=False) # test_l2_projectors_convergence(1, 1, False, do_plot=True)