GUI: abgebrochenen oder teils ausgefallenen Batch fortsetzen

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-07 19:25:25 +01:00
parent 52b13bd269
commit e322a14030
3 changed files with 16 additions and 7 deletions

View File

@ -183,6 +183,7 @@ async fn discover_models(adapter: String, url: String, api_key_env: String) -> R
} }
/// Startet einen Batch mit den angegebenen Modellen (Anzeigenamen) und Aufgaben-IDs. /// Startet einen Batch mit den angegebenen Modellen (Anzeigenamen) und Aufgaben-IDs.
/// Mit `batch_id` wird ein bestehender Batch fortgesetzt: fertige Läufe werden übersprungen.
/// Fortschritt kommt als Ereignis `batch-event`. Das Ergebnis ist die Zusammenfassung. /// Fortschritt kommt als Ereignis `batch-event`. Das Ergebnis ist die Zusammenfassung.
#[tauri::command] #[tauri::command]
async fn start_batch( async fn start_batch(
@ -194,6 +195,7 @@ async fn start_batch(
task_ids: Vec<String>, task_ids: Vec<String>,
repeats: u32, repeats: u32,
note: String, note: String,
batch_id: Option<i64>,
) -> Result<BatchSummary, String> { ) -> Result<BatchSummary, String> {
if models.is_empty() || task_ids.is_empty() { if models.is_empty() || task_ids.is_empty() {
return Err("Mindestens ein Modell und eine Aufgabe wählen.".into()); return Err("Mindestens ein Modell und eine Aufgabe wählen.".into());
@ -262,7 +264,7 @@ async fn start_batch(
let on_event = |e: &Event| { let on_event = |e: &Event| {
let _ = emitter.emit(EVENT_NAME, e); let _ = emitter.emit(EVENT_NAME, e);
}; };
runner::run_batch(&mut store, &run_cfg, None, &note, repeats, &jobs, &cancel, &on_event) runner::run_batch(&mut store, &run_cfg, batch_id, &note, repeats, &jobs, &cancel, &on_event)
}) })
.await .await
.map_err(|e| format!("Batch-Thread abgebrochen: {e}"))?; .map_err(|e| format!("Batch-Thread abgebrochen: {e}"))?;

View File

@ -160,7 +160,7 @@
return (tasks?.tasks ?? []).filter((t) => chosenTasks.includes(t.id)); return (tasks?.tasks ?? []).filter((t) => chosenTasks.includes(t.id));
} }
async function start() { async function start(resumeBatch: number | null = null) {
error = ""; error = "";
log = []; log = [];
progress = null; progress = null;
@ -170,7 +170,7 @@
for (const m of chosenModels) for (const t of chosenTaskInfos()) cells[key(m, t.id)] = { state: "planned", n: 0, sum: 0, cls: "" }; for (const m of chosenModels) for (const t of chosenTaskInfos()) cells[key(m, t.id)] = { state: "planned", n: 0, sum: 0, cls: "" };
running = true; running = true;
try { try {
const s = await api.startBatch($state.snapshot(chosenModels), $state.snapshot(chosenTasks), repeats, ""); const s = await api.startBatch($state.snapshot(chosenModels), $state.snapshot(chosenTasks), repeats, "", resumeBatch);
finishedBatch = s.batch_id; finishedBatch = s.batch_id;
cancelled = s.cancelled; cancelled = s.cancelled;
} catch (e) { } catch (e) {
@ -182,6 +182,10 @@
} }
} }
// Offen ist, was nicht fertig gewertet wurde: abgebrochen oder durch einen Ausfall nicht gewertet.
let openCells = $derived(Object.values(cells).filter((c) => c.state !== "done" && c.state !== "skipped").length);
let canResume = $derived(!running && finishedBatch !== null && openCells > 0);
function cellOf(model: string, task: string): Cell | undefined { function cellOf(model: string, task: string): Cell | undefined {
return cells[key(model, task)]; return cells[key(model, task)];
} }
@ -347,8 +351,11 @@
{#if error}<p class="error">{error}</p>{/if} {#if error}<p class="error">{error}</p>{/if}
{#if finishedBatch !== null} {#if finishedBatch !== null}
<p> <p>
{cancelled ? "Abgebrochen." : "Fertig."} {cancelled ? "Abgebrochen." : openCells > 0 ? `Fertig, aber ${openCells} Zelle(n) offen oder nicht gewertet.` : "Fertig."}
<button class="link" onclick={() => onfinished(finishedBatch!)}>Ergebnisse ansehen</button> <button class="link" onclick={() => onfinished(finishedBatch!)}>Ergebnisse ansehen</button>
{#if canResume}
· <button class="link" onclick={() => start(finishedBatch)}>Fortsetzen</button>
{/if}
</p> </p>
{/if} {/if}
{#if log.length > 0} {#if log.length > 0}
@ -384,7 +391,7 @@
Durchläufe Durchläufe
<input type="number" min="1" max="20" bind:value={repeats} disabled={running} /> <input type="number" min="1" max="20" bind:value={repeats} disabled={running} />
</label> </label>
<button class="primary" onclick={start} disabled={!canStart}>Benchmark starten</button> <button class="primary" onclick={() => start()} disabled={!canStart}>Benchmark starten</button>
<button class="danger" onclick={() => api.cancelBatch()} disabled={!running}>Abbrechen</button> <button class="danger" onclick={() => api.cancelBatch()} disabled={!running}>Abbrechen</button>
{#if progress} {#if progress}
<div class="progress"> <div class="progress">

View File

@ -108,8 +108,8 @@ export const api = {
discoverModels: (adapter: string, url: string, apiKeyEnv: string) => discoverModels: (adapter: string, url: string, apiKeyEnv: string) =>
invoke<string[]>("discover_models", { adapter, url, apiKeyEnv }), invoke<string[]>("discover_models", { adapter, url, apiKeyEnv }),
testModel: (name: string) => invoke<ModelTest>("test_model", { name }), testModel: (name: string) => invoke<ModelTest>("test_model", { name }),
startBatch: (models: string[], taskIds: string[], repeats: number, note: string) => startBatch: (models: string[], taskIds: string[], repeats: number, note: string, batchId: number | null = null) =>
invoke<BatchSummary>("start_batch", { models, taskIds, repeats, note }), invoke<BatchSummary>("start_batch", { models, taskIds, repeats, note, batchId }),
cancelBatch: () => invoke<boolean>("cancel_batch"), cancelBatch: () => invoke<boolean>("cancel_batch"),
batches: () => invoke<BatchInfo[]>("list_batches"), batches: () => invoke<BatchInfo[]>("list_batches"),
results: (batchId: number) => invoke<RunRow[]>("batch_results", { batchId }), results: (batchId: number) => invoke<RunRow[]>("batch_results", { batchId }),