Skip to content

Commit 723f3f1

Browse files
AnHeuermannclaude
andcommitted
Skip sim CSVs exceeding a configurable size limit
Simulation result CSVs can exceed GitHub's 100 MB file size limit, preventing pushes to gh-pages. Fix by checking the CSV size after writing and, if it exceeds the limit (default 20 MB), deleting the file and leaving a <name>_sim.csv.toobig marker in its place. The HTML report detects the marker and shows "(CSV N/A)" with a tooltip instead of a download link. The limit is exposed as a `csv_max_size_mb` keyword argument on `main()`, `test_model()`, `run_simulate()`, and `generate_report()`, defaulting to the module-level constant `CSV_MAX_SIZE_MB = 20`. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 8aef156 commit 723f3f1

4 files changed

Lines changed: 68 additions & 28 deletions

File tree

src/pipeline.jl

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ end
5454
# ── Per-model orchestrator ─────────────────────────────────────────────────────
5555

5656
"""
57-
test_model(omc, model, results_root, ref_root) → ModelResult
57+
test_model(omc, model, results_root, ref_root; csv_max_size_mb) → ModelResult
5858
5959
Run the four-phase pipeline for a single model and return its result.
6060
"""
6161
function test_model(omc::OMJulia.OMCSession, model::String, results_root::String,
62-
ref_root::String)::ModelResult
62+
ref_root::String; csv_max_size_mb::Int = CSV_MAX_SIZE_MB)::ModelResult
6363
model_dir = joinpath(results_root, "files", model)
6464
mkpath(model_dir)
6565

@@ -78,7 +78,7 @@ function test_model(omc::OMJulia.OMCSession, model::String, results_root::String
7878
model, true, exp_t, exp_err, false, par_t, par_err, false, 0.0, "", 0, 0, "")
7979

8080
# Phase 3 ──────────────────────────────────────────────────────────────────
81-
sim_ok, sim_t, sim_err, sol = run_simulate(ode_prob, model_dir, model)
81+
sim_ok, sim_t, sim_err, sol = run_simulate(ode_prob, model_dir, model; csv_max_size_mb)
8282

8383
# Phase 4 (optional) ───────────────────────────────────────────────────────
8484
cmp_total, cmp_pass, cmp_csv = 0, 0, ""
@@ -112,13 +112,14 @@ Discovers models via OMC, runs `test_model` for each, then writes the HTML
112112
report. Returns a `Vector{ModelResult}`.
113113
"""
114114
function main(;
115-
library :: String = LIBRARY,
116-
version :: String = LIBRARY_VERSION,
117-
filter :: Union{String,Nothing} = nothing,
118-
omc_exe :: String = get(ENV, "OMC_EXE", "omc"),
119-
results_root :: String = "",
120-
ref_root :: String = get(ENV, "MAPLIB_REF", ""),
121-
bm_options :: String = get(ENV, "BM_OPTIONS", "scalarize,moveBindings,inlineFunctions"),
115+
library :: String = LIBRARY,
116+
version :: String = LIBRARY_VERSION,
117+
filter :: Union{String,Nothing} = nothing,
118+
omc_exe :: String = get(ENV, "OMC_EXE", "omc"),
119+
results_root :: String = "",
120+
ref_root :: String = get(ENV, "MAPLIB_REF", ""),
121+
bm_options :: String = get(ENV, "BM_OPTIONS", "scalarize,moveBindings,inlineFunctions"),
122+
csv_max_size_mb :: Int = CSV_MAX_SIZE_MB,
122123
)
123124
t0 = time()
124125

@@ -186,7 +187,7 @@ function main(;
186187

187188
for (i, model) in enumerate(models)
188189
@info "[$i/$(length(models))] $model"
189-
result = test_model(omc, model, results_root, ref_root)
190+
result = test_model(omc, model, results_root, ref_root; csv_max_size_mb)
190191
push!(results, result)
191192

192193
phase = result.sim_success ? "SIM OK" :
@@ -221,7 +222,7 @@ function main(;
221222
time() - t0,
222223
)
223224

224-
generate_report(results, results_root, info)
225+
generate_report(results, results_root, info; csv_max_size_mb)
225226
write_summary(results, results_root, info)
226227
return results
227228
end

src/report.jl

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,48 @@ function _status_cell(ok::Bool, t::Float64, logFile::Union{String,Nothing})
1313
end
1414
end
1515

16-
function _cmp_cell(r::ModelResult, results_root::String)
16+
"""
17+
_cmp_cell(r, results_root, csv_max_size_mb) → HTML string
18+
19+
Build the "Ref Cmp" table cell for one model row.
20+
21+
- `cmp_total == 0`: no reference data — show `—` (or just the CSV link if present).
22+
- All signals pass (`p == n`): green cell with score and a link to the sim CSV.
23+
- Some signals fail: red cell with a link to the interactive diff HTML, the diff
24+
CSV, and the sim CSV. The sim CSV link is always included when the file exists.
25+
26+
`sim_csv` is constructed as `"files/<model>/<short>_sim.csv"`, which is already a
27+
path relative to `results_root` (where `index.html` lives), so it is used directly
28+
as the `href` without further `relpath` manipulation. If the CSV was skipped
29+
because it exceeded `csv_max_size_mb` MB, a `<short>_sim.csv.toobig` marker file
30+
is present and a non-linking note is shown instead.
31+
"""
32+
function _cmp_cell(r::ModelResult, results_root::String, csv_max_size_mb::Int)
33+
short = split(r.name, ".")[end]
34+
sim_csv = joinpath("files", r.name, "$(short)_sim.csv") # relative to results_root
35+
abs_sim_csv = joinpath(results_root, sim_csv)
36+
csv_link = if isfile(abs_sim_csv)
37+
""" <a href="$sim_csv">(CSV)</a>"""
38+
elseif isfile(abs_sim_csv * ".toobig")
39+
""" <span title="Result file exceeds $(csv_max_size_mb) MB and was not uploaded">(CSV N/A)</span>"""
40+
else
41+
""
42+
end
43+
1744
if r.cmp_total == 0
18-
return """<td class="na">—</td>"""
45+
return isempty(csv_link) ? """<td class="na">—</td>""" :
46+
"""<td class="na">$(csv_link)</td>"""
1947
end
48+
2049
n, p = r.cmp_total, r.cmp_pass
2150
if p == n
22-
# No diff CSV when all signals pass — link the sim CSV instead
23-
short = split(r.name, ".")[end]
24-
sim_csv = joinpath("files", r.name, "$(short)_sim.csv")
25-
csv_link = isfile(joinpath(results_root, sim_csv)) ? """ <a href="$sim_csv">(CSV)</a>""" : ""
2651
return """<td class="ok">&#10003; $p/$n$(csv_link)</td>"""
2752
else
28-
# Link to the interactive diff HTML (next to the CSV, same name, .html extension)
53+
# Link to the interactive diff HTML (next to the diff CSV, same name, .html extension)
2954
diff_html = replace(r.cmp_csv, r"\.csv$" => ".html")
30-
rel = relpath(isfile(diff_html) ? diff_html : r.cmp_csv, results_root)
31-
csv_link = isempty(r.cmp_csv) ? "" : """ <a href="$(relpath(r.cmp_csv, results_root))">(CSV)</a>"""
32-
return """<td class="fail"><a href="$rel">$p/$n</a>$(csv_link)</td>"""
55+
diff_rel = relpath(isfile(diff_html) ? diff_html : r.cmp_csv, results_root)
56+
diff_csv_link = isempty(r.cmp_csv) ? "" : """ <a href="$(relpath(r.cmp_csv, results_root))">(diff CSV)</a>"""
57+
return """<td class="fail"><a href="$diff_rel">$p/$n</a>$(diff_csv_link)$(csv_link)</td>"""
3358
end
3459
end
3560

@@ -49,12 +74,12 @@ function _format_duration(t::Float64)::String
4974
end
5075

5176
"""
52-
generate_report(results, results_root, info) → report_path
77+
generate_report(results, results_root, info; csv_max_size_mb) → report_path
5378
5479
Write an `index.html` overview report to `results_root` and return its path.
5580
"""
5681
function generate_report(results::Vector{ModelResult}, results_root::String,
57-
info::RunInfo)
82+
info::RunInfo; csv_max_size_mb::Int = CSV_MAX_SIZE_MB)
5883
n = length(results)
5984
n_exp = count(r -> r.export_success, results)
6085
n_par = count(r -> r.parse_success, results)
@@ -75,7 +100,7 @@ function generate_report(results::Vector{ModelResult}, results_root::String,
75100
$(_status_cell(r.export_success, r.export_time, rel_log_file_or_nothing(results_root, r.name, "export")))
76101
$(_status_cell(r.parse_success, r.parse_time, rel_log_file_or_nothing(results_root, r.name, "parsing")))
77102
$(_status_cell(r.sim_success, r.sim_time, rel_log_file_or_nothing(results_root, r.name, "sim")))
78-
$(_cmp_cell(r, results_root))
103+
$(_cmp_cell(r, results_root, csv_max_size_mb))
79104
</tr>""" for r in results], "\n")
80105

81106
bm_sha_link = isempty(info.bm_sha) ? "" :

src/simulate.jl

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,18 @@ import ModelingToolkit
55
import Printf: @sprintf
66

77
"""
8-
run_simulate(ode_prob, model_dir, model) → (success, time, error, sol)
8+
run_simulate(ode_prob, model_dir, model; csv_max_size_mb) → (success, time, error, sol)
99
1010
Solve `ode_prob` with Rodas5P (stiff solver). On success, also writes the
1111
full solution as a CSV file `<Short>_sim.csv` in `model_dir`.
1212
Writes a `<model>_sim.log` file in `model_dir`.
1313
Returns `nothing` as the fourth element on failure.
14+
15+
CSV files larger than `csv_max_size_mb` MiB are deleted and replaced with a
16+
`<Short>_sim.csv.toobig` marker so that the report can note the omission.
1417
"""
15-
function run_simulate(ode_prob, model_dir::String,
16-
model::String)::Tuple{Bool,Float64,String,Any}
18+
function run_simulate(ode_prob, model_dir::String, model::String;
19+
csv_max_size_mb::Int = CSV_MAX_SIZE_MB)::Tuple{Bool,Float64,String,Any}
1720
sim_success = false
1821
sim_time = 0.0
1922
sim_error = ""
@@ -59,6 +62,13 @@ function run_simulate(ode_prob, model_dir::String,
5962
println(f, join(row, ","))
6063
end
6164
end
65+
csv_bytes = filesize(sim_csv)
66+
if csv_bytes > csv_max_size_mb * 1024^2
67+
csv_mb = round(csv_bytes / 1024^2; digits=1)
68+
@warn "Simulation CSV for $model is $(csv_mb) MB (> $(csv_max_size_mb) MB limit); skipping."
69+
rm(sim_csv)
70+
write(sim_csv * ".toobig", string(csv_bytes))
71+
end
6272
catch e
6373
@warn "Failed to write simulation CSV for $model: $(sprint(showerror, e))"
6474
end

src/types.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ const LIBRARY_VERSION = "4.1.0"
88
const CMP_REL_TOL = 0.02
99
const CMP_ABS_TOL = 1e-6
1010

11+
# CSV files larger than this limit are not committed to gh-pages (GitHub
12+
# enforces a 100 MB hard cap; we use a conservative 20 MB soft limit).
13+
const CSV_MAX_SIZE_MB = 20
14+
1115
# ── Comparison settings ────────────────────────────────────────────────────────
1216

1317
"""

0 commit comments

Comments
 (0)