From 82f412556d8adc20015931b75eb1cbda1869f13c Mon Sep 17 00:00:00 2001 From: Kai Partmann Date: Mon, 3 Nov 2025 13:41:29 +0100 Subject: [PATCH 1/3] Now restarts work as intended; finding latest status from logfile --- src/core/study.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/study.jl b/src/core/study.jl index 146703dc..5eb1523b 100644 --- a/src/core/study.jl +++ b/src/core/study.jl @@ -283,13 +283,13 @@ function update_sim_success_from_log!(study::Study) for (i, path) in enumerate(study.jobpaths) # Search for the Simulation line for this job path sim_line_pattern = "Simulation `$(path)`:" - sim_line_idx = findfirst(line -> occursin(sim_line_pattern, line), lines) - - if sim_line_idx === nothing + sim_line_idxs = findall(line -> occursin(sim_line_pattern, line), lines) + if isempty(sim_line_idxs) # No record for this job in logfile study.sim_success[i] = false continue end + sim_line_idx = sim_line_idxs[end] # Take the last occurrence (restarts also logged) # Look for status line in the next few lines after the simulation line found_status = false From 984e2f54f876d1b7b1c9dd89f609ada1b68c1f8d Mon Sep 17 00:00:00 2001 From: Kai Partmann Date: Mon, 3 Nov 2025 13:52:51 +0100 Subject: [PATCH 2/3] Minor logging enhancements --- src/core/study.jl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core/study.jl b/src/core/study.jl index 5eb1523b..ac18055c 100644 --- a/src/core/study.jl +++ b/src/core/study.jl @@ -213,10 +213,11 @@ function submit!(study::Study; kwargs...) end # Now submit each job + n_jobs = length(study.jobs) for (i, job) in enumerate(study.jobs) # If this job already completed in a previous run, skip execution open(study.logfile, "a") do io - msg = "Simulation `$(study.jobpaths[i])`:\n" + msg = @sprintf "(%d/%d) Simulation `%s`:\n" i n_jobs job.options.root for (key, value) in pairs(study.setups[i]) msg *= " $(key): $(value)\n" end @@ -225,7 +226,7 @@ function submit!(study::Study; kwargs...) if study.sim_success[i] # Write a short note about skipping to the study logfile open(study.logfile, "a") do io - write(io, " status: skipped (already completed)\n\n") + write(io, " status: skipped (completed in a previous run)\n\n") end continue end From 2293a826e15a5a915210894d022ffb87adebe570 Mon Sep 17 00:00:00 2001 From: Kai Partmann Date: Mon, 3 Nov 2025 14:16:23 +0100 Subject: [PATCH 3/3] Minor refactoring --- src/core/study.jl | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/core/study.jl b/src/core/study.jl index ac18055c..725b9997 100644 --- a/src/core/study.jl +++ b/src/core/study.jl @@ -79,17 +79,11 @@ struct Study{F,S,J} check_jobpaths_unique(jobpaths) sim_success = fill(false, length(jobs)) logfile = joinpath(root, "study_log.log") - st = new{F,S,J}(jobcreator, setups, jobs, jobpaths, root, logfile, sim_success) + study = new{F,S,J}(jobcreator, setups, jobs, jobpaths, root, logfile, sim_success) # If a logfile already exists from a previous run, initialize sim_success # from the logfile so processing or resuming works across interrupted runs. - if isfile(st.logfile) - try - update_sim_success_from_log!(st) - catch err - @warn "failed to refresh study status from logfile" error=err - end - end - return st + isfile(logfile) && update_sim_success_from_log!(study) + return study end end