From edf30aa4ce6429b9a9a7b35c5a2f0c13e0335e85 Mon Sep 17 00:00:00 2001 From: Pablo Brubeck Date: Thu, 9 Apr 2026 17:35:43 +0100 Subject: [PATCH 1/3] Fix ngsolve workflow --- .github/workflows/ngsPETSc.yml | 54 ++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 19 deletions(-) diff --git a/.github/workflows/ngsPETSc.yml b/.github/workflows/ngsPETSc.yml index 5818ae3..5ed434e 100644 --- a/.github/workflows/ngsPETSc.yml +++ b/.github/workflows/ngsPETSc.yml @@ -39,34 +39,50 @@ jobs: timeout-minutes: 30 steps: - - name: Check out repository code - uses: actions/checkout@v4 + - uses: actions/checkout@v4 + with: + # Download ngsPETSc into a subdirectory not called 'ngsPETSc' to make sure + # that the package installs correctly. Otherwise 'import ngsPETSc' may + # work even if the installation failed because it is a subdirectory. + path: ngspetsc-repo + + - name: Create virtual environment + # pass '--system-site-packages' so ngsolve can be found + run: python3 -m venv --system-site-packages venv-ngspetsc - name: Install ngsPETSc run: | - python -m pip install . + . venv-ngspetsc/bin/activate + pip install --no-deps './ngspetsc-repo' + pip list - name: Run test suite in serial run: | - pytest -v tests/test_env.py - pytest -v tests/test_vec.py - pytest -v tests/test_mat.py - pytest -v tests/test_plex.py - pytest -v tests/test_ksp.py - pytest -v tests/test_pc.py - pytest -v tests/test_eps.py - pytest -v tests/test_snes.py + . venv-ngspetsc/bin/activate + cd ngspetsc-repo + python -c "import petsc4py" + python -c "import ngsolve" + python -m pytest -v tests/test_env.py + #python -m pytest -v tests/test_vec.py + #python -m pytest -v tests/test_mat.py + #python -m pytest -v tests/test_plex.py + #python -m pytest -v tests/test_ksp.py + #python -m pytest -v tests/test_pc.py + #python -m pytest -v tests/test_eps.py + #python -m pytest -v tests/test_snes.py - name: Run test suite in parallel run: | - mpirun --allow-run-as-root -n 2 pytest -v --with-mpi tests/test_env.py - mpirun --allow-run-as-root -n 2 pytest -v --with-mpi tests/test_vec.py - mpirun --allow-run-as-root -n 2 pytest -v --with-mpi tests/test_mat.py - mpirun --allow-run-as-root -n 2 pytest -v --with-mpi tests/test_plex.py - mpirun --allow-run-as-root -n 2 pytest -v --with-mpi tests/test_ksp.py - mpirun --allow-run-as-root -n 2 pytest -v --with-mpi tests/test_pc.py - mpirun --allow-run-as-root -n 2 pytest -v --with-mpi tests/test_eps.py - mpirun --allow-run-as-root -n 2 pytest -v --with-mpi tests/test_snes.py + . venv-ngspetsc/bin/activate + cd ngspetsc-repo + mpirun --allow-run-as-root -n 2 python -m pytest -v --with-mpi tests/test_env.py + #mpirun --allow-run-as-root -n 2 python -m pytest -v --with-mpi tests/test_vec.py + #mpirun --allow-run-as-root -n 2 python -m pytest -v --with-mpi tests/test_mat.py + #mpirun --allow-run-as-root -n 2 python -m pytest -v --with-mpi tests/test_plex.py + #mpirun --allow-run-as-root -n 2 python -m pytest -v --with-mpi tests/test_ksp.py + #mpirun --allow-run-as-root -n 2 python -m pytest -v --with-mpi tests/test_pc.py + #mpirun --allow-run-as-root -n 2 python -m pytest -v --with-mpi tests/test_eps.py + #mpirun --allow-run-as-root -n 2 python -m pytest -v --with-mpi tests/test_snes.py firedrake: runs-on: ubuntu-latest From 203d666afa099e4d7103894e4867d90a3fd44ef0 Mon Sep 17 00:00:00 2001 From: Pablo Brubeck Date: Thu, 9 Apr 2026 17:35:43 +0100 Subject: [PATCH 2/3] Fix ngsolve workflow --- .github/workflows/ngsPETSc.yml | 56 ++++++++++++++++++++++------------ 1 file changed, 37 insertions(+), 19 deletions(-) diff --git a/.github/workflows/ngsPETSc.yml b/.github/workflows/ngsPETSc.yml index 5818ae3..f05541c 100644 --- a/.github/workflows/ngsPETSc.yml +++ b/.github/workflows/ngsPETSc.yml @@ -39,34 +39,52 @@ jobs: timeout-minutes: 30 steps: - - name: Check out repository code - uses: actions/checkout@v4 + - uses: actions/checkout@v4 + with: + # Download ngsPETSc into a subdirectory not called 'ngsPETSc' to make sure + # that the package installs correctly. Otherwise 'import ngsPETSc' may + # work even if the installation failed because it is a subdirectory. + path: ngspetsc-repo + + - name: Create virtual environment + # pass '--system-site-packages' so ngsolve can be found + run: python3 -m venv --system-site-packages venv-ngspetsc - name: Install ngsPETSc run: | - python -m pip install . + . venv-ngspetsc/bin/activate + pip install --no-deps './ngspetsc-repo' + pip list - name: Run test suite in serial run: | - pytest -v tests/test_env.py - pytest -v tests/test_vec.py - pytest -v tests/test_mat.py - pytest -v tests/test_plex.py - pytest -v tests/test_ksp.py - pytest -v tests/test_pc.py - pytest -v tests/test_eps.py - pytest -v tests/test_snes.py + . venv-ngspetsc/bin/activate + cd ngspetsc-repo + echo "import petsc4py" + python -c "import petsc4py" + echo "import ngsolve" + python -c "import ngsolve" + python -m pytest -v tests/test_env.py + python -m pytest -v tests/test_vec.py + python -m pytest -v tests/test_mat.py + python -m pytest -v tests/test_plex.py + python -m pytest -v tests/test_ksp.py + python -m pytest -v tests/test_pc.py + python -m pytest -v tests/test_eps.py + python -m pytest -v tests/test_snes.py - name: Run test suite in parallel run: | - mpirun --allow-run-as-root -n 2 pytest -v --with-mpi tests/test_env.py - mpirun --allow-run-as-root -n 2 pytest -v --with-mpi tests/test_vec.py - mpirun --allow-run-as-root -n 2 pytest -v --with-mpi tests/test_mat.py - mpirun --allow-run-as-root -n 2 pytest -v --with-mpi tests/test_plex.py - mpirun --allow-run-as-root -n 2 pytest -v --with-mpi tests/test_ksp.py - mpirun --allow-run-as-root -n 2 pytest -v --with-mpi tests/test_pc.py - mpirun --allow-run-as-root -n 2 pytest -v --with-mpi tests/test_eps.py - mpirun --allow-run-as-root -n 2 pytest -v --with-mpi tests/test_snes.py + . venv-ngspetsc/bin/activate + cd ngspetsc-repo + mpirun --allow-run-as-root -n 2 python -m pytest -v --with-mpi tests/test_env.py + mpirun --allow-run-as-root -n 2 python -m pytest -v --with-mpi tests/test_vec.py + mpirun --allow-run-as-root -n 2 python -m pytest -v --with-mpi tests/test_mat.py + mpirun --allow-run-as-root -n 2 python -m pytest -v --with-mpi tests/test_plex.py + mpirun --allow-run-as-root -n 2 python -m pytest -v --with-mpi tests/test_ksp.py + mpirun --allow-run-as-root -n 2 python -m pytest -v --with-mpi tests/test_pc.py + mpirun --allow-run-as-root -n 2 python -m pytest -v --with-mpi tests/test_eps.py + mpirun --allow-run-as-root -n 2 python -m pytest -v --with-mpi tests/test_snes.py firedrake: runs-on: ubuntu-latest From ed5320f18be7aa15c22adf266257f2bd771c7778 Mon Sep 17 00:00:00 2001 From: Pablo Brubeck Date: Thu, 9 Apr 2026 20:46:28 +0100 Subject: [PATCH 3/3] import inside the tests --- .github/workflows/ngsPETSc.yml | 4 ---- tests/test_env.py | 22 +++++++++++++++------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ngsPETSc.yml b/.github/workflows/ngsPETSc.yml index f05541c..821cfb3 100644 --- a/.github/workflows/ngsPETSc.yml +++ b/.github/workflows/ngsPETSc.yml @@ -60,10 +60,6 @@ jobs: run: | . venv-ngspetsc/bin/activate cd ngspetsc-repo - echo "import petsc4py" - python -c "import petsc4py" - echo "import ngsolve" - python -c "import ngsolve" python -m pytest -v tests/test_env.py python -m pytest -v tests/test_vec.py python -m pytest -v tests/test_mat.py diff --git a/tests/test_env.py b/tests/test_env.py index a3c9f65..f755f8a 100644 --- a/tests/test_env.py +++ b/tests/test_env.py @@ -3,29 +3,37 @@ In particular it will test for: petsc4py, PETSc, NGSolve and Netgen ''' -import petsc4py -from petsc4py import PETSc - -import ngsolve as ngs -from netgen.geom2d import unit_square -from ngsolve import x,y - def test_petsc4py(): ''' Testing that petsc4py can be imported correctly ''' + import petsc4py assert petsc4py.get_config() != "" + def test_petsc(): ''' Testing that PETSc can be imported correctly ''' + from petsc4py import PETSc assert PETSc.DECIDE == -1 + +def test_netgen(): + ''' + Testing that NGSolve can be imported correctly + ''' + from netgen.geom2d import unit_square + unit_square.GenerateMesh(maxh=0.1) + + def test_ngs(): ''' Testing that NGSolve can be imported correctly ''' + from netgen.geom2d import unit_square + import ngsolve as ngs + from ngsolve import x,y mesh = ngs.Mesh(unit_square.GenerateMesh(maxh=0.1)) coefficientFunction = x*(1-y) mip = mesh(0.2, 0.2)