From d392870902e85af0e96b99e1c096765827228751 Mon Sep 17 00:00:00 2001 From: Jorgen Schartum Dokken Date: Tue, 25 Aug 2026 09:29:27 +0200 Subject: [PATCH 01/23] Remove old CI and simplify existing CI --- .github/workflows/test_package_openmpi.yml | 88 -------------------- .github/workflows/test_redhat.yml | 93 ---------------------- .github/workflows/test_workflow.yml | 68 ++++++++++++++-- 3 files changed, 63 insertions(+), 186 deletions(-) delete mode 100644 .github/workflows/test_package_openmpi.yml delete mode 100644 .github/workflows/test_redhat.yml diff --git a/.github/workflows/test_package_openmpi.yml b/.github/workflows/test_package_openmpi.yml deleted file mode 100644 index 7c98a9a..0000000 --- a/.github/workflows/test_package_openmpi.yml +++ /dev/null @@ -1,88 +0,0 @@ -name: Test package with different mpi compilers - -on: - push: - branches: - - main - pull_request: - branches: - - main - - workflow_call: - workflow_dispatch: - schedule: - - cron: "0 8 * * *" - -jobs: - create-datasets: - uses: ./.github/workflows/create_legacy_data.yml - with: - artifact_name: "legacy_ompi" - - create-legacy-datasets: - uses: ./.github/workflows/create_legacy_checkpoint.yml - with: - artifact_name: "legacy_checkpoint_ompi" - - test-code: - runs-on: ubuntu-latest - needs: [create-datasets, create-legacy-datasets] - container: ${{ matrix.container }} - env: - DEB_PYTHON_INSTALL_LAYOUT: deb_system - PETSC_ARCH: "linux-gnu-real64-32" - OMPI_ALLOW_RUN_AS_ROOT: 1 - OMPI_ALLOW_RUN_AS_ROOT_CONFIRM: 1 - PRTE_MCA_rmaps_default_mapping_policy: :oversubscribe - working-directory: ./src - PIP_NO_BINARY: h5py - - strategy: - matrix: - adios2: ["v2.11.0", "v2.12.1", "default"] - container: - - ghcr.io/fenics/test-env:current-openmpi - - ghcr.io/fenics/test-env:current-mpich - steps: - - uses: actions/checkout@v7 - - - name: Update pip - run: python3 -m pip install --upgrade pip - - - name: Install build requirements - run: python3 -m pip install -r build-requirements.txt - - - name: Install DOLFINx - uses: jorgensd/actions/install-dolfinx@v0.4 - with: - adios2: ${{ matrix.adios2 }} - petsc_arch: ${{ env.PETSC_ARCH }} - dolfinx: main - basix: main - ufl: main - ffcx: main - working-directory: ${{ env.working-directory}} - - - name: Download legacy data - uses: actions/download-artifact@v8 - with: - name: legacy_ompi - path: ./legacy - - - name: Download legacy data - uses: actions/download-artifact@v8 - with: - name: legacy_checkpoint_ompi - path: ./legacy_checkpoint - - - name: Install package - run: | - HDF5_MPI=ON HDF5_PKGCONFIG_NAME="hdf5" python3 -m pip install h5py --no-build-isolation --no-binary=h5py - python3 -m pip install .[test] - - name: Run tests - run: | - coverage run --rcfile=.coveragerc -m mpi4py -m pytest -xvs ./tests/ - - - name: Run tests in parallel - run: | - mpirun -n 2 coverage run --rcfile=.coveragerc -m mpi4py -m pytest -xvs ./tests/ diff --git a/.github/workflows/test_redhat.yml b/.github/workflows/test_redhat.yml deleted file mode 100644 index e0a8b65..0000000 --- a/.github/workflows/test_redhat.yml +++ /dev/null @@ -1,93 +0,0 @@ -name: Test package with redhat - -on: - # push: - # branches: - # - main - # pull_request: - # branches: - # - main - - workflow_call: - workflow_dispatch: - # schedule: - # - cron: "0 8 * * *" - -jobs: - create-datasets: - uses: ./.github/workflows/create_legacy_data.yml - with: - artifact_name: "legacy_ompi" - - create-legacy-datasets: - uses: ./.github/workflows/create_legacy_checkpoint.yml - with: - artifact_name: "legacy_checkpoint_ompi" - - test-code: - runs-on: "ubuntu-latest" - needs: [create-datasets, create-legacy-datasets] - container: docker.io/fenicsproject/test-env:current-redhat - env: - DEB_PYTHON_INSTALL_LAYOUT: deb_system - PETSC_ARCH: "" - PETSC_DIR: "/usr/local/" - PYTHONPATH: "/usr/local/lib/:${PYTHONPATH}" - working-directory: ./src - - strategy: - matrix: - adios2: ["master"] - steps: - - uses: actions/checkout@v7 - - - name: Get pip flags based on version - id: python-version - shell: bash -el {0} - run: | - MODERN_PIP=$(python3 -c "import sys; t = sys.version_info >= (3, 11, 0); sys.stdout.write(str(t))") - if [ ${MODERN_PIP} == "True" ]; then - FLAGS="--break-system-packages" - else - FLAGS="" - python3 -m pip install --upgrade pip - fi - echo "PYTHON_FLAGS=${FLAGS}" >> "$GITHUB_OUTPUT" - - - name: Update pip - run: python3 -m pip install ${{ steps.python-version.outputs.PYTHON_FLAGS}} --upgrade pip setuptools - - - name: Install DOLFINx - uses: jorgensd/actions/install-dolfinx@v0.4 - with: - adios2: ${{ matrix.adios2 }} - petsc_arch: ${{ env.PETSC_ARCH }} - petsc_dir: ${{ env.PETSC_DIR }} - dolfinx: main - basix: main - ufl: main - ffcx: main - working-directory: ${{ env.working-directory}} - - - name: Download legacy data - uses: actions/download-artifact@v8 - with: - name: legacy_ompi - path: ./legacy - - - name: Download legacy data - uses: actions/download-artifact@v8 - with: - name: legacy_checkpoint_ompi - path: ./legacy_checkpoint - - - name: Install package - run: python3 -m pip install ${{ steps.python-version.outputs.PYTHON_FLAGS}} --check-build-dependencies .[test] - - - name: Run tests - run: | - coverage run --rcfile=.coveragerc -m mpi4py -m pytest -xvs ./tests - - - name: Run tests in parallel - run: | - mpirun -n 4 coverage run --rcfile=.coveragerc -m mpi4py -m pytest -xvs ./tests diff --git a/.github/workflows/test_workflow.yml b/.github/workflows/test_workflow.yml index 7849337..e959046 100644 --- a/.github/workflows/test_workflow.yml +++ b/.github/workflows/test_workflow.yml @@ -1,17 +1,47 @@ -name: Test +name: Test package on: workflow_call: inputs: - dolfinx_tag: + tag: + description: "Tag of DOLFINx docker image" + default: "nightly" required: true type: string + workflow_dispatch: + inputs: + tag: + description: "Tag of DOLFINx docker image" + default: "nightly" + required: true + type: string +env: + DEB_PYTHON_INSTALL_LAYOUT: deb_system + DEFAULT_TAG: nightly + HDF5_MPI: "ON" + HDF5_INCLUDEDIR: "/usr/include/hdf5/openmpi" + H5PY_SETUP_REQUIRES: 0 + OMPI_ALLOW_RUN_AS_ROOT: 1 + OMPI_ALLOW_RUN_AS_ROOT_CONFIRM: 1 + PRTE_MCA_rmaps_default_mapping_policy: :oversubscribe jobs: + get_image_tag: + runs-on: ubuntu-latest + outputs: + image: ${{ steps.docker_tag.outputs.image }} + steps: + - id: docker_tag + run: echo "image=${{ inputs.tag || env.DEFAULT_TAG }}" >> $GITHUB_OUTPUT + test-code: runs-on: ubuntu-24.04 # The container tag is now dynamic based on the input passed by the caller - container: ghcr.io/fenics/dolfinx/dolfinx:${{ inputs.dolfinx_tag }} + container: ghcr.io/fenics/test-env:current + needs: + [get_image_tag] + env: + working-directory: ./src steps: - uses: actions/checkout@v7 @@ -35,9 +65,37 @@ jobs: name: legacy_checkpoint_mpich path: ./legacy_checkpoint + + + - name: Install DOLFINx (stable) + if: needs.get_image_tag.outputs.image == 'stable' + uses: jorgensd/actions/install-dolfinx@v0.4 + with: + adios2: v2.12.1 + petsc_arch: linux-gnu-real64-32 + dolfinx: release + basix: release + ufl: release + ffcx: release + working-directory: ${{ env.working-directory}} + + - name: Install DOLFINx (nightly) + if: needs.get_image_tag.outputs.image == 'nightly' + uses: jorgensd/actions/install-dolfinx@v0.4 + with: + adios2: v2.12.1 + petsc_arch: linux-gnu-real64-32 + working-directory: ${{ env.working-directory}} + + - name: Configure HDF5 MPI Environment + run: | + # Evaluate architecture dynamically and write to GITHUB_ENV + ARCH_TRIPLET=$(gcc -print-multiarch) + echo "HDF5_LIBDIR=/usr/lib/${ARCH_TRIPLET}/hdf5/openmpi" >> $GITHUB_ENV + - name: Install package run: | - HDF5_MPI=ON HDF5_PKGCONFIG_NAME="hdf5" python3 -m pip install h5py --no-build-isolation --no-binary=h5py + python3 -m pip install h5py --no-build-isolation --no-binary=h5py python3 -m pip install .[test] - name: Show adios2 version @@ -65,6 +123,6 @@ jobs: - name: Upload coverage report uses: actions/upload-artifact@v7 with: - name: code-coverage-report-${{ inputs.dolfinx_tag }} + name: code-coverage-report-${{ inputs.tag }} path: htmlcov if-no-files-found: error From 0831bead8dda38860068e02f02bfb44d89eafe95 Mon Sep 17 00:00:00 2001 From: Jorgen Schartum Dokken Date: Tue, 25 Aug 2026 09:39:00 +0200 Subject: [PATCH 02/23] Fix tag --- .github/workflows/test_dolfinx_versions.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_dolfinx_versions.yml b/.github/workflows/test_dolfinx_versions.yml index 56441dd..c9233ab 100644 --- a/.github/workflows/test_dolfinx_versions.yml +++ b/.github/workflows/test_dolfinx_versions.yml @@ -31,4 +31,4 @@ jobs: # Call the reusable workflow uses: ./.github/workflows/test_workflow.yml with: - dolfinx_tag: ${{ matrix.tag }} + tag: ${{ matrix.tag }} From 10675148a6caf219ddd30fcb8c980b776e53cffd Mon Sep 17 00:00:00 2001 From: Jorgen Schartum Dokken Date: Tue, 25 Aug 2026 10:32:55 +0200 Subject: [PATCH 03/23] use mpicc --- .github/workflows/test_workflow.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test_workflow.yml b/.github/workflows/test_workflow.yml index e959046..422257c 100644 --- a/.github/workflows/test_workflow.yml +++ b/.github/workflows/test_workflow.yml @@ -24,6 +24,8 @@ env: OMPI_ALLOW_RUN_AS_ROOT: 1 OMPI_ALLOW_RUN_AS_ROOT_CONFIRM: 1 PRTE_MCA_rmaps_default_mapping_policy: :oversubscribe + CC: mpicc + CXX: mpicxx jobs: get_image_tag: From fb9a8330299016fa2509a7b57ee3f790fd7728c9 Mon Sep 17 00:00:00 2001 From: Jorgen Schartum Dokken Date: Tue, 25 Aug 2026 11:56:38 +0200 Subject: [PATCH 04/23] No build isolation --- .github/workflows/test_workflow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_workflow.yml b/.github/workflows/test_workflow.yml index 422257c..b8e353e 100644 --- a/.github/workflows/test_workflow.yml +++ b/.github/workflows/test_workflow.yml @@ -98,7 +98,7 @@ jobs: - name: Install package run: | python3 -m pip install h5py --no-build-isolation --no-binary=h5py - python3 -m pip install .[test] + python3 -m pip install .[test] --no-build-isolation - name: Show adios2 version run: python3 -c "import adios2; print(adios2.__version__)" From 45e253caf18fa16e8806cc241682945bbd2ec38e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Schartum=20Dokken?= Date: Tue, 25 Aug 2026 12:17:34 +0200 Subject: [PATCH 05/23] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jørgen Schartum Dokken --- .github/workflows/test_workflow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_workflow.yml b/.github/workflows/test_workflow.yml index b8e353e..0b54e8b 100644 --- a/.github/workflows/test_workflow.yml +++ b/.github/workflows/test_workflow.yml @@ -52,7 +52,7 @@ jobs: run: python3 -m pip install --upgrade pip - name: Install build requirements - run: python3 -m pip install -r build-requirements.txt + run: python3 -m pip install -r build-requirements.txt --no-build-isolation # Note: We assume the caller workflow has already uploaded these artifacts - name: Download legacy mpich data From b791152f05ccb1e276ca361bba1821d442dbef26 Mon Sep 17 00:00:00 2001 From: Jorgen Schartum Dokken Date: Tue, 25 Aug 2026 12:59:23 +0200 Subject: [PATCH 06/23] Use build group to remove separate file --- .github/workflows/test_workflow.yml | 3 +- build-requirements.txt | 5 --- pyproject.toml | 49 +++++++++++++++++++++-------- 3 files changed, 38 insertions(+), 19 deletions(-) delete mode 100644 build-requirements.txt diff --git a/.github/workflows/test_workflow.yml b/.github/workflows/test_workflow.yml index 0b54e8b..8a969af 100644 --- a/.github/workflows/test_workflow.yml +++ b/.github/workflows/test_workflow.yml @@ -52,7 +52,8 @@ jobs: run: python3 -m pip install --upgrade pip - name: Install build requirements - run: python3 -m pip install -r build-requirements.txt --no-build-isolation + run: python3 -m pip install --group build --no-build-isolation + # Note: We assume the caller workflow has already uploaded these artifacts - name: Download legacy mpich data diff --git a/build-requirements.txt b/build-requirements.txt deleted file mode 100644 index a58cd3b..0000000 --- a/build-requirements.txt +++ /dev/null @@ -1,5 +0,0 @@ -scikit-build-core[pyproject]>=0.11.0 -nanobind>=1.3.2 -setuptools>=77.0.3 -packaging>=24.2 -pkgconfig diff --git a/pyproject.toml b/pyproject.toml index ccb8852..ab83e21 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,12 @@ -[build-system] # Require setuptool version due to https://github.com/pypa/setuptools/issues/2938 -requires = ["setuptools>=61.0.0", "wheel"] +[build-system] +requires = [ + "scikit-build-core[pyproject]>=0.11.0", + "nanobind>=1.3.2,<3.0", # Temporary cap as 0.11 seems to struggle with nanobind 3.0.0 + "setuptools>=77.0.3", + "packaging>=24.2", + "pkgconfig" +] +build-backend = "scikit_build_core.build" [project] name = "io4dolfinx" @@ -14,6 +21,20 @@ readme = "README.md" dependencies = ["fenics-dolfinx>=0.10.0", "packaging"] [project.optional-dependencies] +h5py = ["h5py"] +pyvista = ["pyvista"] +xdmf = ["h5py"] +exodus = ["netcdf4"] + +[dependency-groups] +build = [ + "scikit-build-core[pyproject]>=0.11.0", + "nanobind>=1.3.2,<3.0", + "setuptools>=77.0.3", + "packaging>=24.2", + "pkgconfig" +] + test = [ "pytest", "coverage", @@ -22,23 +43,28 @@ test = [ "io4dolfinx[pyvista]", "io4dolfinx[xdmf]" ] -dev = ["pdbpp", "ipython", "mypy", "ruff"] -h5py = ["h5py"] -pyvista = ["pyvista"] -xdmf = ["h5py"] -exodus = ["netcdf4"] +dev = [ + "pdbpp", + "ipython", + "mypy", + "ruff" +] docs = [ "jupyter-book<2.0.0", "ipyparallel", "ipywidgets", "jupytext", - "ipykernel<7.0.0", # Note: Remove once https://github.com/ipython/ipykernel/issues/1450 is in a release + "ipykernel", "sphinx-codeautolink", "io4dolfinx[h5py]", "io4dolfinx[pyvista]", "sphinx_external_toc<1.1.0", ] -all = ["io4dolfinx[test,dev,docs]"] +all = [ + { include-group = "test" }, + { include-group = "dev" }, + { include-group = "docs" } +] [tool.pytest.ini_options] addopts = ["--import-mode=importlib"] @@ -67,7 +93,6 @@ select = [ "I001", ] - [tool.ruff.lint.isort] known-first-party = ["io4dolfinx"] known-third-party = [ @@ -91,7 +116,6 @@ section-order = [ [tool.ruff.lint.isort.sections] "mpi" = ["mpi4py", "petsc4py"] - [tool.bumpversion] allow_dirty = false commit = true @@ -102,8 +126,7 @@ tag_name = "v{new_version}" tag_message = "Bump version: {current_version} → {new_version}" current_version = "1.3.0" - [[tool.bumpversion.files]] filename = "pyproject.toml" search = 'version = "{current_version}"' -replace = 'version = "{new_version}"' +replace = 'version = "{new_version}"' \ No newline at end of file From a011b5d38429ccb4478d9d0a02d239905fec3877 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 25 Aug 2026 10:59:35 +0000 Subject: [PATCH 07/23] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- pyproject.toml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index ab83e21..c99885a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -44,9 +44,9 @@ test = [ "io4dolfinx[xdmf]" ] dev = [ - "pdbpp", - "ipython", - "mypy", + "pdbpp", + "ipython", + "mypy", "ruff" ] docs = [ @@ -129,4 +129,4 @@ current_version = "1.3.0" [[tool.bumpversion.files]] filename = "pyproject.toml" search = 'version = "{current_version}"' -replace = 'version = "{new_version}"' \ No newline at end of file +replace = 'version = "{new_version}"' From 4b1e35b4d22235b18fc7fc27210f9626e6eebb5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Schartum=20Dokken?= Date: Tue, 25 Aug 2026 13:51:06 +0200 Subject: [PATCH 08/23] Update build_docs.yml --- .github/workflows/build_docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_docs.yml b/.github/workflows/build_docs.yml index 8745acd..f1abcc1 100644 --- a/.github/workflows/build_docs.yml +++ b/.github/workflows/build_docs.yml @@ -50,7 +50,7 @@ jobs: run: python3 -m pip install --upgrade pip setuptools - name: Install dependencies - run: python3 -m pip install --no-binary=h5py -e ".[docs]" + run: python3 -m pip install --no-binary=h5py -e ".[docs]" --no-build-isolation - name: Build docs run: jupyter book build . From 44b0f18a0a0bcd2e6f3588a009df819d4510ccf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Schartum=20Dokken?= Date: Tue, 25 Aug 2026 13:52:26 +0200 Subject: [PATCH 09/23] Add --no-build-isolation to pip install command --- .github/workflows/check_formatting.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check_formatting.yml b/.github/workflows/check_formatting.yml index afe2700..876c846 100644 --- a/.github/workflows/check_formatting.yml +++ b/.github/workflows/check_formatting.yml @@ -47,7 +47,7 @@ jobs: run: python3 -m pip install --upgrade pip setuptools - name: Install code - run: python3 -m pip install .[dev] + run: python3 -m pip install .[dev] --no-build-isolation - name: Check code formatting with ruff run: | From 93c6c6ca28466858c49025b8c4847a5827312caf Mon Sep 17 00:00:00 2001 From: Jorgen Schartum Dokken Date: Tue, 25 Aug 2026 14:00:01 +0200 Subject: [PATCH 10/23] Various dep updates --- .github/workflows/build_docs.yml | 9 +++++---- .github/workflows/check_formatting.yml | 10 ++++++---- .github/workflows/test_workflow.yml | 3 ++- docs/testing.md | 3 ++- pyproject.toml | 7 ++++--- 5 files changed, 19 insertions(+), 13 deletions(-) diff --git a/.github/workflows/build_docs.yml b/.github/workflows/build_docs.yml index f1abcc1..61123c6 100644 --- a/.github/workflows/build_docs.yml +++ b/.github/workflows/build_docs.yml @@ -46,11 +46,12 @@ jobs: # This action sets the current path to the root of your github repo - uses: actions/checkout@v7 - - name: Update pip - run: python3 -m pip install --upgrade pip setuptools - + - name: Update pip and extra deps + run: | + python3 -m pip install --upgrade pip setuptools + python3 -m pip install . --group docs --no-build-isolation - name: Install dependencies - run: python3 -m pip install --no-binary=h5py -e ".[docs]" --no-build-isolation + run: python3 -m pip install --no-binary=h5py -e . --no-build-isolation - name: Build docs run: jupyter book build . diff --git a/.github/workflows/check_formatting.yml b/.github/workflows/check_formatting.yml index 876c846..12a809c 100644 --- a/.github/workflows/check_formatting.yml +++ b/.github/workflows/check_formatting.yml @@ -43,11 +43,13 @@ jobs: steps: - uses: actions/checkout@v7 - - name: Update pip - run: python3 -m pip install --upgrade pip setuptools - + - name: Update pip and install build deps + run: | + python3 -m pip install --upgrade pip setuptools + python3 -m pip install . --group dev --no-build-isolation + - name: Install code - run: python3 -m pip install .[dev] --no-build-isolation + run: python3 -m pip install . --no-build-isolation - name: Check code formatting with ruff run: | diff --git a/.github/workflows/test_workflow.yml b/.github/workflows/test_workflow.yml index 8a969af..78cf87f 100644 --- a/.github/workflows/test_workflow.yml +++ b/.github/workflows/test_workflow.yml @@ -99,7 +99,8 @@ jobs: - name: Install package run: | python3 -m pip install h5py --no-build-isolation --no-binary=h5py - python3 -m pip install .[test] --no-build-isolation + python3 -m pip install . --group test --no-build-isolation + python3 -m pip install . --no-build-isolation - name: Show adios2 version run: python3 -c "import adios2; print(adios2.__version__)" diff --git a/docs/testing.md b/docs/testing.md index 7751c05..e7cbe20 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -21,7 +21,8 @@ Install the library with the optional `test` dependencies to ensure you have packages like `pytest`, `coverage`, and `ipyparallel` ```bash -python3 -m pip install ".[test]" +python3 -m pip install . --group test --no-build-isolation +python3 -m pip install -e . --no-build-isolation ``` ### Running Tests diff --git a/pyproject.toml b/pyproject.toml index c99885a..232fc4c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,12 +1,13 @@ [build-system] requires = [ - "scikit-build-core[pyproject]>=0.11.0", - "nanobind>=1.3.2,<3.0", # Temporary cap as 0.11 seems to struggle with nanobind 3.0.0 "setuptools>=77.0.3", + "wheel", + "scikit-build-core[pyproject]>=0.11.0", + "nanobind>=1.3.2,<3.0", # Temporary cap on nanobind for stable dolfinx "packaging>=24.2", "pkgconfig" ] -build-backend = "scikit_build_core.build" +build-backend = "setuptools.build_meta" [project] name = "io4dolfinx" From cc6758e777e02f2b308f76a80c6317af2d0fb12c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 25 Aug 2026 12:00:14 +0000 Subject: [PATCH 11/23] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .github/workflows/check_formatting.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check_formatting.yml b/.github/workflows/check_formatting.yml index 12a809c..96183fc 100644 --- a/.github/workflows/check_formatting.yml +++ b/.github/workflows/check_formatting.yml @@ -47,7 +47,7 @@ jobs: run: | python3 -m pip install --upgrade pip setuptools python3 -m pip install . --group dev --no-build-isolation - + - name: Install code run: python3 -m pip install . --no-build-isolation From c49f329cd083f81b5e3d5212cc72d4c207202ac6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Schartum=20Dokken?= Date: Tue, 25 Aug 2026 14:16:39 +0200 Subject: [PATCH 12/23] Refactor pip install commands in build_docs.yml Updated pip installation commands for h5py and docs group. --- .github/workflows/build_docs.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_docs.yml b/.github/workflows/build_docs.yml index 61123c6..18615f1 100644 --- a/.github/workflows/build_docs.yml +++ b/.github/workflows/build_docs.yml @@ -49,9 +49,11 @@ jobs: - name: Update pip and extra deps run: | python3 -m pip install --upgrade pip setuptools - python3 -m pip install . --group docs --no-build-isolation + python3 -m pip install --no-binary=h5py h5py + python3 -m pip install . --group docs + - name: Install dependencies - run: python3 -m pip install --no-binary=h5py -e . --no-build-isolation + run: python3 -m pip install -e . --no-build-isolation - name: Build docs run: jupyter book build . From fc8fa999e7fa22796d542309e2500065afe4a284 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 25 Aug 2026 12:16:49 +0000 Subject: [PATCH 13/23] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .github/workflows/build_docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_docs.yml b/.github/workflows/build_docs.yml index 18615f1..8f2ee01 100644 --- a/.github/workflows/build_docs.yml +++ b/.github/workflows/build_docs.yml @@ -51,7 +51,7 @@ jobs: python3 -m pip install --upgrade pip setuptools python3 -m pip install --no-binary=h5py h5py python3 -m pip install . --group docs - + - name: Install dependencies run: python3 -m pip install -e . --no-build-isolation From b74fec68cf4bb7eae708b28ceadbda99ba7dfbd8 Mon Sep 17 00:00:00 2001 From: Jorgen Schartum Dokken Date: Tue, 25 Aug 2026 14:18:17 +0200 Subject: [PATCH 14/23] Try more --- .github/workflows/test_workflow.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test_workflow.yml b/.github/workflows/test_workflow.yml index 78cf87f..6a29ed5 100644 --- a/.github/workflows/test_workflow.yml +++ b/.github/workflows/test_workflow.yml @@ -68,8 +68,6 @@ jobs: name: legacy_checkpoint_mpich path: ./legacy_checkpoint - - - name: Install DOLFINx (stable) if: needs.get_image_tag.outputs.image == 'stable' uses: jorgensd/actions/install-dolfinx@v0.4 @@ -98,8 +96,8 @@ jobs: - name: Install package run: | - python3 -m pip install h5py --no-build-isolation --no-binary=h5py - python3 -m pip install . --group test --no-build-isolation + python3 -m pip install h5py --no-binary=h5py + python3 -m pip install --group dev --group test python3 -m pip install . --no-build-isolation - name: Show adios2 version From 23a0e4381a7fe342d1a1fa509baebf94a4f054c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Schartum=20Dokken?= Date: Tue, 25 Aug 2026 14:51:30 +0200 Subject: [PATCH 15/23] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jørgen Schartum Dokken --- .github/workflows/test_workflow.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test_workflow.yml b/.github/workflows/test_workflow.yml index 6a29ed5..6d829aa 100644 --- a/.github/workflows/test_workflow.yml +++ b/.github/workflows/test_workflow.yml @@ -96,7 +96,8 @@ jobs: - name: Install package run: | - python3 -m pip install h5py --no-binary=h5py + python3 -m pip install "Cython>=3.0.11" "pkgconfig>=1.5.5" + python3 -m pip install h5py --no-binary=h5py --no-build-isolation python3 -m pip install --group dev --group test python3 -m pip install . --no-build-isolation From 5f40e76b7be222ab82e51e42b2bd5fb1f039f7ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Schartum=20Dokken?= Date: Tue, 25 Aug 2026 15:30:55 +0200 Subject: [PATCH 16/23] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jørgen Schartum Dokken --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 232fc4c..9bba01a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ requires = [ "setuptools>=77.0.3", "wheel", "scikit-build-core[pyproject]>=0.11.0", - "nanobind>=1.3.2,<3.0", # Temporary cap on nanobind for stable dolfinx + "nanobind>=1.3.2,<2.15", # Temporary cap on nanobind for stable dolfinx "packaging>=24.2", "pkgconfig" ] From 4c958b0d1fb20691fc293669278b1a1daa9921e4 Mon Sep 17 00:00:00 2001 From: Henrik Finsberg Date: Mon, 31 Aug 2026 10:24:56 +0000 Subject: [PATCH 17/23] Require python3.12 and fix create_cell_partitioner after change in https://github.com/FEniCS/dolfinx/pull/4403/ --- pyproject.toml | 1 + src/io4dolfinx/checkpointing.py | 41 ++++++++++++++++++++------------- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 9bba01a..fb1bed6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,6 +19,7 @@ authors = [ ] license = { file = "LICENSE" } readme = "README.md" +requires-python = ">=3.12" dependencies = ["fenics-dolfinx>=0.10.0", "packaging"] [project.optional-dependencies] diff --git a/src/io4dolfinx/checkpointing.py b/src/io4dolfinx/checkpointing.py index a128ef6..e20b2ec 100644 --- a/src/io4dolfinx/checkpointing.py +++ b/src/io4dolfinx/checkpointing.py @@ -6,6 +6,7 @@ from __future__ import annotations +import inspect import logging import typing from pathlib import Path @@ -458,7 +459,7 @@ def read_mesh( [MPI.Comm, int, list[dolfinx.mesh.CellType], list[npt.NDArray[np.int64]]], dolfinx.cpp.graph.AdjacencyList_int32, ] - partitioner: PartitionerType + partitioner: dolfinx.mesh.PartitioningFunc | PartitionerType if (partition_graph := dist_in_data.partition_graph) is not None: def _custom_partitioner( @@ -478,21 +479,28 @@ def _custom_partitioner( partitioner = _custom_partitioner else: - try: - partitioner = dolfinx.cpp.mesh.create_cell_partitioner( - ghost_mode, max_facet_to_cell_links=max_facet_to_cell_links - ) - except TypeError: - partitioner = dolfinx.cpp.mesh.create_cell_partitioner(ghost_mode) # type: ignore[call-overload] - - # Should change to the commented code below when we require python - # minimum version to be >=3.12 see https://github.com/python/cpython/pull/116198 - # import inspect - # sig = inspect.signature(dolfinx.mesh.create_cell_partitioner) - # part_kwargs = {} - # if "max_facet_to_cell_links" in list(sig.parameters.keys()): - # part_kwargs["max_facet_to_cell_links"] = max_facet_to_cell_links - # partitioner = dolfinx.cpp.mesh.create_cell_partitioner(ghost_mode, **part_kwargs) + if not hasattr(dolfinx.mesh, "create_cell_partitioner"): + partitioner = dolfinx.graph.partitioner() + else: + sig = inspect.signature(dolfinx.mesh.create_cell_partitioner) + part_kwargs = {} + + if "max_facet_to_cell_links" in sig.parameters: + part_kwargs["max_facet_to_cell_links"] = max_facet_to_cell_links + + partitioner = dolfinx.mesh.create_cell_partitioner(ghost_mode, **part_kwargs) + + mesh_args: dict[str, Any] = {} + mesh_sig = inspect.signature(dolfinx.mesh.create_mesh) + if "max_facet_to_cell_links" in mesh_sig.parameters: + mesh_args["max_facet_to_cell_links"] = max_facet_to_cell_links + if "ghost_mode" in mesh_sig.parameters: + mesh_args["ghost_mode"] = ghost_mode + # TODO: Add more options here later + if "cell_weights" in mesh_sig.parameters: + mesh_args["cell_weights"] = None # No cell weights provided, default to None + if "num_threads" in mesh_sig.parameters: + mesh_args["num_threads"] = 1 # Default to 1 thread, can be adjusted if needed return dolfinx.mesh.create_mesh( comm, @@ -500,6 +508,7 @@ def _custom_partitioner( x=dist_in_data.x, e=domain, partitioner=partitioner, + **mesh_args, ) From 21d127565fe3552d6b87b5cdd706914b6e1aeb12 Mon Sep 17 00:00:00 2001 From: Henrik Finsberg Date: Mon, 31 Aug 2026 11:20:40 +0000 Subject: [PATCH 18/23] Attempt to fix custom partitioner --- src/io4dolfinx/checkpointing.py | 57 ++++++++++++++++++++++++--------- 1 file changed, 41 insertions(+), 16 deletions(-) diff --git a/src/io4dolfinx/checkpointing.py b/src/io4dolfinx/checkpointing.py index e20b2ec..3616ec1 100644 --- a/src/io4dolfinx/checkpointing.py +++ b/src/io4dolfinx/checkpointing.py @@ -19,6 +19,7 @@ import numpy as np import numpy.typing as npt import ufl +from packaging.version import Version from . import compat from .backends import FileMode, ReadMode, get_backend @@ -461,23 +462,47 @@ def read_mesh( ] partitioner: dolfinx.mesh.PartitioningFunc | PartitionerType if (partition_graph := dist_in_data.partition_graph) is not None: + if Version(dolfinx.__version__) <= Version("0.11"): + + def _custom_partitioner_old( + comm: MPI.Comm, + nparts: int, + cell_types: list[dolfinx.mesh.CellType], + local_graph: list[npt.NDArray[np.int64]], + *args, + **kwargs, + ) -> dolfinx.cpp.graph.AdjacencyList_int32: + assert len(local_graph[0]) % (len(partition_graph.offsets) - 1) == 0 + if hasattr(partition_graph, "_cpp_object"): + cpp_obj = partition_graph._cpp_object + assert isinstance(cpp_obj, dolfinx.cpp.graph.AdjacencyList_int32) + return cpp_obj + else: + assert isinstance(partition_graph, dolfinx.cpp.graph.AdjacencyList_int32) + return partition_graph + + partitioner = _custom_partitioner_old + else: - def _custom_partitioner( - comm: MPI.Comm, - nparts: int, - cell_types: list[dolfinx.mesh.CellType], - local_graph: list[npt.NDArray[np.int64]], - ) -> dolfinx.cpp.graph.AdjacencyList_int32: - assert len(local_graph[0]) % (len(partition_graph.offsets) - 1) == 0 - if hasattr(partition_graph, "_cpp_object"): - cpp_obj = partition_graph._cpp_object - assert isinstance(cpp_obj, dolfinx.cpp.graph.AdjacencyList_int32) - return cpp_obj - else: - assert isinstance(partition_graph, dolfinx.cpp.graph.AdjacencyList_int32) - return partition_graph - - partitioner = _custom_partitioner + def _custom_partitioner_new( + comm: MPI.Comm, + n: int, + dual_graph: dolfinx.cpp.graph.AdjacencyList_int64, + cell_weights: Any | None, + edge_weights: Any | None, + ghosting: bool, + ) -> dolfinx.cpp.graph.AdjacencyList_int32: + # FIXME: Add some asserts here? + # assert len(dual_graph[0]) % (len(partition_graph.offsets) - 1) == 0 + if hasattr(partition_graph, "_cpp_object"): + cpp_obj = partition_graph._cpp_object + assert isinstance(cpp_obj, dolfinx.cpp.graph.AdjacencyList_int32) + return cpp_obj + else: + assert isinstance(partition_graph, dolfinx.cpp.graph.AdjacencyList_int32) + return partition_graph + + partitioner = _custom_partitioner_new else: if not hasattr(dolfinx.mesh, "create_cell_partitioner"): partitioner = dolfinx.graph.partitioner() From 6e6f155a41e4e595c2f02da73cad103330407a0f Mon Sep 17 00:00:00 2001 From: Henrik Finsberg Date: Mon, 31 Aug 2026 16:58:23 +0200 Subject: [PATCH 19/23] Try with adios version default --- .github/workflows/test_workflow.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test_workflow.yml b/.github/workflows/test_workflow.yml index 6d829aa..11e0728 100644 --- a/.github/workflows/test_workflow.yml +++ b/.github/workflows/test_workflow.yml @@ -72,7 +72,7 @@ jobs: if: needs.get_image_tag.outputs.image == 'stable' uses: jorgensd/actions/install-dolfinx@v0.4 with: - adios2: v2.12.1 + adios2: default petsc_arch: linux-gnu-real64-32 dolfinx: release basix: release @@ -84,7 +84,7 @@ jobs: if: needs.get_image_tag.outputs.image == 'nightly' uses: jorgensd/actions/install-dolfinx@v0.4 with: - adios2: v2.12.1 + adios2: default petsc_arch: linux-gnu-real64-32 working-directory: ${{ env.working-directory}} From 1e48bc8fe68f38c9fe5e079009b692bb366ac705 Mon Sep 17 00:00:00 2001 From: Henrik Finsberg Date: Wed, 2 Sep 2026 11:02:54 +0000 Subject: [PATCH 20/23] Add hack to costrain nanobind on stable (for now) --- .github/workflows/test_workflow.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/test_workflow.yml b/.github/workflows/test_workflow.yml index 11e0728..54fc93c 100644 --- a/.github/workflows/test_workflow.yml +++ b/.github/workflows/test_workflow.yml @@ -68,6 +68,20 @@ jobs: name: legacy_checkpoint_mpich path: ./legacy_checkpoint + # DOLFINx 0.11.x (release branch) passes a cffi cdata object where the + # nanobind bindings expect a C++ integer. nanobind 2.14.0 requires the + # `__index__` protocol for implicit integer conversion, which cffi cdata + # does not implement, so every `dolfinx.fem.form` call fails with + # "TypeError: __init__(): incompatible function arguments". + # Fixed on DOLFINx main by https://github.com/FEniCS/dolfinx/pull/4371, + # not (yet) backported to the release branch, so constrain nanobind when + # building the stable bindings. Remove once the fix is in a release. + - name: Constrain nanobind for stable DOLFINx + if: needs.get_image_tag.outputs.image == 'stable' + run: | + echo "nanobind<2.14" > "$GITHUB_WORKSPACE/constraints.txt" + echo "PIP_CONSTRAINT=$GITHUB_WORKSPACE/constraints.txt" >> $GITHUB_ENV + - name: Install DOLFINx (stable) if: needs.get_image_tag.outputs.image == 'stable' uses: jorgensd/actions/install-dolfinx@v0.4 From 32b640499bfc94c420104fe6feae41aad1fa23e9 Mon Sep 17 00:00:00 2001 From: Henrik Finsberg Date: Wed, 2 Sep 2026 12:59:31 +0000 Subject: [PATCH 21/23] Fix partitioner --- src/io4dolfinx/checkpointing.py | 70 +++++++++++---------------------- 1 file changed, 23 insertions(+), 47 deletions(-) diff --git a/src/io4dolfinx/checkpointing.py b/src/io4dolfinx/checkpointing.py index 3616ec1..de4f8c0 100644 --- a/src/io4dolfinx/checkpointing.py +++ b/src/io4dolfinx/checkpointing.py @@ -19,7 +19,6 @@ import numpy as np import numpy.typing as npt import ufl -from packaging.version import Version from . import compat from .backends import FileMode, ReadMode, get_backend @@ -456,53 +455,30 @@ def read_mesh( dtype=dist_in_data.x.dtype, ) domain = ufl.Mesh(element) - PartitionerType = Callable[ - [MPI.Comm, int, list[dolfinx.mesh.CellType], list[npt.NDArray[np.int64]]], - dolfinx.cpp.graph.AdjacencyList_int32, - ] - partitioner: dolfinx.mesh.PartitioningFunc | PartitionerType + # `dolfinx.mesh.PartitioningFunc` is not available in all supported + # versions of DOLFINx, and the accepted callback signature varies (see + # below), so type the callback permissively. + partitioner: Callable[..., dolfinx.cpp.graph.AdjacencyList_int32] if (partition_graph := dist_in_data.partition_graph) is not None: - if Version(dolfinx.__version__) <= Version("0.11"): - - def _custom_partitioner_old( - comm: MPI.Comm, - nparts: int, - cell_types: list[dolfinx.mesh.CellType], - local_graph: list[npt.NDArray[np.int64]], - *args, - **kwargs, - ) -> dolfinx.cpp.graph.AdjacencyList_int32: - assert len(local_graph[0]) % (len(partition_graph.offsets) - 1) == 0 - if hasattr(partition_graph, "_cpp_object"): - cpp_obj = partition_graph._cpp_object - assert isinstance(cpp_obj, dolfinx.cpp.graph.AdjacencyList_int32) - return cpp_obj - else: - assert isinstance(partition_graph, dolfinx.cpp.graph.AdjacencyList_int32) - return partition_graph - - partitioner = _custom_partitioner_old - else: - - def _custom_partitioner_new( - comm: MPI.Comm, - n: int, - dual_graph: dolfinx.cpp.graph.AdjacencyList_int64, - cell_weights: Any | None, - edge_weights: Any | None, - ghosting: bool, - ) -> dolfinx.cpp.graph.AdjacencyList_int32: - # FIXME: Add some asserts here? - # assert len(dual_graph[0]) % (len(partition_graph.offsets) - 1) == 0 - if hasattr(partition_graph, "_cpp_object"): - cpp_obj = partition_graph._cpp_object - assert isinstance(cpp_obj, dolfinx.cpp.graph.AdjacencyList_int32) - return cpp_obj - else: - assert isinstance(partition_graph, dolfinx.cpp.graph.AdjacencyList_int32) - return partition_graph - - partitioner = _custom_partitioner_new + # The arguments DOLFINx passes to a partitioner callback have changed + # over time: 0.11 calls it with + # ``(comm, nparts, cell_types, local_graph)``, while newer versions call + # it with ``(comm, nparts, dual_graph, cell_weights, edge_weights, + # ghosting)`` (see https://github.com/FEniCS/dolfinx/pull/4403). + # We read the partitioning from file, so the returned graph does not + # depend on any of these arguments. Accept them all and stay agnostic to + # the calling convention rather than branching on `dolfinx.__version__`, + # which does not distinguish pre-releases and post-releases reliably. + def _custom_partitioner(*args: Any, **kwargs: Any) -> dolfinx.cpp.graph.AdjacencyList_int32: + if hasattr(partition_graph, "_cpp_object"): + cpp_obj = partition_graph._cpp_object + assert isinstance(cpp_obj, dolfinx.cpp.graph.AdjacencyList_int32) + return cpp_obj + else: + assert isinstance(partition_graph, dolfinx.cpp.graph.AdjacencyList_int32) + return partition_graph + + partitioner = _custom_partitioner else: if not hasattr(dolfinx.mesh, "create_cell_partitioner"): partitioner = dolfinx.graph.partitioner() From 7ce6b72b4191c68b94bc9a80dfc4875e140e73e3 Mon Sep 17 00:00:00 2001 From: Henrik Finsberg Date: Wed, 2 Sep 2026 21:49:56 +0200 Subject: [PATCH 22/23] =?UTF-8?q?Use=20main=20branch=20of=20J=C3=B8rgens?= =?UTF-8?q?=20actions=20which=20has=20the=20nanobind=20fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/test_workflow.yml | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/.github/workflows/test_workflow.yml b/.github/workflows/test_workflow.yml index 54fc93c..57fed00 100644 --- a/.github/workflows/test_workflow.yml +++ b/.github/workflows/test_workflow.yml @@ -68,23 +68,9 @@ jobs: name: legacy_checkpoint_mpich path: ./legacy_checkpoint - # DOLFINx 0.11.x (release branch) passes a cffi cdata object where the - # nanobind bindings expect a C++ integer. nanobind 2.14.0 requires the - # `__index__` protocol for implicit integer conversion, which cffi cdata - # does not implement, so every `dolfinx.fem.form` call fails with - # "TypeError: __init__(): incompatible function arguments". - # Fixed on DOLFINx main by https://github.com/FEniCS/dolfinx/pull/4371, - # not (yet) backported to the release branch, so constrain nanobind when - # building the stable bindings. Remove once the fix is in a release. - - name: Constrain nanobind for stable DOLFINx - if: needs.get_image_tag.outputs.image == 'stable' - run: | - echo "nanobind<2.14" > "$GITHUB_WORKSPACE/constraints.txt" - echo "PIP_CONSTRAINT=$GITHUB_WORKSPACE/constraints.txt" >> $GITHUB_ENV - - name: Install DOLFINx (stable) if: needs.get_image_tag.outputs.image == 'stable' - uses: jorgensd/actions/install-dolfinx@v0.4 + uses: jorgensd/actions/install-dolfinx@main with: adios2: default petsc_arch: linux-gnu-real64-32 From 1345de33b16fa39b7cf8928e040f0e4e29e799c9 Mon Sep 17 00:00:00 2001 From: Henrik Finsberg Date: Thu, 3 Sep 2026 07:51:50 +0200 Subject: [PATCH 23/23] Change bacn to v0.4 in actions --- .github/workflows/test_workflow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_workflow.yml b/.github/workflows/test_workflow.yml index 57fed00..11e0728 100644 --- a/.github/workflows/test_workflow.yml +++ b/.github/workflows/test_workflow.yml @@ -70,7 +70,7 @@ jobs: - name: Install DOLFINx (stable) if: needs.get_image_tag.outputs.image == 'stable' - uses: jorgensd/actions/install-dolfinx@main + uses: jorgensd/actions/install-dolfinx@v0.4 with: adios2: default petsc_arch: linux-gnu-real64-32