fix: Review-Befunde beheben (Image-Bau, Absturzsicherung, Image-Name, Ausgabelimit)
- App baut cb-python selbst: Containerfile eingebettet, Befehle image_status und build_image, Live-Ausgabe, Knopf in den Einstellungen. start_batch prüft vorher, ob die Images da sind. - running-Flag wird per Wächter zurückgesetzt, auch nach einem Absturz. - Ein Fehler in einem Lauf beendet nicht mehr den Batch: Lauf wird als sandbox_error gespeichert. endpoint_error und sandbox_error zählen nicht in die Bewertung und werden beim Fortsetzen wiederholt. - Image-Name wird geprüft (kein führendes -, nur erlaubte Zeichen), Podman bekommt -- vor dem Image. - Ausgabe von Befehlen wird auf 1 MiB je Strom begrenzt. - Abbruch wird auch vor dem Aufwärmen geprüft. - Fehlerklassen lesbar, Hinweis auf nicht gewertete Läufe. 65 Unit-Tests grün (6 ignorierte Integrationstests); echter Sandbox- und Image-Test grün. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@ -166,6 +166,10 @@ pub fn run_batch(
|
||||
}
|
||||
|
||||
'models: for model in &models {
|
||||
if cancel.load(Ordering::SeqCst) {
|
||||
summary.cancelled = true;
|
||||
break 'models;
|
||||
}
|
||||
let client = make_client(cfg, model)?;
|
||||
let warm = client.chat(
|
||||
&[Message::new("user", "ping")],
|
||||
@ -208,31 +212,21 @@ pub fn run_batch(
|
||||
let fin = match &unavailable {
|
||||
// Modell nicht nutzbar: Lauf wird als endpoint_error gespeichert, ohne Container.
|
||||
Some(reason) => Finished {
|
||||
record: RunRecord {
|
||||
batch_id,
|
||||
model: job.model.clone(),
|
||||
task_id: job.task.meta.id.clone(),
|
||||
repeat_idx: job.repeat_idx,
|
||||
error_class: ErrorClass::EndpointError,
|
||||
score: 0.0,
|
||||
steps: 0,
|
||||
prompt_tokens: 0,
|
||||
completion_tokens: 0,
|
||||
duration_ms: 0,
|
||||
tps: None,
|
||||
ttft_tool_ms: None,
|
||||
artifact_path: None,
|
||||
summary: None,
|
||||
check_output: reason.clone(),
|
||||
},
|
||||
record: infra_record(batch_id, job, ErrorClass::EndpointError, reason),
|
||||
transcript: vec![],
|
||||
},
|
||||
None => match execute_job(cfg, batch_id, i, job, &*client, cancel)? {
|
||||
JobResult::Cancelled => {
|
||||
None => match execute_job(cfg, batch_id, i, job, &*client, cancel) {
|
||||
Ok(JobResult::Cancelled) => {
|
||||
summary.cancelled = true;
|
||||
break 'models;
|
||||
}
|
||||
JobResult::Finished(f) => f,
|
||||
Ok(JobResult::Finished(f)) => f,
|
||||
// Ein Fehler der Umgebung beendet nicht den Batch: Der Lauf wird als
|
||||
// sandbox_error gespeichert und beim Fortsetzen wiederholt.
|
||||
Err(message) => Finished {
|
||||
record: infra_record(batch_id, job, ErrorClass::SandboxError, &message),
|
||||
transcript: vec![],
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@ -256,6 +250,27 @@ pub fn run_batch(
|
||||
Ok(summary)
|
||||
}
|
||||
|
||||
/// Lauf ohne Ergebnis, weil Umgebung oder Server ausfielen. Zählt nicht gegen das Modell.
|
||||
fn infra_record(batch_id: i64, job: &Job, class: ErrorClass, message: &str) -> RunRecord {
|
||||
RunRecord {
|
||||
batch_id,
|
||||
model: job.model.clone(),
|
||||
task_id: job.task.meta.id.clone(),
|
||||
repeat_idx: job.repeat_idx,
|
||||
error_class: class,
|
||||
score: 0.0,
|
||||
steps: 0,
|
||||
prompt_tokens: 0,
|
||||
completion_tokens: 0,
|
||||
duration_ms: 0,
|
||||
tps: None,
|
||||
ttft_tool_ms: None,
|
||||
artifact_path: None,
|
||||
summary: None,
|
||||
check_output: message.to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
struct Finished {
|
||||
record: RunRecord,
|
||||
transcript: Vec<Message>,
|
||||
@ -310,7 +325,9 @@ fn execute_job(
|
||||
.map_err(|e| format!("prompt.md nicht lesbar: {e}"))?;
|
||||
let outcome = run_agent_cancellable(client, &ws, &prompt, &limits, cancel);
|
||||
if outcome.cancelled {
|
||||
sb.remove()?;
|
||||
if let Err(e) = sb.remove() {
|
||||
eprintln!("Container {} nicht entfernt: {e}", name);
|
||||
}
|
||||
return Ok(JobResult::Cancelled);
|
||||
}
|
||||
|
||||
@ -352,7 +369,10 @@ fn execute_job(
|
||||
Ok(()) => Some(artifact.join("work").display().to_string()),
|
||||
Err(_) => None,
|
||||
};
|
||||
sb.remove()?;
|
||||
// Ein fehlschlagendes Aufräumen darf einen fertigen Lauf nicht verwerfen.
|
||||
if let Err(e) = sb.remove() {
|
||||
eprintln!("Container {} nicht entfernt: {e}", name);
|
||||
}
|
||||
|
||||
let class = final_class(outcome.class, &check);
|
||||
let secs = outcome.duration_ms as f64 / 1000.0;
|
||||
@ -562,6 +582,48 @@ mod tests {
|
||||
eprintln!("Datenbank: {}", data.join("db.sqlite").display());
|
||||
}
|
||||
|
||||
/// Ein Modell, dessen Server nicht antwortet, bricht den Batch nicht ab. Die Läufe werden als
|
||||
/// endpoint_error gespeichert, zählen nicht in die Bewertung und werden beim Fortsetzen wiederholt.
|
||||
/// Braucht weder Podman noch einen Server (Port 1 auf localhost ist geschlossen).
|
||||
#[test]
|
||||
fn ausgefallenes_modell_wird_gespeichert_und_beim_fortsetzen_wiederholt() {
|
||||
let cfg = RunConfig {
|
||||
runtime: "podman".into(),
|
||||
models: vec![ModelConn {
|
||||
name: "weg".into(),
|
||||
adapter: "ollama".into(),
|
||||
url: "http://127.0.0.1:1".into(),
|
||||
model_id: "x".into(),
|
||||
api_key: None,
|
||||
}],
|
||||
data_dir: std::env::temp_dir().join("cb-unused"),
|
||||
limits: Limits::default(),
|
||||
};
|
||||
let jobs = plan(&["weg".to_string()], &[task("a-01"), task("a-02")], 1);
|
||||
let mut store = Store::open_in_memory().unwrap();
|
||||
let cancel = AtomicBool::new(false);
|
||||
let events = std::cell::RefCell::new(Vec::new());
|
||||
let on = |e: &Event| events.borrow_mut().push(e.clone());
|
||||
|
||||
let first = run_batch(&mut store, &cfg, None, "t", 1, &jobs, &cancel, &on).unwrap();
|
||||
assert_eq!(first.completed, 2);
|
||||
assert!(events.borrow().iter().any(|e| matches!(e, Event::ModelUnavailable { .. })));
|
||||
let runs = store.runs_for_batch(first.batch_id).unwrap();
|
||||
assert_eq!(runs.len(), 2);
|
||||
assert!(runs.iter().all(|r| r.error_class == ErrorClass::EndpointError));
|
||||
|
||||
// Fortsetzen: Ausfälle gelten nicht als fertig und werden wiederholt.
|
||||
let second = run_batch(&mut store, &cfg, Some(first.batch_id), "", 1, &jobs, &cancel, &on).unwrap();
|
||||
assert_eq!(second.completed, 2);
|
||||
assert_eq!(second.skipped, 0);
|
||||
|
||||
// Die Bewertung ignoriert die Ausfälle.
|
||||
let all = store.runs_for_batch(first.batch_id).unwrap();
|
||||
let r = crate::ranking::compute(first.batch_id, &all, &Default::default());
|
||||
assert_eq!(r.excluded_runs, 4);
|
||||
assert!(r.models.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn klasse_agent_vor_pruefung() {
|
||||
let ok = CheckResult { score: 1.0, passed: true };
|
||||
|
||||
Reference in New Issue
Block a user