From 4d67d2cc5513f569bc06b0b11ecf34254dce2fc5 Mon Sep 17 00:00:00 2001 From: salman Date: Wed, 2 Sep 2026 15:36:13 +0200 Subject: [PATCH] Report "nothing to fit" when all series runs are skipped Setting every series action chip to skip (or selecting only already-fitted runs) left no runnable candidate and no reusable reference, so the series runner fell into the bootstrap path and failed with the internal series-bootstrap-first-run-blocked error ("The first selected run has no complete data set"). Detect pendingTotal === 0 up front and report a clear message instead of entering the bootstrap path or requiring a runner. --- muSRFitlib.js | 27 ++++++++++++++++-- tests/series-fit-routing.test.js | 48 ++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 3 deletions(-) diff --git a/muSRFitlib.js b/muSRFitlib.js index b959651..a9574e4 100644 --- a/muSRFitlib.js +++ b/muSRFitlib.js @@ -10455,6 +10455,30 @@ async function runIndependentSeriesFit(execution, webMode) { return 0; } + let reused = plan.summary.skip; + let pendingTotal = plan.summary.fit + plan.summary.retry + plan.summary.refit; + let bootstrapSequence = null; + if (pendingTotal === 0) { + // Every selected run is skipped (all chips set to skip, or all existing + // MSRs are already converged). There is nothing left to fit or reuse as a + // reference, so report this clearly before requiring a runner or entering + // the bootstrap path. + let message = reused > 0 + ? "All selected runs are already fitted and none were set for a refit; " + + reused + " reused." + : "No run is scheduled to be fitted; set at least one run to refit or reuse."; + updateJobStatus({ + state: "Complete", + message: message, + messageDetail: message, + noticeLevel: "info", + finishedAt: jobTimestamp(), + exitCode: "" + }); + appendJobLog(message); + return 1; + } + let referenceEntry = plan.entries.find(function(entry) { return entry.reusable === true && entry.action == "skip" && entry.msrExists === true; }); @@ -10468,9 +10492,6 @@ async function runIndependentSeriesFit(execution, webMode) { } setMusrfitActionState("fit", "running"); - let reused = plan.summary.skip; - let pendingTotal = plan.summary.fit + plan.summary.retry + plan.summary.refit; - let bootstrapSequence = null; if (!referenceEntry) { if (!validateRRFSettings("Fit", config.all)) { finishJobStatus(0, 1, "Check the RRF settings before fitting the first run."); diff --git a/tests/series-fit-routing.test.js b/tests/series-fit-routing.test.js index eb1971d..cf9b586 100644 --- a/tests/series-fit-routing.test.js +++ b/tests/series-fit-routing.test.js @@ -258,11 +258,59 @@ async function testMissingReferenceBootstrapsFirstRun() { }); } +async function testAllRunsSkippedReportsNothingToFit() { + // When every run is set to skip (e.g. the bulk "All" selector), there is + // nothing to fit and no reference to bootstrap from. This must produce a + // clear "nothing to fit" message instead of the internal + // series-bootstrap-first-run-blocked error. + const lib = loadLibrary(); + lib.All.runNumbers = "2531,2534,2536"; + lib.collectSharedParameterControls = function() { return {}; }; + lib.checkDir = function() { return 1; }; + lib.updateJobStatus = function() {}; + lib.appendJobLog = function() {}; + lib.validateRRFSettings = function() { return 1; }; + lib.validateT0BgOverrides = function() { return { ok: 1, message: "" }; }; + + const plan = { + ok: true, + mode: "series", + entries: [ + { run: 2531, action: "skip", reusable: false, msrExists: true, dataSet: { main: 2531, add: [] } }, + { run: 2534, action: "skip", reusable: false, msrExists: true, dataSet: { main: 2534, add: [] } }, + { run: 2536, action: "skip", reusable: false, msrExists: true, dataSet: { main: 2536, add: [] } } + ], + summary: { total: 3, fit: 0, retry: 0, refit: 0, skip: 3, blocked: 0 } + }; + lib.inspectSeriesFitPlan = async function() { return plan; }; + + let bootstrapCalls = 0; + lib.prepareSeriesBootstrapCandidate = function() { + bootstrapCalls++; + return { ok: true, candidates: [] }; + }; + + let finished = null; + lib.finishJobStatus = function(ok, code, message) { + finished = { ok: ok, code: code, message: message }; + }; + + const result = await lib.runIndependentSeriesFit( + { mode: "series", dataSetCount: 3 }, false + ); + assert.strictEqual(result, 1); + assert.strictEqual(bootstrapCalls, 0, + "bootstrap must not be attempted when all runs are skipped"); + assert.strictEqual(finished, null, + "the all-skip case should be reported via updateJobStatus, not finishJobStatus failure"); +} + (async function main() { testCurrentRouteClassification(); await testFitButtonUsesSeriesRoute(); await testEstablishedRoutesRemainUnchanged(); await testMissingReferenceBootstrapsFirstRun(); + await testAllRunsSkippedReportsNothingToFit(); console.log("series fit routing tests passed"); })().catch(function(error) { console.error(error);