Skip to content

toolchain: batch example-case validation in precheck (~7x faster)#1634

Merged
sbryngelson merged 1 commit into
MFlowCode:masterfrom
sbryngelson:speedup-precheck-validate
Jul 8, 2026
Merged

toolchain: batch example-case validation in precheck (~7x faster)#1634
sbryngelson merged 1 commit into
MFlowCode:masterfrom
sbryngelson:speedup-precheck-validate

Conversation

@sbryngelson

Copy link
Copy Markdown
Member

What

./mfc.sh precheck's example-case step (check 7/7) ran ./mfc.sh validate once per case in a serial loop over all 155 examples/*/case.py. Each invocation re-paid the mfc.sh/venv bootstrap (~2.4s), which dominated (~90%) the ~6.5 min serial cost of that step.

validate now accepts multiple case files (nargs="+") and validates them all in one process: load + constraint-check each, failing only on a genuine load/parse error — matching the historical per-file exit behavior (a single ./mfc.sh validate exits non-zero only on a load error; constraint issues are warnings). precheck.sh calls ./mfc.sh validate examples/*/case.py once instead of looping.

Impact

Before After
Full precheck (idle node) ~394 s ~56 s (~7×)
Example-case step 155 serial validate calls 1 batched call, 155/155 in one process

Correctness is unchanged — all 155 cases are still loaded and constraint-checked; only the process/bootstrap overhead is removed. The single-file ./mfc.sh validate case.py path is untouched.

Changes (4 files, +52/−14)

  • toolchain/mfc/validate.py_validate_batch() for the multi-file path
  • toolchain/mfc/cli/commands.pyvalidate positional gains nargs="+"
  • toolchain/mfc/args.py — abspath loop handles the list case
  • toolchain/bootstrap/precheck.sh — step 7 is a single batched validate call

Validation

Full precheck green (all 7 checks) — the commit's own pre-commit hook prechecked itself in ~56 s. Batch validates 155/155 example cases in one process.

Copilot AI review requested due to automatic review settings July 8, 2026 17:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR speeds up ./mfc.sh precheck by batching validation of all examples/*/case.py files into a single ./mfc.sh validate invocation, avoiding repeated toolchain/venv bootstrap overhead while preserving the historical “only fail on load/parse errors” behavior.

Changes:

  • Add a multi-file validation path in toolchain/mfc/validate.py to load and constraint-check many cases in one process.
  • Update the CLI to accept one or more positional input files (nargs="+") and normalize them to absolute paths.
  • Change precheck.sh example-case validation step from a per-case loop to a single batched validate call.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
toolchain/mfc/validate.py Adds _validate_batch() and routes multi-file inputs through it.
toolchain/mfc/cli/commands.py Changes validate positional input to accept multiple files (nargs="+").
toolchain/mfc/args.py Converts input to absolute paths when it is a list (multi-file validate).
toolchain/bootstrap/precheck.sh Replaces serial per-case validate loop with one batched validate invocation.

Comment thread toolchain/mfc/validate.py
Comment thread toolchain/mfc/validate.py Outdated
@github-actions

This comment was marked as resolved.

The precheck example-case step (7/7) ran './mfc.sh validate' once per case in a
serial loop over all 155+ examples/*/case.py. Each invocation re-paid the
mfc.sh/venv bootstrap (~2.4s), which dominated (~90%) the ~6.5min serial cost.

Validate now accepts multiple case files (nargs="+") and validates them all in
ONE process (_validate_batch): load+constraint-check each, fail only on a load
error - matching the historical per-file exit behavior. precheck.sh calls
'./mfc.sh validate examples/*/case.py' once. Full precheck drops from ~394s to
~51s (~7x) on an idle node; correctness unchanged (all cases still validated).

Batch mode still surfaces cases with constraint issues (listed in the summary,
exit 0) so the output is not misleading, and --migrate with multiple files fails
fast (it rewrites a file in place - single-case only) instead of a silent no-op.

VALIDATED: full precheck green (all 7 checks); batch validates 158/158 cases in
one process; single-file './mfc.sh validate' path unchanged.
@sbryngelson sbryngelson force-pushed the speedup-precheck-validate branch from ff5ced2 to 55b3562 Compare July 8, 2026 17:10
@sbryngelson sbryngelson requested review from Copilot and removed request for Copilot July 8, 2026 17:11
@sbryngelson sbryngelson merged commit 5cbb962 into MFlowCode:master Jul 8, 2026
84 checks passed
@sbryngelson sbryngelson deleted the speedup-precheck-validate branch July 8, 2026 17:15
@codecov

codecov Bot commented Jul 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.07%. Comparing base (102def2) to head (55b3562).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1634      +/-   ##
==========================================
+ Coverage   60.88%   61.07%   +0.18%     
==========================================
  Files          83       83              
  Lines       19836    19925      +89     
  Branches     2953     2975      +22     
==========================================
+ Hits        12077    12169      +92     
+ Misses       5767     5753      -14     
- Partials     1992     2003      +11     

☔ 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.

drcole17 added a commit to cmtl-wpi/MFC-drcole that referenced this pull request Jul 9, 2026
Sync 8 upstream commits: BC-routine unification (MFlowCode#1629), synthetic
turbulence (MFlowCode#1548), extrusion v3 (MFlowCode#1349), amdflang CPU builds (MFlowCode#1635),
batched example validation (MFlowCode#1634).

Conflicts (all 'both added, keep both'):
- m_global_parameters_common.fpp: thermal_conduction + synthetic_turbulence GPU_DECLAREs
- m_checker.fpp: thermal_conduction/visc_model + synthetic_turbulence checks
- m_start_up.fpp: conduction finalize + broadened body-forces finalize condition

Verified: all 3 targets build+install on gfortran CPU.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants