Referenz: externe Läufe exportieren und importieren, Referenz ohne Rang mit Strich im Ranking, Reiter Referenz; Roadmap 0.1.1
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
mod agent;
|
||||
mod config;
|
||||
mod discover;
|
||||
mod external;
|
||||
mod images;
|
||||
mod ranking;
|
||||
mod runner;
|
||||
@ -272,6 +273,62 @@ async fn start_batch(
|
||||
result
|
||||
}
|
||||
|
||||
/// Legt einen Exportordner für Referenz-Läufe an (von Hand zu lösen, z. B. mit Claude Code).
|
||||
#[tauri::command]
|
||||
fn export_external(paths: State<'_, AppPaths>, task_ids: Vec<String>, repeats: u32) -> Result<external::ExportResult, String> {
|
||||
let selected: Vec<tasks::Task> =
|
||||
tasks::load_all(&paths.0.tasks_dir).tasks.into_iter().filter(|t| task_ids.contains(&t.meta.id)).collect();
|
||||
if selected.len() != task_ids.len() {
|
||||
return Err("Mindestens eine gewählte Aufgabe ist nicht gültig geladen.".into());
|
||||
}
|
||||
let stamp = std::time::SystemTime::now()
|
||||
.duration_since(std::time::UNIX_EPOCH)
|
||||
.map(|d| d.as_secs())
|
||||
.unwrap_or(0);
|
||||
let out = paths.0.data_dir.join("exports").join(format!("referenz-{stamp}"));
|
||||
external::export(&selected, repeats, &out)
|
||||
}
|
||||
|
||||
/// Prüft Ergebnisordner von Hand gelöster Aufgaben und speichert sie als externe Läufe.
|
||||
#[tauri::command]
|
||||
async fn import_external(
|
||||
paths: State<'_, AppPaths>,
|
||||
cfg: State<'_, ConfigState>,
|
||||
run: State<'_, RunState>,
|
||||
dir: String,
|
||||
model: String,
|
||||
batch_id: i64,
|
||||
) -> Result<external::ImportSummary, String> {
|
||||
let model = model.trim().to_string();
|
||||
if model.is_empty() || model.chars().count() > 80 {
|
||||
return Err("Der Modellname muss 1 bis 80 Zeichen lang sein.".into());
|
||||
}
|
||||
let (runtime, limits) = {
|
||||
let c = cfg.config.lock().map_err(|e| e.to_string())?;
|
||||
if c.models.iter().any(|m| m.name == model) {
|
||||
return Err(format!(
|
||||
"{model:?} ist ein angebundenes Modell. Wähle für die Referenz einen eigenen Namen, z. B. „{model} (extern)“."
|
||||
));
|
||||
}
|
||||
(c.container_runtime.clone(), c.sandbox_limits())
|
||||
};
|
||||
let loaded = tasks::load_all(&paths.0.tasks_dir).tasks;
|
||||
|
||||
if run.running.swap(true, Ordering::SeqCst) {
|
||||
return Err("Ein Batch oder Import läuft bereits.".into());
|
||||
}
|
||||
let _running_guard = FlagGuard(run.running.clone());
|
||||
|
||||
let run_cfg = RunConfig { runtime, models: Vec::new(), data_dir: paths.0.data_dir.clone(), limits };
|
||||
let db_path = paths.0.data_dir.join(DB_FILE);
|
||||
tauri::async_runtime::spawn_blocking(move || {
|
||||
let mut store = Store::open(&db_path)?;
|
||||
external::import(&mut store, &run_cfg, &loaded, std::path::Path::new(&dir), &model, batch_id)
|
||||
})
|
||||
.await
|
||||
.map_err(|e| format!("Import abgebrochen: {e}"))?
|
||||
}
|
||||
|
||||
/// Zustand eines Container-Images für die Einstellungen.
|
||||
#[derive(Serialize)]
|
||||
pub struct ImageStatus {
|
||||
@ -457,6 +514,8 @@ pub fn run() {
|
||||
save_models,
|
||||
test_model,
|
||||
discover_models,
|
||||
export_external,
|
||||
import_external,
|
||||
start_batch,
|
||||
cancel_batch,
|
||||
list_batches,
|
||||
|
||||
Reference in New Issue
Block a user