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

Reorganise testing and CI #209

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
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 @@ -40,25 +44,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 12 --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 4 --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

nslices = fd.COMM_WORLD.size//2
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)
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 = 1.0e-10
solver_parameters = {
'snes_type': 'ksponly',
'snes': {
'monitor': None,
'converged_reason': None,
},
'pc_type': 'none',
'ksp_type': 'gmres',
'mat_type': 'matfree',
'ksp': {
'monitor': None,
'converged_rate': None,
'atol': atol,
'rtol': 1.0e-100,
'stol': 1.0e-100,
}
}

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

aaosolver.solve()

# check residual

aaoform.assemble(func=aaofunc)
residual = fd.norm(aaoform.F.function)

assert 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(6, 6, comm=ensemble.comm)
Expand Down Expand Up @@ -166,7 +107,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 @@ -249,10 +190,11 @@ def form_mass(uu, up, vu, vp):
'stol': 1e-100,
},
'mat_type': 'matfree',
'ksp_type': 'preonly',
'ksp_type': 'gmres',
'ksp': {
'monitor': None,
'converged_reason': None,
'rtol': 1e-3,
},
'pc_type': 'python',
'pc_python_type': 'asQ.CirculantPC',
Expand Down
File renamed without changes.
Loading