Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JDBetteridge/update build system #61

Merged
merged 39 commits into from
Dec 7, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
00695dd
Remove setuptools
JDBetteridge Nov 6, 2024
615e26c
Add info from poetry, but not petsc4py
JDBetteridge Nov 6, 2024
8689875
Add missing petsc4py dependency
JDBetteridge Nov 6, 2024
fe4ff9e
Remove duplicated metadata
JDBetteridge Nov 6, 2024
3f1d91c
Remove ineffective environment variables
JDBetteridge Nov 6, 2024
43f14bb
netgen-mesher now explicitly listed as a dependency
JDBetteridge Nov 6, 2024
9fbb193
POETRY is coming to town.
Nov 6, 2024
88f92e3
Update release.yml
JDBetteridge Nov 7, 2024
2273c6e
Edit regex
JDBetteridge Nov 7, 2024
2ecea8b
Bump version
JDBetteridge Nov 7, 2024
49ba98f
Try building petsc/petsc4py
JDBetteridge Nov 7, 2024
ef91493
Drop v from tag when versioning
JDBetteridge Nov 7, 2024
6f20dc9
bump version
JDBetteridge Nov 7, 2024
2cca839
Install mpich
JDBetteridge Nov 7, 2024
8b42ad8
bump version
JDBetteridge Nov 7, 2024
fba882d
PETSc requires additional Python packages to install petsc4py
JDBetteridge Nov 7, 2024
85ddd10
bump version
JDBetteridge Nov 7, 2024
a75c139
export PETSc env vars
JDBetteridge Nov 7, 2024
9492bc4
bump version
JDBetteridge Nov 7, 2024
980cc5c
Grrr
JDBetteridge Nov 7, 2024
59a638c
bump version
JDBetteridge Nov 7, 2024
8fc5845
Remove more duplicated spec
JDBetteridge Nov 8, 2024
e0404a9
Bump version
JDBetteridge Nov 8, 2024
4afb19e
A bit of SSH debugging
JDBetteridge Nov 8, 2024
9d97641
Still need disgusting hack :face_vomiting:
JDBetteridge Nov 8, 2024
742be52
Remove SSH debugging
JDBetteridge Nov 8, 2024
8c9a392
Tidy makefile
JDBetteridge Nov 8, 2024
652d57b
Update the readme to prefer installing via PyPI
JDBetteridge Nov 8, 2024
febeac3
Add notes on how to create a release for Umberto
JDBetteridge Nov 8, 2024
9168553
Merge remote-tracking branch 'origin' into JDBetteridge/update_build_…
JDBetteridge Nov 8, 2024
7fb9234
Tags need a v before them
JDBetteridge Nov 8, 2024
2fbea40
Merge branch 'main' into JDBetteridge/update_build_system
Nov 20, 2024
3f54a85
Release vngsPETSc 0.0.7a8
Nov 20, 2024
5599d49
Changed path of the tests
Dec 7, 2024
a2788a0
Merge branch 'main' into JDBetteridge/update_build_system
Dec 7, 2024
cccb036
Merge branch 'uz/CI' into JDBetteridge/update_build_system
Dec 7, 2024
ec3d189
Removed MPI direct dependency from ngsPETSc.
Dec 7, 2024
ab4caf9
Release vngsPETSc 0.0.8
Dec 7, 2024
81a7b19
Merge branch 'main' into JDBetteridge/update_build_system
UZerbinati Dec 7, 2024
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
8 changes: 3 additions & 5 deletions .github/workflows/ngsPETSc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ jobs:
pip install netgen-mesher --break-system-packages
export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python3.10/site-packages
echo "PYTHONPATH=$PYTHONPATH" >> $GITHUB_ENV
NGSPETSC_NO_INSTALL_REQUIRED=ON pip install -e . --break-system-packages
pip install -e . --break-system-packages

- name: Run test suite in serial
run: |
Expand All @@ -109,9 +109,8 @@ jobs:
- name: Install Netgen and ngsPETSc
run: |
. /home/firedrake/firedrake/bin/activate
pip install netgen-mesher
pip install xdist pytest-timeout ipympl
NGSPETSC_NO_INSTALL_REQUIRED=ON pip install .
pip install .

- name: Run part of the Firedrake test suite
run: |
Expand All @@ -135,9 +134,8 @@ jobs:
- name: Install Netgen and ngsPETSc
run: |
. /home/firedrake/firedrake/bin/activate
pip install netgen-mesher
pip install xdist pytest-timeout ipympl
NGSPETSC_NO_INSTALL_REQUIRED=ON pip install .
pip install .

- name: Run part of the Firedrake test suite
run: |
Expand Down
67 changes: 42 additions & 25 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,41 +1,58 @@
[project]
[project.optional-dependencies]
dev = [
"pytest",
"pylint",
]
ngsolve = [
"ngsolve",
]
firedrake = [
"firedrake",
]

[tool.poetry]
name = "ngsPETSc"
version = "0.0.5"
description = "NGSolve/Netgen interface to PETSc."
readme = "README.md"
version = "0.0.6"
description = "NGSolve/Netgen interface to PETSc"
authors = [
{name = "Umberto Zerbinati", email = "[email protected]"},
{name = "Patrick E. Farrell", email = "[email protected]"},
{name = "Stefano Zampini", email = "[email protected]"},
{name = "Jack Betteridge", email = "[email protected]"},
"Umberto Zerbinati <[email protected]>",
"Patrick E. Farrell <[email protected]>",
"Stefano Zampini <[email protected]>",
"Jack Betteridge <[email protected]>",
]
maintainers = [
{name = "Umberto Zerbinati", email = "[email protected]"},
"Umberto Zerbinati <[email protected]>",
]
license = {file = "LICENSE.txt"}
dependencies = [
"mpi4py",
"numpy",
"scipy",
readme = "README.md"
licence = "MIT"
packages = [
{include = "ngsPETSc"}
]
requires-python = ">=3.8"
documentation = "https://ngspetsc.readthedocs.io/en/latest/"
repository = "https://github.com/NGSolve/ngsPETSc"
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Development Status :: 3 - Alpha",
]

[project.urls]
Documentation = "https://ngspetsc.readthedocs.io/en/latest/"
Repository = "https://github.com/NGSolve/ngsPETSc"
[tool.poetry.dependencies]
python = "^3.9"
netgen-mesher = "^6.2"
netgen-occt = "^7.8"
petsc4py = "^3.22.1"
mpi4py = "^4"
Copy link
Collaborator

@stefanozampini stefanozampini Nov 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a look at ngsPETSc code, it seems there's no need to have mpi4py listed here, if not for a few occurrences of MPI.COMM_WORLD that can be replaced by PETSc.COMM_WORLD.tompi4py() . @UZerbinati How mpi4py is handled by the netgen related packages?

I just tried to install with this branch and got this

$ mpiexec -n 2 python test_vec.py 
/home/szampini/Devel/sandbox/ngspetsc/ngsPETSc/ngsPETSc/eps.py:10: UserWarning: Import Warning: it was not possible to import SLEPc
  warnings.warn("Import Warning: it was not possible to import SLEPc")
/home/szampini/Devel/sandbox/ngspetsc/ngsPETSc/ngsPETSc/eps.py:10: UserWarning: Import Warning: it was not possible to import SLEPc
  warnings.warn("Import Warning: it was not possible to import SLEPc")
Assertion failed in file ./src/include/mpir_request.h at line 508: ((req))->ref_count >= 0
/usr/lib64/mpich/lib/libmpi.so.12(+0x2d88ff) [0x7f5c956d88ff]
/usr/lib64/mpich/lib/libmpi.so.12(+0x2d8b60) [0x7f5c956d8b60]
/usr/lib64/mpich/lib/libmpi.so.12(+0x202bd2) [0x7f5c95602bd2]
/usr/lib64/mpich/lib/libmpi.so.12(PMPI_Waitall+0x106) [0x7f5c95510e76]
/home/szampini/Devel/sandbox/ngspetsc/ngsPETSc/test-jack/lib64/python3.11/site-packages/netgen/../netgen_mesher.libs/libnglib.so(+0x391129) [0x7f5ccf191129]
/home/szampini/Devel/sandbox/ngspetsc/ngsPETSc/test-jack/lib64/python3.11/site-packages/netgen/../netgen_mesher.libs/libnglib.so(+0x38e252) [0x7f5ccf18e252]
/home/szampini/Devel/sandbox/ngspetsc/ngsPETSc/test-jack/lib64/python3.11/site-packages/netgen/../netgen_mesher.libs/libnglib.so(+0x38fff8) [0x7f5ccf18fff8]
/home/szampini/Devel/sandbox/ngspetsc/ngsPETSc/test-jack/lib64/python3.11/site-packages/netgen/../netgen_mesher.libs/libnglib.so(_ZN6netgen4Mesh10DistributeEv+0x87) [0x7f5ccf190097]
/home/szampini/Devel/sandbox/ngspetsc/ngsPETSc/test-jack/lib64/python3.11/site-packages/netgen/../netgen_mesher.libs/libnglib.so(+0x3df8a1) [0x7f5ccf1df8a1]
/home/szampini/Devel/sandbox/ngspetsc/ngsPETSc/test-jack/lib64/python3.11/site-packages/netgen/../netgen_mesher.libs/libnglib.so(+0x18466a) [0x7f5ccef8466a]
/lib64/libpython3.11.so.1.0(+0x1d56e1) [0x7f5ce4bd56e1]
/lib64/libpython3.11.so.1.0(_PyObject_MakeTpCall+0x73) [0x7f5ce4bb7c73]
/lib64/libpython3.11.so.1.0(_PyEval_EvalFrameDefault+0x7e9) [0x7f5ce4bc0779]
/lib64/libpython3.11.so.1.0(+0x1bc6fa) [0x7f5ce4bbc6fa]
/lib64/libpython3.11.so.1.0(PyEval_EvalCode+0xac) [0x7f5ce4c463ac]
/lib64/libpython3.11.so.1.0(+0x264473) [0x7f5ce4c64473]
/lib64/libpython3.11.so.1.0(+0x2609fa) [0x7f5ce4c609fa]
/lib64/libpython3.11.so.1.0(+0x276752) [0x7f5ce4c76752]
/lib64/libpython3.11.so.1.0(_PyRun_SimpleFileObject+0x1a9) [0x7f5ce4c75f49]
/lib64/libpython3.11.so.1.0(_PyRun_AnyFileObject+0x48) [0x7f5ce4c75be8]
/lib64/libpython3.11.so.1.0(Py_RunMain+0x2eb) [0x7f5ce4c6f79b]
/lib64/libpython3.11.so.1.0(Py_BytesMain+0x3b) [0x7f5ce4c3652b]
/lib64/libc.so.6(+0x27550) [0x7f5ce484a550]
/lib64/libc.so.6(__libc_start_main+0x89) [0x7f5ce484a609]
python(_start+0x25) [0x555a452c1095]
internal ABORT - process 0
$ pip list
Package            Version  Editable project location
------------------ -------- ----------------------------------------------
intel-cmplr-lib-ur 2025.0.0
intel-openmp       2025.0.0
mkl                2025.0.0
mpi4py             4.0.1
netgen-mesher      6.2.2405
netgen_occt        7.8.1
ngsolve            6.2.2405
ngsPETSc           0.0.7a7  /home/szampini/Devel/sandbox/ngspetsc/ngsPETSc
numpy              2.1.3
petsc4py           3.22.1
pip                22.2.2
scipy              1.14.1
setuptools         62.6.0
tbb                2022.0.0
tcmlib             1.2.0
umf                0.9.0

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not good ! I'll replace the use of MPI.COMM_WORLD as you suggested.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how mpi4py is handled by the netgen related packages? @mhochsteger might know more since I remember he put a lot of work into making ngsolve with mpi support pip installable.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like it could be an issue with your MPI installation?
4.0 is using large count datatypes, which causes some headaches with existing MPI installations that don't conform to the MPI 4.0 standard.
It'd be nice to just suck down the mpi4py wheel, but that isn't available on PyPI. (...yet?)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why users wouldn't want mpi4py TBH!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue with mpi4py 3.1.6, not a mpi4 problem. Does it work for you? I have mpich on fedora and installed ngspetsc using pip install -e . letting the build figure out the dependencies

Copy link
Collaborator

@stefanozampini stefanozampini Nov 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why users wouldn't want mpi4py TBH!

you can make the same argument with many other useful python packages. The point is that if a package does not explicitly use another one, it should not list it as a dependency. The only reason it is a dependency now is because of the misuse of MPI.COMM_WORLD

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In a fresh python virtual environment pip install ngsPETSc ngsolve allows me to run all tests.
I'm working on Archlinux and OpenMPI, I'll try next on a fresh install with MPICH!

numpy = "^2.0"
scipy = "^1"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these explicit dependencies only needed to build the wheel or they are also used to install the package via pip? If the latter case, then they seem too strict

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They probably are a bit strict, but at least initially I want to get something working. The main aim of this PR (from Firedrake's viewpoint) is to use versioned ngsPETSc for the CI.
Firedrake requires python >=3.9 (and soon >=3.10) and petsc4py==3.22.1 and numpy >= 2.0.

Of course it's up to ngsPETSc which versions of dependencies it wasn't to support!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't use firedrake with ngsPETSc, and we should find a way to relax those requirements here. If you need these specific requirements for firedrake CI you can do it there, not here, unless I'm missing something.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we're agreeing with each other. Poetry by default adds a very constrained version range, these values (except for petsc4py, which is more strict and scipy which is less strict) have been edited to be pinned to minor releases, we can probably relax to major releases for most packages. I don't know enough about netgen-mesher and netgen-occt to comment further on those constraints though.

Copy link
Collaborator

@stefanozampini stefanozampini Nov 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$ git grep scipy
Dockerfile:RUN pip install numpy scipy cython mpi4py pytest pytest-mpi
docs/requirements.txt:scipy==1.11.1
docs/src/PETScBasic/pinvt.py.rst:   from scipy.linalg import eigh
docs/src/PETScPC/stokes.py.rst:   from scipy.sparse import coo_matrix
ngsPETSc/utils/firedrake/meshes.py:from scipy.spatial.distance import cdist
pyproject.toml:scipy = "^1"

Can we get rid of the scipy dependency cdist ?

p = [np.where(cdist(a, b).T < tol)[1] for a, b in zip(points_a, points_b)]

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, although it's probably it's own PR. I introduced it as optional but was told it was fine to have a hard dependency so removed the alternative.

See: #48 (comment)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We didn't have this dependence a while ago, after @JDBetteridge refactored ngsPETSc curve mesh support for Firedrake he opted to use cdist to make the code faster. Maybe we can substitute cdist with a function pure python function and then check if the user has installed scipy (try: import scipy ...) , if so replace our own cdist with scipy cdist ? I think this was the original plan and it is my fault since I suggested @JDBetteridge to make scipy a hard dependence.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure having scipy as a dependency is the end of the world, it's an easy to install well supported project and comes by default on some Python distributions.


[project.optional-dependencies]
dev = [
"pytest",
"pylint",
]
[tool.poetry.group.dev.dependencies]
pytest = "^8.3"
pylint = "^3.3"

[tool.poetry.group.ngsolve.dependencies]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this is optional? ngsPETSc is a package that offers PETSc solvers to ngsolve, it shouldn't be optional

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ngsPETSc at its bare minimum, only provides netgen meshes to PETSc and vice-versa, which only requires netgen for this reason I think ngsolve can be interpreted as an optional dependency while netgen is not optional.
This also allows people who want to use ngsPETSc only to get netgen mesh and PETSc dmplex not to install the full ngsolve which is a much larger package than netgen.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also works around the issue that netgen packages have a completely different name when installed from source and the explanation I got after questioning this code:
https://github.com/NGSolve/ngsPETSc/blob/main/setup.py

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought the business of ngsPETSc is to provide parallel solver support for ngsolve, not meshes, see also https://docu.ngsolve.org/latest/i-tutorials/index.html#mpi-parallelization-and-cuda-support.

ngsolve = "^6.2"

[build-system]
requires = ['setuptools>=42']
build-backend = 'setuptools.build_meta'
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
28 changes: 0 additions & 28 deletions setup.py

This file was deleted.