feat: Batch aus der Oberfläche starten
Tauri-Befehle start_batch, cancel_batch, batch_results. Fortschritt läuft als Ereignis batch-event. Datenbank coding-bench.sqlite im Datenordner. Oberfläche: Aufgaben wählen, Modelle und Wiederholungen angeben, starten, abbrechen, Live-Log und Ergebnistabelle. Ollama-URL in config.toml. 40 Unit-Tests grün, svelte-check ohne Fehler. Im Fenster nicht geprüft. lib.rs wurde vor meiner Änderung auf der Platte zurückgesetzt (ohne runner/store); ich habe auf dem aktuellen Stand aufgebaut. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
This commit is contained in:
12
ROADMAP.md
12
ROADMAP.md
@ -22,10 +22,10 @@ Zeichen: ✓ fertig · ◐ teilweise · ✗ offen · ? nicht geprüft.
|
|||||||
| #1002 | F-02 Aufgaben laden und validieren | SPEC 4, 12 | ◐ | Umgesetzt: Laden, Validierung (Pflichtdateien, TOML, Werte, `check.sh` ausführbar), Fehler im Setup. `cargo test` 13/13. Klicktests `aufgabe2validierung.1–.2` manuell offen (→ #1019) |
|
| #1002 | F-02 Aufgaben laden und validieren | SPEC 4, 12 | ◐ | Umgesetzt: Laden, Validierung (Pflichtdateien, TOML, Werte, `check.sh` ausführbar), Fehler im Setup. `cargo test` 13/13. Klicktests `aufgabe2validierung.1–.2` manuell offen (→ #1019) |
|
||||||
| #1003 | F-03 Agent-Loop gegen Ollama mit Tools und Fehlerklassen | SPEC 5, 12 | ◐ | Loop, Tools, Pfadprüfung, Fehlerklassen und Metriken in `agent.rs`. 31 Unit-Tests grün (Mock-Modell). Werkzeuge gegen echte Sandbox grün. Echter Lauf gegen Ollama auf srv04 mit `qwen3:0.6b` bestanden (ignorierter Test `ollama_lauf_schreibt_datei_und_beendet`: Datei geschrieben, `done` aufgerufen). Offen: größere Modelle, Klicktests `lauf2ergebnis.1–.3` (→ #1021) |
|
| #1003 | F-03 Agent-Loop gegen Ollama mit Tools und Fehlerklassen | SPEC 5, 12 | ◐ | Loop, Tools, Pfadprüfung, Fehlerklassen und Metriken in `agent.rs`. 31 Unit-Tests grün (Mock-Modell). Werkzeuge gegen echte Sandbox grün. Echter Lauf gegen Ollama auf srv04 mit `qwen3:0.6b` bestanden (ignorierter Test `ollama_lauf_schreibt_datei_und_beendet`: Datei geschrieben, `done` aufgerufen). Offen: größere Modelle, Klicktests `lauf2ergebnis.1–.3` (→ #1021) |
|
||||||
| #1004 | F-04 Podman-Sandbox pro Lauf | SPEC 6, 12 | ◐ | Modul `sandbox.rs` steht: Start ohne Netz, Limits, Kopieren nach `/work`, `exec` mit Timeout, Export, Entfernen. Limits und Runtime kommen aus `config.toml`. Echter Lauf gegen Podman mit Image `cb-python:latest` bestanden (ignorierter Test). Noch nicht an den Runner angebunden (#1022); Klicktests `lauf2sandbox.1–.2` manuell offen (→ #1020) |
|
| #1004 | F-04 Podman-Sandbox pro Lauf | SPEC 6, 12 | ◐ | Modul `sandbox.rs` steht: Start ohne Netz, Limits, Kopieren nach `/work`, `exec` mit Timeout, Export, Entfernen. Limits und Runtime kommen aus `config.toml`. Echter Lauf gegen Podman mit Image `cb-python:latest` bestanden (ignorierter Test). Noch nicht an den Runner angebunden (#1022); Klicktests `lauf2sandbox.1–.2` manuell offen (→ #1020) |
|
||||||
| #1005 | F-05 Runner mit Wiederholungen, Abbruch, Fortsetzen | SPEC 7, 12 | ◐ | `runner.rs`: Plan, Warm-up je Modell, Sandbox pro Lauf, `check.sh`, Abbruch, Fortsetzen über die DB. Ende-zu-Ende gegen srv04 mit `qwen3:0.6b` grün (2 Läufe, dann Fortsetzen überspringt beide). Abbruch im Lauf nicht real getestet. Noch nicht an Commands/GUI angebunden (→ #1022) |
|
| #1005 | F-05 Runner mit Wiederholungen, Abbruch, Fortsetzen | SPEC 7, 12 | ◐ | `runner.rs`: Plan, Warm-up je Modell, Sandbox pro Lauf, `check.sh`, Abbruch, Fortsetzen über die DB. Ende-zu-Ende gegen srv04 mit `qwen3:0.6b` grün (2 Läufe, dann Fortsetzen überspringt beide). Abbruch im Lauf nicht real getestet. Über Tauri-Befehle `start_batch`, `cancel_batch` angebunden, Ereignisse `batch-event` (→ #1022) |
|
||||||
| #1006 | F-06 SQLite inkl. Schritt-Log | SPEC 8, 12 | ◐ | `store.rs`: Tabellen `batch`, `run`, `step` nach SPEC 8, Lauf und Schritte in einer Transaktion. Getestet in-memory. Datei-Datenbank im Datenordner noch nicht angebunden (→ #1023) |
|
| #1006 | F-06 SQLite inkl. Schritt-Log | SPEC 8, 12 | ◐ | `store.rs`: Tabellen `batch`, `run`, `step` nach SPEC 8, Lauf und Schritte in einer Transaktion. Datei `coding-bench.sqlite` im Datenordner, wird beim Start angelegt. Lesen über `batch_results`. Getestet in-memory und im Batch (→ #1023) |
|
||||||
| #1007 | F-07 Tests a-01 bis a-03 und b-04 bis b-06 | SPEC 11, 12 | ✗ | noch nicht begonnen (→ #1024) |
|
| #1007 | F-07 Tests a-01 bis a-03 und b-04 bis b-06 | SPEC 11, 12 | ✗ | noch nicht begonnen (→ #1024) |
|
||||||
| #1008 | F-08 GUI: Setup, Batch starten, Live-Fortschritt | SPEC 10, 12 | ✗ | noch nicht begonnen (→ #1025) |
|
| #1008 | F-08 GUI: Setup, Batch starten, Live-Fortschritt | SPEC 10, 12 | ◐ | Setup zeigt Pfade und Aufgaben, Batch-Start mit Modellen, Wiederholungen, Abbrechen, Fortschritt und Ergebnistabelle gebaut. `svelte-check` 0 Fehler. Nicht im Fenster geprüft; Klicktests `batch2fortsetzen.1–.2` offen (→ #1025) |
|
||||||
| #1009 | F-09 Rangliste und Matrix | SPEC 9, 10, 12 | ✗ | noch nicht begonnen (→ #1026) |
|
| #1009 | F-09 Rangliste und Matrix | SPEC 9, 10, 12 | ✗ | noch nicht begonnen (→ #1026) |
|
||||||
| #1010 | F-10 Tests c-07 bis c-09 | SPEC 11, 12 | ✗ | Phase 2 (→ #1027) |
|
| #1010 | F-10 Tests c-07 bis c-09 | SPEC 11, 12 | ✗ | Phase 2 (→ #1027) |
|
||||||
| #1011 | F-11 Adapter Aider-Polyglot-Teilmenge | SPEC 12 | ✗ | Phase 2 (→ #1028) |
|
| #1011 | F-11 Adapter Aider-Polyglot-Teilmenge | SPEC 12 | ✗ | Phase 2 (→ #1028) |
|
||||||
@ -48,10 +48,10 @@ Zeichen: ✓ fertig · ◐ teilweise · ✗ offen · ? nicht geprüft.
|
|||||||
- [#1019] **Aufgaben laden und validieren.** Umgesetzt in `src-tauri/src/tasks.rs`, `cargo test` 13/13. Offen: Klicktests `aufgabe2validierung.1–.2` manuell ausführen lassen. Tests `aufgabe2validierung.1–.2`. → #1002
|
- [#1019] **Aufgaben laden und validieren.** Umgesetzt in `src-tauri/src/tasks.rs`, `cargo test` 13/13. Offen: Klicktests `aufgabe2validierung.1–.2` manuell ausführen lassen. Tests `aufgabe2validierung.1–.2`. → #1002
|
||||||
- [#1020] **Podman-Sandbox pro Lauf.** Modul gebaut (`src-tauri/src/sandbox.rs`). Echter Test `CB_TEST_IMAGE=docker.io/library/python:3.12-slim cargo test -- --ignored` grün: Startdatei in `/work`, Netz aus, Timeout erkannt, Export, Container entfernt. Limits und Runtime aus der Config. Image `cb-python` gebaut (`images/cb-python/Containerfile`, Python 3.12 und pytest). Der Test lief mit `CB_TEST_IMAGE=cb-python:latest` grün. Offen: Anbindung an den Runner (#1022), Klicktests `lauf2sandbox.1–.2` manuell. Tests `lauf2sandbox.1–.2`. → #1004
|
- [#1020] **Podman-Sandbox pro Lauf.** Modul gebaut (`src-tauri/src/sandbox.rs`). Echter Test `CB_TEST_IMAGE=docker.io/library/python:3.12-slim cargo test -- --ignored` grün: Startdatei in `/work`, Netz aus, Timeout erkannt, Export, Container entfernt. Limits und Runtime aus der Config. Image `cb-python` gebaut (`images/cb-python/Containerfile`, Python 3.12 und pytest). Der Test lief mit `CB_TEST_IMAGE=cb-python:latest` grün. Offen: Anbindung an den Runner (#1022), Klicktests `lauf2sandbox.1–.2` manuell. Tests `lauf2sandbox.1–.2`. → #1004
|
||||||
- [#1021] **Agent-Loop gegen Ollama.** Umgesetzt in `src-tauri/src/agent.rs`: fünf Tools, Pfade auf `/work`, Fehlerklassen, Schleifenerkennung, Metriken, Ollama-Client (`/api/chat`, ohne Streaming, Temperatur 0). Offen: echter Lauf gegen Ollama (Dienst starten, Modell laden), Klicktests `lauf2ergebnis.1–.3`. Tests `lauf2ergebnis.1–.3`. → #1003
|
- [#1021] **Agent-Loop gegen Ollama.** Umgesetzt in `src-tauri/src/agent.rs`: fünf Tools, Pfade auf `/work`, Fehlerklassen, Schleifenerkennung, Metriken, Ollama-Client (`/api/chat`, ohne Streaming, Temperatur 0). Offen: echter Lauf gegen Ollama (Dienst starten, Modell laden), Klicktests `lauf2ergebnis.1–.3`. Tests `lauf2ergebnis.1–.3`. → #1003
|
||||||
- [#1022] **Runner.** Umgesetzt in `src-tauri/src/runner.rs`. Offen: Abbruch über die GUI real prüfen, Anbindung an Tauri-Commands und Events, Modelle mit eigenem Endpunkt in der Config. Tests `batch2fortsetzen.1–.2`. → #1005
|
- [#1022] **Runner.** Umgesetzt in `src-tauri/src/runner.rs`, über `start_batch` und `cancel_batch` an die Oberfläche angebunden. Offen: Abbruch in der App real prüfen, Modelle mit eigenem Endpunkt in der Config (Phase 1 hat einen gemeinsamen `ollama_url`). Tests `batch2fortsetzen.1–.2`. → #1005
|
||||||
- [#1023] **SQLite-Speicher.** Umgesetzt in `src-tauri/src/store.rs`, Schema nach SPEC 8. Offen: Datei-Datenbank im Datenordner anlegen und an den Runner anbinden. Tests `lauf2ergebnis.2`. → #1006
|
- [#1023] **SQLite-Speicher.** Umgesetzt in `src-tauri/src/store.rs`, Schema nach SPEC 8. Datei-Datenbank im Datenordner angebunden. Offen: Klicktest `lauf2ergebnis.2` mit Schritt-Ansicht (noch keine Oberfläche dafür). Tests `lauf2ergebnis.2`. → #1006
|
||||||
- [#1024] **Aufgaben a-01 bis a-03, b-04 bis b-06 schreiben.** Mindestens je ein lauffähiges Beispiel, Mutation bei b-06. Tests: je Aufgabe ein Lauf mit Bericht. → #1007
|
- [#1024] **Aufgaben a-01 bis a-03, b-04 bis b-06 schreiben.** Mindestens je ein lauffähiges Beispiel, Mutation bei b-06. Tests: je Aufgabe ein Lauf mit Bericht. → #1007
|
||||||
- [#1025] **GUI Setup und Batch.** Modelle, Podman-Status, Datenordner, Aufgabenauswahl, Start, Live-Fortschritt mit Schritt-Log. Tests `batch2fortsetzen.1`. → #1008
|
- [#1025] **GUI Setup und Batch.** Gebaut: Pfade, Aufgabenauswahl, Modelle, Wiederholungen, Start, Abbrechen, Live-Log, Ergebnistabelle. Offen: Podman-Status im Setup, Schritt-Log in der Oberfläche, Klicktest `batch2fortsetzen.1` manuell. → #1008
|
||||||
- [#1026] **Rangliste und Matrix.** Gesamtscore mit Intervall, Matrix Modell × Test nach Erfolgsquote, Lauf-Detail. Tests `ergebnis2detail.1`. → #1009
|
- [#1026] **Rangliste und Matrix.** Gesamtscore mit Intervall, Matrix Modell × Test nach Erfolgsquote, Lauf-Detail. Tests `ergebnis2detail.1`. → #1009
|
||||||
|
|
||||||
**P2 – danach (Release 0.2.0, Referenz und Tiefe)**
|
**P2 – danach (Release 0.2.0, Referenz und Tiefe)**
|
||||||
|
|||||||
@ -21,6 +21,8 @@ pub struct Config {
|
|||||||
pub tasks_dir: Option<PathBuf>,
|
pub tasks_dir: Option<PathBuf>,
|
||||||
/// Container-Programm für die Sandbox (Podman-CLI).
|
/// Container-Programm für die Sandbox (Podman-CLI).
|
||||||
pub container_runtime: String,
|
pub container_runtime: String,
|
||||||
|
/// Ollama-Endpunkt für alle Modelle (Phase 1).
|
||||||
|
pub ollama_url: String,
|
||||||
/// Speicherlimit pro Lauf, Podman-Schreibweise.
|
/// Speicherlimit pro Lauf, Podman-Schreibweise.
|
||||||
pub sandbox_memory: String,
|
pub sandbox_memory: String,
|
||||||
/// CPU-Anteil pro Lauf.
|
/// CPU-Anteil pro Lauf.
|
||||||
@ -34,6 +36,7 @@ impl Default for Config {
|
|||||||
data_dir: None,
|
data_dir: None,
|
||||||
tasks_dir: None,
|
tasks_dir: None,
|
||||||
container_runtime: "podman".into(),
|
container_runtime: "podman".into(),
|
||||||
|
ollama_url: "http://127.0.0.1:11434".into(),
|
||||||
sandbox_memory: limits.memory,
|
sandbox_memory: limits.memory,
|
||||||
sandbox_cpus: limits.cpus,
|
sandbox_cpus: limits.cpus,
|
||||||
}
|
}
|
||||||
@ -130,6 +133,13 @@ mod tests {
|
|||||||
assert_eq!(c.container_runtime, "podman");
|
assert_eq!(c.container_runtime, "podman");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn ollama_url_hat_standard_und_ist_ueberschreibbar() {
|
||||||
|
assert_eq!(Config::default().ollama_url, "http://127.0.0.1:11434");
|
||||||
|
let c = Config::parse("ollama_url = \"http://srv04:11434\"\n").unwrap();
|
||||||
|
assert_eq!(c.ollama_url, "http://srv04:11434");
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn unbekannter_schluessel_ist_fehler() {
|
fn unbekannter_schluessel_ist_fehler() {
|
||||||
assert!(Config::parse("unbekannt = 1\n").is_err());
|
assert!(Config::parse("unbekannt = 1\n").is_err());
|
||||||
|
|||||||
@ -1,16 +1,31 @@
|
|||||||
mod agent;
|
mod agent;
|
||||||
mod config;
|
mod config;
|
||||||
mod runner;
|
mod runner;
|
||||||
mod store;
|
|
||||||
mod sandbox;
|
mod sandbox;
|
||||||
|
mod store;
|
||||||
mod tasks;
|
mod tasks;
|
||||||
|
|
||||||
use config::Paths;
|
use config::{Config, Paths};
|
||||||
use tauri::{Manager, State};
|
use runner::{BatchSummary, Event, RunConfig};
|
||||||
|
use std::sync::atomic::{AtomicBool, Ordering};
|
||||||
|
use std::sync::Arc;
|
||||||
|
use store::{RunRecord, Store};
|
||||||
|
use tauri::{Emitter, Manager, State};
|
||||||
|
|
||||||
|
pub const DB_FILE: &str = "coding-bench.sqlite";
|
||||||
|
pub const EVENT_NAME: &str = "batch-event";
|
||||||
|
|
||||||
/// Aufgelöste Pfade, einmal beim Start ermittelt.
|
/// Aufgelöste Pfade, einmal beim Start ermittelt.
|
||||||
pub struct AppPaths(pub Paths);
|
pub struct AppPaths(pub Paths);
|
||||||
|
|
||||||
|
/// Steuerung für den laufenden Batch. Es läuft immer nur einer.
|
||||||
|
pub struct RunState {
|
||||||
|
/// Gesetzt, wenn der laufende Batch abbrechen soll.
|
||||||
|
pub cancel: Arc<AtomicBool>,
|
||||||
|
/// Gesetzt, solange ein Batch läuft.
|
||||||
|
pub running: Arc<AtomicBool>,
|
||||||
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
fn get_paths(paths: State<'_, AppPaths>) -> Paths {
|
fn get_paths(paths: State<'_, AppPaths>) -> Paths {
|
||||||
paths.0.clone()
|
paths.0.clone()
|
||||||
@ -21,6 +36,88 @@ fn load_tasks(paths: State<'_, AppPaths>) -> tasks::LoadReport {
|
|||||||
tasks::load_all(&paths.0.tasks_dir)
|
tasks::load_all(&paths.0.tasks_dir)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Startet einen Batch mit den angegebenen Modellen und Aufgaben-IDs.
|
||||||
|
/// Fortschritt kommt als Ereignis `batch-event`. Das Ergebnis ist die Zusammenfassung.
|
||||||
|
#[tauri::command]
|
||||||
|
async fn start_batch(
|
||||||
|
app: tauri::AppHandle,
|
||||||
|
paths: State<'_, AppPaths>,
|
||||||
|
cfg: State<'_, Config>,
|
||||||
|
run: State<'_, RunState>,
|
||||||
|
models: Vec<String>,
|
||||||
|
task_ids: Vec<String>,
|
||||||
|
repeats: u32,
|
||||||
|
note: String,
|
||||||
|
) -> Result<BatchSummary, String> {
|
||||||
|
if models.is_empty() || task_ids.is_empty() {
|
||||||
|
return Err("Mindestens ein Modell und eine Aufgabe wählen.".into());
|
||||||
|
}
|
||||||
|
if repeats == 0 {
|
||||||
|
return Err("Wiederholungen müssen mindestens 1 sein.".into());
|
||||||
|
}
|
||||||
|
if run.running.swap(true, Ordering::SeqCst) {
|
||||||
|
return Err("Ein Batch läuft bereits.".into());
|
||||||
|
}
|
||||||
|
run.cancel.store(false, Ordering::SeqCst);
|
||||||
|
|
||||||
|
let report = tasks::load_all(&paths.0.tasks_dir);
|
||||||
|
let selected: Vec<tasks::Task> = report
|
||||||
|
.tasks
|
||||||
|
.into_iter()
|
||||||
|
.filter(|t| task_ids.contains(&t.meta.id))
|
||||||
|
.collect();
|
||||||
|
if selected.len() != task_ids.len() {
|
||||||
|
run.running.store(false, Ordering::SeqCst);
|
||||||
|
return Err("Mindestens eine gewählte Aufgabe ist nicht gültig geladen.".into());
|
||||||
|
}
|
||||||
|
let jobs = runner::plan(&models, &selected, repeats);
|
||||||
|
let run_cfg = RunConfig {
|
||||||
|
runtime: cfg.container_runtime.clone(),
|
||||||
|
endpoint_url: cfg.ollama_url.clone(),
|
||||||
|
data_dir: paths.0.data_dir.clone(),
|
||||||
|
limits: cfg.sandbox_limits(),
|
||||||
|
};
|
||||||
|
let db_path = paths.0.data_dir.join(DB_FILE);
|
||||||
|
let cancel = run.cancel.clone();
|
||||||
|
let running = run.running.clone();
|
||||||
|
let emitter = app.clone();
|
||||||
|
|
||||||
|
let result = tauri::async_runtime::spawn_blocking(move || {
|
||||||
|
let outcome = (|| -> Result<BatchSummary, String> {
|
||||||
|
let mut store = Store::open(&db_path)?;
|
||||||
|
let on_event = |e: &Event| {
|
||||||
|
let _ = emitter.emit(EVENT_NAME, e);
|
||||||
|
};
|
||||||
|
runner::run_batch(&mut store, &run_cfg, None, ¬e, repeats, &jobs, &cancel, &on_event)
|
||||||
|
})();
|
||||||
|
running.store(false, Ordering::SeqCst);
|
||||||
|
outcome
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.map_err(|e| format!("Batch-Thread abgebrochen: {e}"))?;
|
||||||
|
|
||||||
|
run.running.store(false, Ordering::SeqCst);
|
||||||
|
result
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Bricht den laufenden Batch ab. Der aktuelle Lauf wird verworfen.
|
||||||
|
/// Gibt `false` zurück, wenn gerade kein Batch läuft.
|
||||||
|
#[tauri::command]
|
||||||
|
fn cancel_batch(run: State<'_, RunState>) -> bool {
|
||||||
|
let running = run.running.load(Ordering::SeqCst);
|
||||||
|
if running {
|
||||||
|
run.cancel.store(true, Ordering::SeqCst);
|
||||||
|
}
|
||||||
|
running
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Alle gespeicherten Läufe eines Batches.
|
||||||
|
#[tauri::command]
|
||||||
|
fn batch_results(paths: State<'_, AppPaths>, batch_id: i64) -> Result<Vec<RunRecord>, String> {
|
||||||
|
let store = Store::open(&paths.0.data_dir.join(DB_FILE))?;
|
||||||
|
store.runs_for_batch(batch_id)
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||||
pub fn run() {
|
pub fn run() {
|
||||||
tauri::Builder::default()
|
tauri::Builder::default()
|
||||||
@ -35,11 +132,23 @@ pub fn run() {
|
|||||||
.app_data_dir()
|
.app_data_dir()
|
||||||
.map_err(|e| format!("Datenordner nicht ermittelbar: {e}"))?;
|
.map_err(|e| format!("Datenordner nicht ermittelbar: {e}"))?;
|
||||||
let (paths, cfg) = config::load_or_create(&config_dir, &default_data_dir)?;
|
let (paths, cfg) = config::load_or_create(&config_dir, &default_data_dir)?;
|
||||||
|
// Datenbank einmal anlegen, damit Fehler früh sichtbar werden.
|
||||||
|
Store::open(&paths.data_dir.join(DB_FILE))?;
|
||||||
app.manage(AppPaths(paths));
|
app.manage(AppPaths(paths));
|
||||||
app.manage(cfg);
|
app.manage(cfg);
|
||||||
|
app.manage(RunState {
|
||||||
|
cancel: Arc::new(AtomicBool::new(false)),
|
||||||
|
running: Arc::new(AtomicBool::new(false)),
|
||||||
|
});
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
.invoke_handler(tauri::generate_handler![get_paths, load_tasks])
|
.invoke_handler(tauri::generate_handler![
|
||||||
|
get_paths,
|
||||||
|
load_tasks,
|
||||||
|
start_batch,
|
||||||
|
cancel_batch,
|
||||||
|
batch_results
|
||||||
|
])
|
||||||
.run(tauri::generate_context!())
|
.run(tauri::generate_context!())
|
||||||
.expect("error while running tauri application");
|
.expect("error while running tauri application");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -179,6 +179,44 @@ impl Store {
|
|||||||
Ok(run_id)
|
Ok(run_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Alle gespeicherten Läufe eines Batches, sortiert nach Modell, Aufgabe und Wiederholung.
|
||||||
|
pub fn runs_for_batch(&self, batch_id: i64) -> Result<Vec<RunRecord>, String> {
|
||||||
|
let mut stmt = self
|
||||||
|
.conn
|
||||||
|
.prepare(
|
||||||
|
"SELECT batch_id, model, task_id, repeat_idx, error_class, score, steps,
|
||||||
|
prompt_tokens, completion_tokens, duration_ms, tps, ttft_tool_ms,
|
||||||
|
artifact_path, summary, check_output
|
||||||
|
FROM run WHERE batch_id = ?1 ORDER BY model, task_id, repeat_idx",
|
||||||
|
)
|
||||||
|
.map_err(|e| e.to_string())?;
|
||||||
|
let rows = stmt
|
||||||
|
.query_map(params![batch_id], |r| {
|
||||||
|
let class: String = r.get(4)?;
|
||||||
|
let error_class = serde_json::from_value(serde_json::Value::String(class))
|
||||||
|
.unwrap_or(ErrorClass::EndpointError);
|
||||||
|
Ok(RunRecord {
|
||||||
|
batch_id: r.get(0)?,
|
||||||
|
model: r.get(1)?,
|
||||||
|
task_id: r.get(2)?,
|
||||||
|
repeat_idx: r.get(3)?,
|
||||||
|
error_class,
|
||||||
|
score: r.get(5)?,
|
||||||
|
steps: r.get(6)?,
|
||||||
|
prompt_tokens: r.get(7)?,
|
||||||
|
completion_tokens: r.get(8)?,
|
||||||
|
duration_ms: r.get::<_, i64>(9)? as u128,
|
||||||
|
tps: r.get(10)?,
|
||||||
|
ttft_tool_ms: r.get::<_, Option<i64>>(11)?.map(|v| v as u128),
|
||||||
|
artifact_path: r.get(12)?,
|
||||||
|
summary: r.get(13)?,
|
||||||
|
check_output: r.get(14)?,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.map_err(|e| e.to_string())?;
|
||||||
|
rows.collect::<Result<Vec<_>, _>>().map_err(|e| e.to_string())
|
||||||
|
}
|
||||||
|
|
||||||
pub fn run_count(&self, batch_id: i64) -> Result<i64, String> {
|
pub fn run_count(&self, batch_id: i64) -> Result<i64, String> {
|
||||||
self.conn
|
self.conn
|
||||||
.query_row("SELECT COUNT(*) FROM run WHERE batch_id = ?1", params![batch_id], |r| r.get(0))
|
.query_row("SELECT COUNT(*) FROM run WHERE batch_id = ?1", params![batch_id], |r| r.get(0))
|
||||||
@ -249,6 +287,20 @@ mod tests {
|
|||||||
assert!(!keys.contains(&("m1".to_string(), "a-01".to_string(), 2)));
|
assert!(!keys.contains(&("m1".to_string(), "a-01".to_string(), 2)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn laeufe_eines_batches_werden_zurueckgelesen() {
|
||||||
|
let mut s = Store::open_in_memory().unwrap();
|
||||||
|
let b = s.create_batch("", 2, "{}").unwrap();
|
||||||
|
s.insert_run(&rec(b, "m1", "a-01", 2), &[]).unwrap();
|
||||||
|
s.insert_run(&rec(b, "m1", "a-01", 1), &[]).unwrap();
|
||||||
|
let runs = s.runs_for_batch(b).unwrap();
|
||||||
|
assert_eq!(runs.len(), 2);
|
||||||
|
assert_eq!(runs[0].repeat_idx, 1);
|
||||||
|
assert_eq!(runs[0].error_class, ErrorClass::Ok);
|
||||||
|
assert_eq!(runs[0].ttft_tool_ms, Some(300));
|
||||||
|
assert!(s.runs_for_batch(99).unwrap().is_empty());
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn unbekannter_batch_existiert_nicht() {
|
fn unbekannter_batch_existiert_nicht() {
|
||||||
let s = Store::open_in_memory().unwrap();
|
let s = Store::open_in_memory().unwrap();
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { onMount } from "svelte";
|
import { onMount, onDestroy } from "svelte";
|
||||||
import { invoke } from "@tauri-apps/api/core";
|
import { invoke } from "@tauri-apps/api/core";
|
||||||
|
import { listen, type UnlistenFn } from "@tauri-apps/api/event";
|
||||||
|
|
||||||
type Paths = {
|
type Paths = {
|
||||||
config_file: string;
|
config_file: string;
|
||||||
@ -12,11 +13,41 @@
|
|||||||
type TaskError = { dir: string; message: string };
|
type TaskError = { dir: string; message: string };
|
||||||
type LoadReport = { tasks: TaskInfo[]; errors: TaskError[] };
|
type LoadReport = { tasks: TaskInfo[]; errors: TaskError[] };
|
||||||
|
|
||||||
|
type BatchEvent =
|
||||||
|
| { kind: "run_started"; model: string; task: string; repeat: number }
|
||||||
|
| { kind: "run_finished"; model: string; task: string; repeat: number; class: string; score: number }
|
||||||
|
| { kind: "run_skipped"; model: string; task: string; repeat: number }
|
||||||
|
| { kind: "model_unavailable"; model: string; reason: string }
|
||||||
|
| { kind: "progress"; done: number; total: number };
|
||||||
|
|
||||||
|
type RunRow = {
|
||||||
|
model: string;
|
||||||
|
task_id: string;
|
||||||
|
repeat_idx: number;
|
||||||
|
error_class: string;
|
||||||
|
score: number;
|
||||||
|
steps: number;
|
||||||
|
duration_ms: number;
|
||||||
|
tps: number | null;
|
||||||
|
};
|
||||||
|
|
||||||
let paths = $state<Paths | null>(null);
|
let paths = $state<Paths | null>(null);
|
||||||
let error = $state("");
|
let error = $state("");
|
||||||
let report = $state<LoadReport | null>(null);
|
let report = $state<LoadReport | null>(null);
|
||||||
let taskError = $state("");
|
let taskError = $state("");
|
||||||
|
|
||||||
|
let modelsText = $state("qwen3:0.6b");
|
||||||
|
let selected = $state<string[]>([]);
|
||||||
|
let repeats = $state(1);
|
||||||
|
let running = $state(false);
|
||||||
|
let log = $state<string[]>([]);
|
||||||
|
let progress = $state<{ done: number; total: number } | null>(null);
|
||||||
|
let batchId = $state<number | null>(null);
|
||||||
|
let rows = $state<RunRow[]>([]);
|
||||||
|
let batchError = $state("");
|
||||||
|
|
||||||
|
let unlisten: UnlistenFn | null = null;
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
try {
|
try {
|
||||||
paths = await invoke<Paths>("get_paths");
|
paths = await invoke<Paths>("get_paths");
|
||||||
@ -28,7 +59,69 @@
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
taskError = String(e);
|
taskError = String(e);
|
||||||
}
|
}
|
||||||
|
unlisten = await listen<BatchEvent>("batch-event", (ev) => onEvent(ev.payload));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
onDestroy(() => {
|
||||||
|
if (unlisten) unlisten();
|
||||||
|
});
|
||||||
|
|
||||||
|
function onEvent(e: BatchEvent) {
|
||||||
|
if (e.kind === "progress") {
|
||||||
|
progress = { done: e.done, total: e.total };
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (e.kind === "model_unavailable") {
|
||||||
|
log = [...log, `Modell ${e.model} nicht nutzbar: ${e.reason}`];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const label = `${e.model} · ${e.task} · Wdh. ${e.repeat}`;
|
||||||
|
if (e.kind === "run_started") log = [...log, `läuft: ${label}`];
|
||||||
|
if (e.kind === "run_skipped") log = [...log, `übersprungen: ${label}`];
|
||||||
|
if (e.kind === "run_finished")
|
||||||
|
log = [...log, `fertig: ${label} → ${e.class}, Score ${e.score.toFixed(2)}`];
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleTask(id: string) {
|
||||||
|
selected = selected.includes(id)
|
||||||
|
? selected.filter((x) => x !== id)
|
||||||
|
: [...selected, id];
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseModels(): string[] {
|
||||||
|
return modelsText
|
||||||
|
.split(/[\n,]/)
|
||||||
|
.map((m) => m.trim())
|
||||||
|
.filter((m) => m.length > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function start() {
|
||||||
|
batchError = "";
|
||||||
|
rows = [];
|
||||||
|
log = [];
|
||||||
|
progress = null;
|
||||||
|
batchId = null;
|
||||||
|
running = true;
|
||||||
|
try {
|
||||||
|
const summary = await invoke<{ batch_id: number; cancelled: boolean }>("start_batch", {
|
||||||
|
models: parseModels(),
|
||||||
|
taskIds: selected,
|
||||||
|
repeats,
|
||||||
|
note: "",
|
||||||
|
});
|
||||||
|
batchId = summary.batch_id;
|
||||||
|
rows = await invoke<RunRow[]>("batch_results", { batchId: summary.batch_id });
|
||||||
|
if (summary.cancelled) log = [...log, "Batch abgebrochen."];
|
||||||
|
} catch (e) {
|
||||||
|
batchError = String(e);
|
||||||
|
} finally {
|
||||||
|
running = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function cancel() {
|
||||||
|
await invoke<boolean>("cancel_batch");
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<main class="container">
|
<main class="container">
|
||||||
@ -58,9 +151,19 @@
|
|||||||
<p class="fehler">Fehler: {taskError}</p>
|
<p class="fehler">Fehler: {taskError}</p>
|
||||||
{:else if report}
|
{:else if report}
|
||||||
<p>{report.tasks.length} gültig, {report.errors.length} mit Fehlern.</p>
|
<p>{report.tasks.length} gültig, {report.errors.length} mit Fehlern.</p>
|
||||||
<ul>
|
<ul class="tasks">
|
||||||
{#each report.tasks as t (t.dir)}
|
{#each report.tasks as t (t.dir)}
|
||||||
<li><strong>{t.id}</strong> · {t.title} <span class="gruppe">Gruppe {t.group}</span></li>
|
<li>
|
||||||
|
<label>
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
checked={selected.includes(t.id)}
|
||||||
|
onchange={() => toggleTask(t.id)}
|
||||||
|
disabled={running}
|
||||||
|
/>
|
||||||
|
<strong>{t.id}</strong> · {t.title} <span class="gruppe">Gruppe {t.group}</span>
|
||||||
|
</label>
|
||||||
|
</li>
|
||||||
{/each}
|
{/each}
|
||||||
</ul>
|
</ul>
|
||||||
{#if report.errors.length > 0}
|
{#if report.errors.length > 0}
|
||||||
@ -75,6 +178,70 @@
|
|||||||
<p>Lade Aufgaben …</p>
|
<p>Lade Aufgaben …</p>
|
||||||
{/if}
|
{/if}
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<section>
|
||||||
|
<h2>Batch starten</h2>
|
||||||
|
<label class="feld">
|
||||||
|
Modelle (Komma oder Zeilenumbruch)
|
||||||
|
<textarea rows="2" bind:value={modelsText} disabled={running}></textarea>
|
||||||
|
</label>
|
||||||
|
<label class="feld">
|
||||||
|
Wiederholungen
|
||||||
|
<input type="number" min="1" max="20" bind:value={repeats} disabled={running} />
|
||||||
|
</label>
|
||||||
|
<div class="knöpfe">
|
||||||
|
<button onclick={start} disabled={running || selected.length === 0 || parseModels().length === 0}>
|
||||||
|
Starten
|
||||||
|
</button>
|
||||||
|
<button onclick={cancel} disabled={!running}>Abbrechen</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{#if progress}
|
||||||
|
<p>Fortschritt: {progress.done} von {progress.total}</p>
|
||||||
|
{/if}
|
||||||
|
{#if batchError}
|
||||||
|
<p class="fehler">Fehler: {batchError}</p>
|
||||||
|
{/if}
|
||||||
|
{#if log.length > 0}
|
||||||
|
<ul class="log">
|
||||||
|
{#each log as line, i (i)}
|
||||||
|
<li>{line}</li>
|
||||||
|
{/each}
|
||||||
|
</ul>
|
||||||
|
{/if}
|
||||||
|
</section>
|
||||||
|
|
||||||
|
{#if batchId !== null && rows.length > 0}
|
||||||
|
<section>
|
||||||
|
<h2>Ergebnisse, Batch {batchId}</h2>
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Modell</th>
|
||||||
|
<th>Aufgabe</th>
|
||||||
|
<th>Wdh.</th>
|
||||||
|
<th>Klasse</th>
|
||||||
|
<th>Score</th>
|
||||||
|
<th>Schritte</th>
|
||||||
|
<th>Dauer</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{#each rows as r (`${r.model}|${r.task_id}|${r.repeat_idx}`)}
|
||||||
|
<tr>
|
||||||
|
<td>{r.model}</td>
|
||||||
|
<td>{r.task_id}</td>
|
||||||
|
<td>{r.repeat_idx}</td>
|
||||||
|
<td>{r.error_class}</td>
|
||||||
|
<td>{r.score.toFixed(2)}</td>
|
||||||
|
<td>{r.steps}</td>
|
||||||
|
<td>{(r.duration_ms / 1000).toFixed(1)} s</td>
|
||||||
|
</tr>
|
||||||
|
{/each}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</section>
|
||||||
|
{/if}
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
@ -100,6 +267,10 @@
|
|||||||
max-width: 48rem;
|
max-width: 48rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
section {
|
||||||
|
margin-bottom: 2rem;
|
||||||
|
}
|
||||||
|
|
||||||
dl {
|
dl {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: max-content 1fr;
|
grid-template-columns: max-content 1fr;
|
||||||
@ -115,6 +286,43 @@
|
|||||||
overflow-wrap: anywhere;
|
overflow-wrap: anywhere;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.tasks {
|
||||||
|
list-style: none;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.feld {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.3rem;
|
||||||
|
margin-bottom: 0.8rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.knöpfe {
|
||||||
|
display: flex;
|
||||||
|
gap: 0.6rem;
|
||||||
|
margin-bottom: 0.8rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log {
|
||||||
|
max-height: 16rem;
|
||||||
|
overflow-y: auto;
|
||||||
|
font-family: monospace;
|
||||||
|
font-size: 0.85rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
table {
|
||||||
|
width: 100%;
|
||||||
|
border-collapse: collapse;
|
||||||
|
}
|
||||||
|
|
||||||
|
th,
|
||||||
|
td {
|
||||||
|
text-align: left;
|
||||||
|
padding: 0.3rem 0.5rem;
|
||||||
|
border-bottom: 1px solid #8884;
|
||||||
|
}
|
||||||
|
|
||||||
.fehler {
|
.fehler {
|
||||||
color: #c62828;
|
color: #c62828;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user