Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
e4cbca9
pro run: read a conditionally assigned pnList as an so file
cekees Nov 21, 2026
37f8e31
pro msh: set Profiling.procID before opening its log
cekees Nov 21, 2026
b78910e
pro run: check the mesh only after every rank has loaded the model
cekees Nov 21, 2026
b7775eb
C49 R3: first tests of the Galerkin shallow water kernel SW2D (serial…
cekees Nov 23, 2026
5fdb67f
C49 R3: the four MCorr correction solvers of the vortex2D deck (corre…
cekees Nov 23, 2026
988aacb
C49 R3: the MCorr3P level solvers other than Newton (rising bubble, s…
cekees Nov 23, 2026
b0a88af
C49 R3: RDLS.PsiTC, the pseudo-transient controller of the redistanci…
cekees Nov 23, 2026
20e7394
C49 R3: unit tests of the lines of the three gwvd step classes the 2d…
cekees Nov 23, 2026
988b97e
C49 R3: SW2DCV switches no deck sets (low order only, star states, wa…
cekees Nov 23, 2026
f56cdfb
C49 R3: SW2DCV and GN_SW2DCV: the consistent mass matrix, the dispers…
cekees Nov 23, 2026
5404b69
C49 R3: m_comp_co2 options no regression case sets (CO2 injection, FC…
cekees Nov 23, 2026
c9369a8
RANS2P reads the boundary kind per face (3D and 2D): strong rows on t…
cekees Nov 23, 2026
9a79632
RANS2P kinds: the constant-pressure null space follows a strong press…
cekees Nov 24, 2026
9dc2fe9
CI environments: keep conda-forge yaml below 0.2.6 (macOS import of p…
cekees Nov 24, 2026
5866423
coverage ratchet: floors for an aggregate (proteus/kernels/) and for …
cekees Nov 24, 2026
ab9fb08
coverage floors: SpatialTools 56.0 -> 57.0, mbd/BodyDynamics 52.2 -> …
cekees Nov 24, 2026
6f174e0
coverage floors: proteus/kernels aggregate 80.0 and the three gwvd st…
cekees Nov 24, 2026
37bb1f9
Merge cekees/proteus#352: CI environments: keep conda-forge yaml belo…
cekees Nov 24, 2026
8cb54d8
Merge cekees/proteus#350: C49 R3: tests for the moved kernels (first …
cekees Nov 24, 2026
ec9ed95
Merge cekees/proteus#344: pro: run the air-water-vv decks (model_kind…
cekees Nov 24, 2026
521c2cb
Merge cekees/proteus#351: C0 round 18: per-face strong/weak/none boun…
cekees Nov 24, 2026
39eff95
Merge cekees/proteus#353: C3 round 12: coverage floors for an aggrega…
cekees Nov 24, 2026
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: 6 additions & 2 deletions .github/coverage/floors.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,15 @@
"proteus/SWFlow/utils/SWEs_so.py": 0.0,
"proteus/ShockCapturing.py": 36.1,
"proteus/SimTools.py": 11.9,
"proteus/SpatialTools.py": 56.0,
"proteus/SpatialTools.py": 57.0,
"proteus/SplitOperator.py": 46.1,
"proteus/SplitOperator.py::ISO_fixed_MinModelStep": 100.0,
"proteus/StepControl.py": 36.0,
"proteus/StepControl.py::Fixed_dt_controller_systemit": 100.0,
"proteus/SubgridError.py": 19.6,
"proteus/SubsurfaceTransportCoefficients.py": 18.6,
"proteus/TimeIntegration.py": 22.6,
"proteus/TimeIntegration.py::NonConservativeBackwardEuler": 100.0,
"proteus/Transport.py": 63.4,
"proteus/TransportCoefficients.py": 18.1,
"proteus/TwoPhaseFlow/TwoPhaseFlowProblem.py": 94.6,
Expand Down Expand Up @@ -101,6 +104,7 @@
"proteus/defaults.py": 88.8,
"proteus/deim_utils.py": 60.4,
"proteus/iproteus.py": 76.9,
"proteus/kernels/": 80.0,
"proteus/kernels/ADR.py": 90.6,
"proteus/kernels/AddedMass.py": 76.2,
"proteus/kernels/ArchiveBeams.py": 7.8,
Expand Down Expand Up @@ -134,7 +138,7 @@
"proteus/kernels/__init__.py": 100.0,
"proteus/kernels/beamFEM.py": 9.2,
"proteus/kernels/m_comp_co2.py": "test pending (deck from Arnob; not legacy, #1282)",
"proteus/mbd/BodyDynamics.py": 52.2,
"proteus/mbd/BodyDynamics.py": 58.9,
"proteus/petsc_optional.py": 91.6,
"proteus/runtime.py": 100.0
}
76 changes: 65 additions & 11 deletions .github/coverage/ratchet.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,18 @@
-- the modules in the "at least a point above the floor" table -- so a floor
never chases the tenths a run's MPI timing can move. Every other floor stays.

A floor can also name a part of the package instead of one module, for the code a decision measures on its own:
a key ending in "/" is an aggregate (``"proteus/kernels/"``: every module under it counted together, one number for
the kernel package), a key ``<module>::<Class>`` is one class of a module (``"proteus/StepControl.py::Fixed_dt_controller_systemit"``:
the statements between the class's first and last line). They are checked and raised like a module's floor.

A floor may instead be a string: the module is measured and listed with that
reason, but not checked (a module waiting for its first test, or one excluded
until a campaign decides its fate). --write-floors leaves those entries as
they are; turning one into a number is a reviewed edit.
"""
import argparse
import ast
import json
import math
import os
Expand All @@ -51,18 +57,62 @@ def module_name(filename, source=''):
return path


def measure(report):
"""{module: (statements, covered)} from a Cobertura report."""
modules = {}
def read_report(report):
"""({module: (statements, covered)}, {module: {line number: hits}}, source directory) from a Cobertura report."""
modules, lines_of = {}, {}
root = ET.parse(report).getroot()
sources = [s.text or '' for s in root.iter('source')]
source = sources[0] if len(sources) == 1 else ''
for cls in root.iter('class'):
lines = [int(line.get('hits')) for line in cls.iter('line')]
name = module_name(cls.get('filename'), source)
lines = {int(line.get('number')): int(line.get('hits')) for line in cls.iter('line')}
statements, covered = modules.get(name, (0, 0))
modules[name] = (statements + len(lines), covered + sum(1 for hits in lines if hits > 0))
return modules
modules[name] = (statements + len(lines), covered + sum(1 for hits in lines.values() if hits > 0))
lines_of.setdefault(name, {}).update(lines)
return modules, lines_of, source


def measure(report):
"""{module: (statements, covered)} from a Cobertura report."""
return read_report(report)[0]


def class_span(path, class_name):
"""(first, last) line of a top-level class in a Python file, or None."""
try:
with open(path) as f:
tree = ast.parse(f.read())
except (OSError, SyntaxError):
return None
for node in tree.body:
if isinstance(node, ast.ClassDef) and node.name == class_name:
return node.lineno, node.end_lineno
return None


def parts(floors, modules, lines_of, source):
"""{floor key: (statements, covered)} for the floors that name a part of the package (see the docstring):
an aggregate ("proteus/kernels/") or one class ("proteus/StepControl.py::Fixed_dt_controller_systemit").
A part that cannot be found is left out, so it is reported as a floor for something no longer measured."""
found = {}
for key in floors:
if key.endswith('/'):
members = [v for name, v in modules.items() if name.startswith(key)]
if members:
found[key] = (sum(s for s, _ in members), sum(c for _, c in members))
elif '::' in key:
module, _, class_name = key.partition('::')
if module not in lines_of:
continue
# the report's file names are relative to its <source> (a combined report) or absolute (one run's)
path = os.path.join(source, module[len('proteus/'):]) if source else module
span = class_span(path, class_name)
if span is None:
continue
lines = [h for n, h in lines_of[module].items() if span[0] <= n <= span[1]]
if lines:
found[key] = (len(lines), sum(1 for h in lines if h > 0))
return found


def percent(statements, covered):
Expand Down Expand Up @@ -160,21 +210,25 @@ def main(argv=None):
parser.add_argument('--partial', action='store_true')
parser.add_argument('--write-floors', action='store_true')
args = parser.parse_args(argv)
modules = measure(args.report)
modules, lines_of, source = read_report(args.report)
floors = {}
if os.path.exists(args.floors):
with open(args.floors) as f:
floors = json.load(f)
drops, rises, new, unchecked, gone = compare(modules, floors)
# the floors of parts (aggregates, classes) are checked beside the modules'; the tables list modules only
named = parts(floors, modules, lines_of, source)
drops, rises, new, unchecked, gone = compare({**modules, **named}, floors)
new = [n for n in new if n[0] in modules]
sys.stdout.write(tables(modules, drops, rises, new, unchecked, gone, args.partial))
# a report whose module names do not match the floors' checks nothing, and would pass
if floors and not args.write_floors and len(set(floors) & set(modules)) < len(floors) // 2:
module_floors = [k for k in floors if not (k.endswith('/') or '::' in k)]
if module_floors and not args.write_floors and len(set(module_floors) & set(modules)) < len(module_floors) // 2:
sys.stderr.write('only %d of %d floors name a module in this report (first module: %s): '
'the report and the floors disagree about module names\n'
% (len(set(floors) & set(modules)), len(floors), min(modules) if modules else 'none'))
% (len(set(module_floors) & set(modules)), len(module_floors), min(modules) if modules else 'none'))
return 1
if args.write_floors:
write_floors(args.floors, modules, floors)
write_floors(args.floors, {**modules, **named}, floors)
return 0
if drops:
sys.stderr.write('%d module(s) below their coverage floor: %s\n'
Expand Down
4 changes: 4 additions & 0 deletions environment-dev-up.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ dependencies:
# errors without it, because the pure-Python dumper is ~3.2x slower and the
# archive is written every timestep. conda-forge's pyyaml is built with it.
- pyyaml >=6.0.2
# conda-forge yaml 0.2.6 ships libyaml-0.1.dylib, but pyyaml 6.0.3 and petsc4py are built against libyaml-0.2.dylib
# (yaml >=0.2.5,<0.3): on macOS a fresh solve gets 0.2.6 and `import petsc4py` fails with 'Library not loaded:
# @rpath/libyaml-0.2.dylib'. Written as a range so the off-lock legs' pin-to-floor rewrite leaves it alone.
- yaml >=0.2.5,<0.2.6
- sympy >=1.13.2
- strictyaml >=1.7.3
# provides `dot` for the docs inheritance diagrams
Expand Down
4 changes: 4 additions & 0 deletions environment-mpich-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ dependencies:
# errors without it, because the pure-Python dumper is ~3.2x slower and the
# archive is written every timestep. conda-forge's pyyaml is built with it.
- pyyaml =6.0.2
# conda-forge yaml 0.2.6 ships libyaml-0.1.dylib, but pyyaml 6.0.3 and petsc4py are built against libyaml-0.2.dylib
# (yaml >=0.2.5,<0.3): on macOS a fresh solve gets 0.2.6 and `import petsc4py` fails with 'Library not loaded:
# @rpath/libyaml-0.2.dylib'. Written as a range so the off-lock legs' pin-to-floor rewrite leaves it alone.
- yaml >=0.2.5,<0.2.6
# ymf itself has no conda-forge feedstock yet, so it is installed from PyPI
# with pip, at a floor (not a moving git branch): ymf 0.3.0 at @main broke
# main's test/dispatch for half a day on 2026-11-17/18 and every run that
Expand Down
4 changes: 4 additions & 0 deletions environment-openmpi-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ dependencies:
# errors without it, because the pure-Python dumper is ~3.2x slower and the
# archive is written every timestep. conda-forge's pyyaml is built with it.
- pyyaml =6.0.2
# conda-forge yaml 0.2.6 ships libyaml-0.1.dylib, but pyyaml 6.0.3 and petsc4py are built against libyaml-0.2.dylib
# (yaml >=0.2.5,<0.3): on macOS a fresh solve gets 0.2.6 and `import petsc4py` fails with 'Library not loaded:
# @rpath/libyaml-0.2.dylib'. Written as a range so the off-lock legs' pin-to-floor rewrite leaves it alone.
- yaml >=0.2.5,<0.2.6
# ymf itself has no conda-forge feedstock yet, so it is installed from PyPI
# with pip, at a floor (not a moving git branch): ymf 0.3.0 at @main broke
# main's test/dispatch for half a day on 2026-11-17/18 and every run that
Expand Down
2 changes: 2 additions & 0 deletions proteus/cli/msh.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ def run(args):
return 2

from proteus import Context, Profiling
# Comm.init() starts PETSc without setting it, and openLog asserts on it (pro run sets it the same way)
Profiling.procID = comm.rank()
if args.verbose:
Profiling.verbose = True
if args.log_level > 0:
Expand Down
26 changes: 24 additions & 2 deletions proteus/cli/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,34 @@ def add_parser(subparsers):
return p


def _module_level_statements(body):
"""Every statement that runs when the module is imported: the module's own, and those inside its ``if``,
``try``, ``with`` and loop blocks, but not inside a function or class."""
for node in body:
yield node
if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef, ast.ClassDef)):
continue
for field in ("body", "orelse", "finalbody"):
inner = getattr(node, field, None)
if isinstance(inner, list):
yield from _module_level_statements(inner)
for handler in getattr(node, "handlers", ()):
yield from _module_level_statements(handler.body)


def model_kind(path):
"""'so' if the file assigns ``pnList`` at module level, else 'case'.
"""'so' if the file assigns ``pnList`` when it is imported, else 'case'.

``pnList`` may be assigned in an ``if``/``else`` or ``try`` at module level, as the air-water-vv so
files do (``if tank3D.useOnlyVF: pnList = ... else: pnList = ...``); an assignment inside a function
or class does not count.

Read from the source, so nothing is imported (an import would run the
model before the context options are set).
"""
with open(path) as f:
tree = ast.parse(f.read(), path)
for node in tree.body:
for node in _module_level_statements(tree.body):
targets = []
if isinstance(node, ast.Assign):
targets = node.targets
Expand Down Expand Up @@ -316,6 +335,9 @@ def _bring_mesh_up_to_date(args, comm, pList, nList, log):
domain, meshOptions, plan = plan_for(pList, nList)
if plan is None or not meshOptions.genMesh:
return None
# Every rank has loaded the model, so none is still writing the generator's input: a model that rewrites its .poly on
# every rank at import (air-water-vv 45DEG_R1, 3072 ranks) had it hashed mid-rewrite, and a current mesh read as stale.
comm.barrier()
error = None
if comm.isMaster():
state, reason = mesh.state(plan)
Expand Down
Loading
Loading