Skip to content

Console scripts: abort all ranks on an uncaught exception (issue #807) - #815

Open
DLWoodruff wants to merge 2 commits into
Pyomo:mainfrom
DLWoodruff:mpi-abort-entry-points
Open

Console scripts: abort all ranks on an uncaught exception (issue #807)#815
DLWoodruff wants to merge 2 commits into
Pyomo:mainfrom
DLWoodruff:mpi-abort-entry-points

Conversation

@DLWoodruff

Copy link
Copy Markdown
Collaborator

Closes #807.

The pip console entry points (mpi-sppy-generic-cylinders, mpi-sppy-mrp-generic, mpi-sppy-one-sided-test) bypass python -m mpi4py, whose runner prints the traceback and calls MPI_Abort when a rank raises. Without that, an uncaught exception on one rank leaves the other ranks blocked in a collective and the whole mpiexec job hangs — which is why the docs recommended the -m mpi4py module form over the console scripts.

This PR wraps the three entry-point targets in a new mpisppy/entry_points.py: on an uncaught exception with world size > 1, print the traceback and call MPI.COMM_WORLD.Abort(1), replicating the mpi4py runner's behavior (the "create our own script" idea from the issue, which turned out to need no special launcher — just a ~15-line wrapper). Serial runs re-raise normally so tracebacks and exit codes are unchanged, SystemExit (argparse --help/usage errors) passes through untouched, and the no-mpi4py mock comm in mpisppy.MPI (which has no Abort) is left alone.

Verified end-to-end with a two-rank probe where rank 1 raises while rank 0 waits in a barrier: bare, the job hangs until an external timeout kills it; wrapped, MPI_ABORT fires immediately. Also smoke-tested mpiexec -n 2 mpi-sppy-one-sided-test and a 3-rank farmer run of mpi-sppy-generic-cylinders (both clean), plus new serial unit tests for the wrapper (wired into run_coverage.bash and test_pr_and_main.yml).

Docs: the issue's other half (prefer python -m mpi4py in docs/examples) was mostly done in #803 — 17 of 20 mpiexec ... python doc invocations already used it. This PR converts the two genuine stragglers (debug_utils.rst, the L-shaped example in generic_cylinders.rst) and updates the notes that steered users away from the console scripts for multi-rank runs, since both forms are now equally safe.

🤖 Generated with Claude Code

…o#807)

The pip entry points bypass python -m mpi4py, whose runner calls
MPI_Abort when a rank raises, so an exception on one rank could leave
the others blocked in a collective and hang the whole mpiexec job.
Wrap the three console-script targets in mpisppy.entry_points so they
install the same protection; serial runs re-raise normally and the
no-mpi4py mock comm (which has no Abort) is left alone.

Also switch the last doc examples to the python -m mpi4py form and
update the notes that recommended it over the console scripts, since
the two are now equally safe.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@codecov

codecov Bot commented Jul 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.38%. Comparing base (3749661) to head (4b5bf2e).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #815      +/-   ##
==========================================
+ Coverage   76.33%   76.38%   +0.04%     
==========================================
  Files         170      171       +1     
  Lines       22628    22650      +22     
==========================================
+ Hits        17274    17301      +27     
+ Misses       5354     5349       -5     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

The wrappers' bodies (real import + call) were only checked as callable,
leaving them unexecuted. Drive each real wrapper end-to-end on its cheap
serial path -- no arguments (and one rank) makes every wrapped main print
usage and raise SystemExit, which the wrapper must pass through -- so a
broken import target fails in the test suite instead of on a user's
command line. entry_points.py is now at 100% statement coverage.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Investigate inserting -m mpi4py into driver scripts

1 participant