Skip to content

Reorganise testing and CI #209

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

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file

version: 2
updates:
- package-ecosystem: "github-actions" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
34 changes: 27 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ on:
- master
# And all pull requests
pull_request:
schedule:
# * is a special character in YAML so you have to quote this string
# Scheduled run over the weekend to detect any upstream breaks.
- cron: '0 1 * * 0'

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
Expand Down Expand Up @@ -41,25 +45,41 @@ jobs:
# (copied from https://help.github.com/en/actions/migrating-to-github-actions/migrating-from-circleci-to-github-actions)
run: |
sudo chmod -R 777 $GITHUB_WORKSPACE /github /__w/_temp
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Install test dependencies
run: |
. /home/firedrake/firedrake/bin/activate
python -m pip install pytest-timeout
python -m pip install pytest-cov
# try and reduce the number of warnings to sift through
python -m pip install siphash24
- name: Install
run: |
. /home/firedrake/firedrake/bin/activate
python -m pip install -e .
python --version
python -m pytest --version
flake8 --version
firedrake-status
- name: Lint
run: |
. /home/firedrake/firedrake/bin/activate
flake8 --version
flake8 .
- name: Test
- name: Test - unit tests
run: |
. /home/firedrake/firedrake/bin/activate
python --version
python -m pytest --version
firedrake-status
python -m pytest -v -n 6 --durations=40 --timeout=600 --cov=asQ --cov-report=term tests/
python -m pytest \
-n 3 --dist worksteal \
--durations=40 \
--timeout=300 \
--cov=asQ --cov-report=term \
-v tests/unit
- name: Test - integration tests
run: |
. /home/firedrake/firedrake/bin/activate
python -m pytest \
-n 3 --dist worksteal \
--durations=40 \
--timeout=600 \
--cov=asQ --cov-report=term --cov-append \
-v tests/integration
Original file line number Diff line number Diff line change
Expand Up @@ -3,82 +3,9 @@
import pytest


@pytest.mark.parallel(nprocs=6)
def test_solve_heat_equation_nopc():
"""
Tests the basic solver setup using the heat equation.
Solves using unpreconditioned GMRES and checks that the
residual of the all-at-once-form is below tolerance.
"""

# set up space-time parallelism

nspace_ranks = 2
nslices = fd.COMM_WORLD.size//nspace_ranks
slice_length = 2

time_partition = tuple((slice_length for _ in range(nslices)))
ensemble = asQ.create_ensemble(time_partition, comm=fd.COMM_WORLD)

mesh = fd.UnitSquareMesh(
6, 6, comm=ensemble.comm,
distribution_parameters={'partitioner_type': 'simple'})

V = fd.FunctionSpace(mesh, "CG", 1)

# all-at-once function and initial conditions

x, y = fd.SpatialCoordinate(mesh)
ics = fd.Function(V).interpolate(fd.exp(-((x - 0.5)**2 + (y - 0.5)**2) / 0.5**2))

aaofunc = asQ.AllAtOnceFunction(ensemble, time_partition, V)
aaofunc.assign(ics)

# all-at-once form

dt = 0.01
theta = 1.0

def form_function(u, v, t):
return fd.inner(fd.grad(u), fd.grad(v))*fd.dx

def form_mass(u, v):
return fd.inner(u, v)*fd.dx

aaoform = asQ.AllAtOnceForm(aaofunc, dt, theta,
form_mass, form_function)

# solver and options

atol = 1e-10
solver_parameters = {
'snes_type': 'ksponly',
'pc_type': 'none',
'ksp_type': 'gmres',
'mat_type': 'matfree',
'ksp': {
'converged_rate': None,
'atol': atol,
'rtol': 0,
'stol': 0,
}
}

aaosolver = asQ.AllAtOnceSolver(aaoform, aaofunc,
solver_parameters=solver_parameters)

aaosolver.solve()

# check residual
aaoform.assemble(func=aaofunc)

residual = aaoform.F.cofunction.riesz_representation(
'l2', solver_options={'function_space': aaofunc.function.function_space()})

assert fd.norm(residual) < atol, "GMRES should converge to prescribed tolerance even without preconditioning"


def test_solve_heat_equation_circulantpc():
@pytest.mark.parallel(nprocs=4)
@pytest.mark.parametrize('partition', ['serial', 't-parallel', 'st-parallel'])
def test_solve_heat_equation_circulantpc(partition):
"""
Tests the basic solver setup using the heat equation.
Solves using GMRES preconditioned with the CirculantPC
Expand All @@ -89,8 +16,22 @@ def test_solve_heat_equation_circulantpc():
# set up space-time parallelism

window_length = 4
nprocs = fd.COMM_WORLD.size
assert window_length % nprocs == 0, "test setup incorrectly"

if partition == 'serial':
time_partition = window_length
elif partition == 't-parallel':
nslices = nprocs
slice_length = window_length//nslices
time_partition = [slice_length for _ in range(nslices)]
elif partition == 'st-parallel':
nslices = nprocs//2
slice_length = window_length//nslices
time_partition = [slice_length for _ in range(nslices)]
else:
assert False, "Unrecognised partition type"

time_partition = window_length
ensemble = asQ.create_ensemble(time_partition, comm=fd.COMM_WORLD)

mesh = fd.UnitSquareMesh(
Expand Down Expand Up @@ -163,7 +104,7 @@ def form_mass(u, v):
@pytest.mark.parallel(nprocs=4)
@pytest.mark.parametrize("extrude", extruded)
@pytest.mark.parametrize("cpx_type", cpx_types)
def test_solve_mixed_wave_equation(extrude, cpx_type):
def test_solve_mixed_wave_equation_circulantpc(extrude, cpx_type):
"""
Tests the solver setup using a nonlinear wave equation.
Solves using GMRES preconditioned with CirculantPC and checks
Expand Down Expand Up @@ -252,10 +193,11 @@ def form_mass(uu, up, vu, vp):
'stol': 0,
},
'mat_type': 'matfree',
'ksp_type': 'preonly',
'ksp_type': 'gmres',
'ksp': {
'monitor': None,
'converged_rate': None,
'converged_reason': None,
'rtol': 1e-3,
},
'pc_type': 'python',
'pc_python_type': 'asQ.CirculantPC',
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
from operator import mul


def assemble(form, *args, **kwargs):
return fd.assemble(form, *args, **kwargs).riesz_representation(riesz_map='l2')


bc_options = ["no_bcs", "homogeneous_bcs", "inhomogeneous_bcs"]


Expand Down Expand Up @@ -295,7 +291,3 @@ def form_mass(u, p, v, q):
yparallel = y[step].subfunctions[cpt]
for pdat, sdat in zip(yparallel.dat, yserial.dat):
assert np.allclose(pdat.data, sdat.data), f"Timestep {step}, component {cpt}, of AllAtOnceJacobian action doesn't match component of monolithic residual calculated locally"


if __name__ == '__main__':
pass
Loading
Loading