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/python312 #3546

Merged
merged 62 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from 61 commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
f56d200
Fix cython files for Cython 3.0
connorjward Dec 11, 2023
f789607
update firedrake-install for numpy deps
connorjward Dec 11, 2023
91e1015
lint
connorjward Dec 11, 2023
57fde42
Silly fixes
connorjward Dec 11, 2023
714d8fd
Add ninja system dependency
connorjward Dec 11, 2023
4f69130
Since we are using the docker container
connorjward Dec 11, 2023
92b62ae
fixup
connorjward Dec 11, 2023
9a4d5bc
Install with numpy 2.0 release candidate
connorjward Apr 11, 2024
d79f247
fixup
connorjward Apr 11, 2024
ba3e868
fixup
connorjward Apr 11, 2024
9c51eef
fixup
connorjward Apr 11, 2024
a868c84
fixup
connorjward Apr 11, 2024
5da6d11
fixup
connorjward Apr 11, 2024
2390837
PYOP2 branch
connorjward Apr 11, 2024
e6b319c
fixup
connorjward Apr 11, 2024
2d66f28
fixup
connorjward Apr 12, 2024
79c656e
fixup
connorjward Apr 12, 2024
ca6efad
fixup
connorjward Apr 12, 2024
b94816f
loopy is now updated
connorjward Apr 16, 2024
ac7784d
Update branches of other dependencies
JDBetteridge May 1, 2024
0b983ca
Bump Zenodo canary Python version
JDBetteridge May 1, 2024
0a088e1
Build testing docker image
JDBetteridge May 2, 2024
4391c90
More workflow changes
JDBetteridge May 2, 2024
b095b3a
fix
JDBetteridge May 2, 2024
215bfeb
New unbuntu packages
JDBetteridge May 2, 2024
f08589c
Build against testing container
JDBetteridge May 2, 2024
eb3ffd6
Do I really need to specify root?
JDBetteridge May 2, 2024
e3ec363
Test without Thetis due to issues
JDBetteridge May 2, 2024
6c4383d
Don't become root
JDBetteridge May 8, 2024
1b1696a
Try setting user
JDBetteridge May 8, 2024
4de170c
Noodling
JDBetteridge May 8, 2024
2512d10
Noodling
JDBetteridge May 8, 2024
5e6534f
Noodling
JDBetteridge May 8, 2024
f9398e6
Noodling
JDBetteridge May 8, 2024
fc0d221
Noodling
JDBetteridge May 8, 2024
d3a9a34
Noodling
JDBetteridge May 8, 2024
ea03bf8
Noodling
JDBetteridge May 8, 2024
c0e33a8
Noodling
JDBetteridge May 8, 2024
13720f3
Noodling
JDBetteridge May 8, 2024
d17d991
Noodling
JDBetteridge May 8, 2024
71e0ae9
Noodling
JDBetteridge May 8, 2024
a51161a
Noodling
JDBetteridge May 8, 2024
ff50e25
Noodling
JDBetteridge May 8, 2024
ebd2168
Reintroduce old hack
JDBetteridge May 9, 2024
97a1f0e
Try user 1000
JDBetteridge May 9, 2024
dda9045
Remove sudo permissions hack
JDBetteridge May 9, 2024
49fd03c
Try user 100
JDBetteridge May 9, 2024
62fe66d
Try the hack again
JDBetteridge May 9, 2024
b52bf52
Revert me, check the old container
JDBetteridge May 9, 2024
903cbc0
Revert me too
JDBetteridge May 9, 2024
42e3b8a
Build another testing container
JDBetteridge May 9, 2024
0b445bf
Try again!
JDBetteridge May 10, 2024
14c4ad1
Re-enable thetis and tinyASM to test the branches
JDBetteridge May 13, 2024
8231d45
Try out the second numpy release candidate
JDBetteridge May 14, 2024
451ad20
What happens if we turn off coverage
JDBetteridge May 30, 2024
9957cfb
More C consts
JDBetteridge Jun 7, 2024
9ebdb66
All package branches merged
JDBetteridge Jun 7, 2024
a51ead9
Test
JDBetteridge Jun 18, 2024
be7ef80
Use stable torch release
JDBetteridge Jun 20, 2024
129133f
Update documentation to Python3.9-3.12
JDBetteridge Jun 20, 2024
fe93ed7
tinyasm snuck back in during rebase
JDBetteridge Jun 20, 2024
e1c9e28
Apply suggestions from code review
JDBetteridge Jun 20, 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
13 changes: 10 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
# Run on our self-hosted machines
runs-on: self-hosted
container:
image: firedrakeproject/firedrake-env:latest
image: firedrakeproject/firedrake-test:latest
JDBetteridge marked this conversation as resolved.
Show resolved Hide resolved
strategy:
# Don't immediately kill real if complex fails and vice versa.
fail-fast: false
Expand Down Expand Up @@ -88,7 +88,7 @@ jobs:
. ../firedrake_venv/bin/activate
python "$(which firedrake-clean)"
python -m pip install \
pytest-cov pytest-timeout pytest-xdist pytest-timeout ipympl
pytest-xdist pytest-timeout ipympl
python -m pip list
- name: Test Firedrake
run: |
Expand All @@ -98,7 +98,6 @@ jobs:
python -m pytest -v tests/test_0init.py
python -m pytest \
--durations=200 \
--cov firedrake \
--timeout=1800 \
--timeout-method=thread \
-o faulthandler_timeout=1860 \
Expand Down Expand Up @@ -151,3 +150,11 @@ jobs:
tag: ${{ needs.docker_tag.outputs.tag }}
status: ${{ needs.build.result }}
secrets: inherit
#~ docker_testing:
#~ # Strictly for testing!
#~ uses: ./.github/workflows/docker_reuse.yml
#~ with:
#~ target: firedrake-test
#~ tag: latest
#~ dockerfile: docker/Dockerfile.env
#~ secrets: inherit
JDBetteridge marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 2 additions & 2 deletions .github/workflows/zenodo-canary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.8
python-version: 3.12
- name: Install deps
run: |
pip install requests
pip install requests packaging
- name: Zenodo API canary
run: |
python scripts/firedrake-install --test-doi-resolution
Expand Down
14 changes: 9 additions & 5 deletions docker/Dockerfile.env
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# DockerFile for an environment into which firedrake can be installed.

FROM ubuntu:22.04
FROM ubuntu:24.04

# Update and install required packages for Firedrake
USER root
Expand All @@ -13,17 +13,21 @@ RUN apt-get update \
cmake gfortran git libopenblas-serial-dev \
libtool python3-dev python3-pip python3-tk python3-venv \
python3-requests zlib1g-dev libboost-dev sudo gmsh \
bison flex \
liboce-ocaf-dev \
bison flex ninja-build \
libocct-ocaf-dev libocct-data-exchange-dev \
swig graphviz \
libcurl4-openssl-dev libxml2-dev \
&& rm -rf /var/lib/apt/lists/*

# Use a more sane locale
ENV LC_ALL C.UTF-8

# Set up user so that we do not run as root
RUN useradd -m -s /bin/bash -G sudo firedrake && \
# Change the `ubuntu` user to `firedrake`
# and ensure that we do not run as root on self-hosted systems
RUN usermod -d /home/firedrake -m ubuntu && \
usermod -l firedrake ubuntu && \
groupmod -n firedrake ubuntu && \
usermod -aG sudo firedrake && \
echo "firedrake:docker" | chpasswd && \
echo "firedrake ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers && \
ldconfig
Expand Down
16 changes: 7 additions & 9 deletions docs/source/download.rst
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,15 @@ packages can be installed into an existing Firedrake installation using
System requirements
-------------------

Firedrake requires Python 3.8.x to 3.11.x. On MacOS Arm (M1 or M2) Python 3.9.x
to 3.11.x is required. Many externally managed dependencies such as VTK
have yet to create binary wheels for 3.11.x, but we have generated these
for the major supported platforms.
The installation script is tested on Ubuntu and MacOS X. On Ubuntu 22.04
or later, the system installed Python 3 is supported and tested. On
MacOS, the homebrew_ installed Python 3 is supported::
Firedrake requires Python 3.9 to 3.12. The installation script is
tested by CI on Ubuntu 24.04 LTS. On Ubuntu 22.04 or later, the system
installed Python 3 is supported. On MacOS, the homebrew_ installed
Python 3 is supported::

brew install python3

Installation is likely to work well on other Linux platforms, although
the script may stop to ask you to install some dependency packages.
the script may fail if dependency packages are not already installed.
Installation on other Unix platforms may work but is untested. On Linux
systems that do not use the Debian package management system, it will be
necessary to pass the `--no-package-manager` option to the install
Expand All @@ -129,12 +126,13 @@ they have the system dependencies:
* A Fortran compiler (for PETSc)
* Blas and Lapack
* Git, Mercurial
* Python version 3.8.x-3.11.x (3.9.x-3.11.x on MacOS Arm)
* Python version 3.9-3.12
* The Python headers
* autoconf, automake, libtool
* CMake
* zlib
* flex, bison
* Ninja

Firedrake has been successfully installed on Windows 10 using the
Windows Subsystem for Linux. There are more detailed instructions for
Expand Down
4 changes: 2 additions & 2 deletions docs/source/install-debug.dot
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ digraph triage {
venv_activated [label="venv activated?"];
install_script_up_to_date [label="Install script\nup to date?"];
using_anaconda [label="Using\nAnaconda?"];
python_version [label="Python <3.8?"];
python_version [label="Python <3.9?"];
using_macos [label="Using\nMacOS?"];
using_homebrew [label="Using\nHomebrew?"];
url_error [label="URL Error with SSL\ncertificate failure?"];
which_python [label="<which python3> points\nat <$(brew --prefix)/bin/python3>?"];

activate_venv [label="Activate the\nvenv first."];
uninstall_anaconda [label="Deactivate\nAnaconda."];
update_python [label="Get Python 3.8-3.11"];
update_python [label="Get Python 3.9-3.12"];
update_install_script [label="Fetch new\ninstall script"];
get_homebrew [label="Use Homebrew."];
brew_doctor [label="brew doctor"];
Expand Down
2 changes: 1 addition & 1 deletion firedrake/checkpointing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1359,7 +1359,7 @@ def _load_function_topology(self, tmesh, element, tf_name, idx=None):
if element.family() == "Real":
assert not isinstance(element, (finat.ufl.VectorElement, finat.ufl.TensorElement))
value = self.get_attr(path, "_".join([PREFIX, "value" if idx is None else "value_" + str(idx)]))
tf.dat.data.itemset(value)
tf.dat.data[...] = value
else:
if path in self.h5pyfile:
timestepping = self.has_attr(os.path.join(path, tf.name()), "timestepping")
Expand Down
15 changes: 8 additions & 7 deletions firedrake/cython/dmcommon.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# Utility functions common to all DMs used in Firedrake
import functools
import math
import cython
import numpy as np
import firedrake
Expand Down Expand Up @@ -675,7 +676,7 @@ def closure_ordering(PETSc.DM dm,
incident = 1
break
if incident == 0:
face_indices[nfaces] += v * 10**(1-fi)
face_indices[nfaces] += v * <PetscInt> 10**(1-fi)
fi += 1
nfaces += 1

Expand Down Expand Up @@ -970,7 +971,7 @@ cdef inline PetscInt _compute_orientation_simplex(PetscInt *fiat_cone,
coneSize1 -= 1
assert n == coneSize
for k in range(n):
o += np.math.factorial(n - 1 - k) * inds[k]
o += math.factorial(n - 1 - k) * inds[k]
CHKERR(PetscFree(cone1))
CHKERR(PetscFree(inds))
return o
Expand Down Expand Up @@ -1019,10 +1020,10 @@ cdef inline PetscInt _compute_orientation_interval_tensor_product(PetscInt *fiat
# io += (2**(dim - 1 - i)) * 0
pass
elif plex_cone_copy[2 * j + 1] == fiat_cone[2 * i] and plex_cone_copy[2 * j] == fiat_cone[2 * i + 1]:
io += (2**(dim - 1 - i)) * 1
io += <PetscInt> (2**(dim - 1 - i)) * 1
else:
raise RuntimeError("Found inconsistent fiat_cone and plex_cone")
eo += np.math.factorial(dim - 1 - i) * j
eo += math.factorial(dim - 1 - i) * j
for k in range(j, dim1 - 1):
plex_cone_copy[2 * k] = plex_cone_copy[2 * k + 2]
plex_cone_copy[2 * k + 1] = plex_cone_copy[2 * k + 3]
Expand All @@ -1031,7 +1032,7 @@ cdef inline PetscInt _compute_orientation_interval_tensor_product(PetscInt *fiat
else:
raise RuntimeError("Found inconsistent fiat_cone and plex_cone")
assert dim1 == 0
return (2**dim) * eo + io
return <PetscInt> (2**dim) * eo + io


cdef inline PetscInt _compute_orientation(PETSc.DM dm,
Expand Down Expand Up @@ -2552,7 +2553,7 @@ cdef struct CommFacet:
PetscInt global_u, global_v
PetscInt local_facet

cdef int CommFacet_cmp(const void *x_, const void *y_) nogil:
cdef int CommFacet_cmp(const void *x_, const void *y_) noexcept nogil:
"""Three-way comparison C function for CommFacet structs."""
cdef:
CommFacet *x = <CommFacet *>x_
Expand Down Expand Up @@ -3334,7 +3335,7 @@ cdef int DMPlexGetAdjacency_Facet_Support(PETSc.PetscDM dm,
PetscInt p,
PetscInt *adjSize,
PetscInt adj[],
void *ctx) nogil:
void *ctx) noexcept nogil:
"""Custom adjacency callback for halo growth.

:arg dm: The DMPlex object.
Expand Down
2 changes: 1 addition & 1 deletion firedrake/cython/mgimpl.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def coarse_to_fine_cells(mc, mf, clgmaps, flgmaps):
cdm = mc.topology_dm
fdm = mf.topology_dm
dim = cdm.getDimension()
nref = 2 ** dim
nref = <PetscInt> 2 ** dim
ncoarse = mc.cell_set.size
nfine = mf.cell_set.size
co2n, _ = get_entity_renumbering(cdm, mc._cell_numbering, "cell")
Expand Down
2 changes: 1 addition & 1 deletion firedrake/cython/petschdr.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ cdef inline int SETERR(int ierr) with gil:
PyErr_SetObject(<object>PyExc_RuntimeError, <long>ierr)
return ierr

cdef inline int CHKERR(int ierr) nogil except -1:
cdef inline int CHKERR(int ierr) except -1 nogil:
if ierr == 0:
return 0 # no error
else:
Expand Down
11 changes: 9 additions & 2 deletions firedrake/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from pyop2.mpi import (
MPI, COMM_WORLD, internal_comm, is_pyop2_comm, temp_internal_comm
)
from pyop2.utils import as_tuple, tuplify
from pyop2.utils import as_tuple

import firedrake.cython.dmcommon as dmcommon
import firedrake.cython.extrusion_numbering as extnum
Expand Down Expand Up @@ -1445,7 +1445,14 @@ def make_dofs_per_plex_entity(self, entity_dofs):
dofs_per_entity = np.zeros((1 + self._base_mesh.cell_dimension(), 2), dtype=IntType)
for (b, v), entities in entity_dofs.items():
dofs_per_entity[b, v] += len(entities[0])
return tuplify(dofs_per_entity)

# Convert to a tuple of tuples with int (not numpy.intXX) values. This is
# to give us a string representation like ((0, 1), (2, 3)) instead of
# ((numpy.int32(0), numpy.int32(1)), (numpy.int32(2), numpy.int32(3))).
return tuple(
tuple(int(d_) for d_ in d)
for d in dofs_per_entity
)

@PETSc.Log.EventDecorator()
def node_classes(self, nodes_per_entity, real_tensorproduct=False):
Expand Down
11 changes: 7 additions & 4 deletions firedrake/preconditioners/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -816,10 +816,13 @@ def initialize(self, obj):
is_snes = False

if len(bcs) > 0:
ghost_bc_nodes = numpy.unique(numpy.concatenate([bcdofs(bc, ghost=True)
for bc in bcs]))
global_bc_nodes = numpy.unique(numpy.concatenate([bcdofs(bc, ghost=False)
for bc in bcs]))
ghost_bc_nodes = numpy.unique(
numpy.concatenate([bcdofs(bc, ghost=True) for bc in bcs],
dtype=PETSc.IntType)
)
global_bc_nodes = numpy.unique(
numpy.concatenate([bcdofs(bc, ghost=False) for bc in bcs],
dtype=PETSc.IntType))
else:
ghost_bc_nodes = numpy.empty(0, dtype=PETSc.IntType)
global_bc_nodes = numpy.empty(0, dtype=PETSc.IntType)
Expand Down
Loading
Loading