Skip to content

Commit a2b2e1c

Browse files
committed
fix(benchmark-report): drop task cost fallback
Stop treating Seqera task cost as a fallback when no CUR data is present. Normalized task rows now emit cost as null and aggregation reports zero without CUR input. Tests: nf-test test --profile=+docker --verbose
1 parent 353e062 commit a2b2e1c

4 files changed

Lines changed: 13 additions & 17 deletions

File tree

modules/local/aggregate_benchmark_report_data/bin/benchmark_report_aggregate.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,13 @@ def _lookup_cost(
6262
return None
6363

6464

65-
def _cost_or_task(cost_row: dict[str, Any] | None, key: str, task_cost: float, default: float = 0.0) -> float:
65+
def _cost_or_task(cost_row: dict[str, Any] | None, key: str, default: float = 0.0) -> float:
6666
if not cost_row:
67-
return task_cost if key in {"cost", "used_cost"} else default
67+
return default
6868

6969
value = cost_row.get(key)
7070
if value is None:
71-
return task_cost if key in {"cost", "used_cost"} else default
71+
return default
7272

7373
return float(value)
7474

@@ -311,21 +311,17 @@ def build_report_data(jsonl_dir: Path, include_failed_runs: bool = False) -> dic
311311
}
312312

313313
cost_row = _lookup_cost(costs_index, run_id=run_id, process=process, process_short=process_short, hash_short=hash_short)
314-
task_cost = float(t.get("cost") or 0.0)
315314

316315
if cost_row:
317-
run_cost_acc[run_group_key]["cost"] += _cost_or_task(cost_row, "cost", task_cost)
318-
run_cost_acc[run_group_key]["used_cost"] += _cost_or_task(cost_row, "used_cost", task_cost)
319-
run_cost_acc[run_group_key]["unused_cost"] += _cost_or_task(cost_row, "unused_cost", task_cost, default=0.0)
320-
else:
321-
run_cost_acc[run_group_key]["cost"] += task_cost
322-
run_cost_acc[run_group_key]["used_cost"] += task_cost
316+
run_cost_acc[run_group_key]["cost"] += _cost_or_task(cost_row, "cost")
317+
run_cost_acc[run_group_key]["used_cost"] += _cost_or_task(cost_row, "used_cost")
318+
run_cost_acc[run_group_key]["unused_cost"] += _cost_or_task(cost_row, "unused_cost")
323319

324320
if has_cost_rows:
325321
overview_key = (group, process_short)
326-
cost_group_acc[overview_key]["total_cost"] += _cost_or_task(cost_row, "cost", task_cost)
327-
cost_group_acc[overview_key]["used_cost"] += _cost_or_task(cost_row, "used_cost", task_cost)
328-
cost_group_acc[overview_key]["unused_cost"] += _cost_or_task(cost_row, "unused_cost", task_cost, default=0.0)
322+
cost_group_acc[overview_key]["total_cost"] += _cost_or_task(cost_row, "cost")
323+
cost_group_acc[overview_key]["used_cost"] += _cost_or_task(cost_row, "used_cost")
324+
cost_group_acc[overview_key]["unused_cost"] += _cost_or_task(cost_row, "unused_cost")
329325
cost_group_acc[overview_key]["n_tasks"] += 1
330326

331327
status = t.get("status")

modules/local/aggregate_benchmark_report_data/tests/test_aggregate.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ def test_build_report_data_has_all_sections(tmp_path, make_run, flat_task, write
3131
}
3232

3333

34-
def test_run_costs_without_cur_uses_task_cost(tmp_path, make_run, flat_task, write_run_json):
34+
def test_run_costs_without_cur_are_zero(tmp_path, make_run, flat_task, write_run_json):
3535
data_dir = tmp_path / "data"
3636
jsonl_dir = tmp_path / "jsonl_bundle"
3737
write_run_json(data_dir, [make_run(tasks=[flat_task(cost=4.2)])])
3838
normalize_jsonl(data_dir, jsonl_dir)
3939

4040
data = build_report_data(jsonl_dir)
41-
assert data["run_costs"][0]["cost"] == 4.2
41+
assert data["run_costs"][0]["cost"] == 0.0
4242
assert data["run_costs"][0]["used_cost"] is None
4343

4444

modules/local/normalize_benchmark_jsonl/bin/benchmark_report_normalize.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def extract_tasks(runs: list[dict[str, Any]]) -> list[dict[str, Any]]:
179179
"peak_rss": task.get("peakRss", 0),
180180
"read_bytes": task.get("readBytes", 0),
181181
"write_bytes": task.get("writeBytes", 0),
182-
"cost": task.get("cost"),
182+
"cost": None,
183183
"executor": task.get("executor", ""),
184184
"machine_type": task.get("machineType", ""),
185185
"cloud_zone": task.get("cloudZone", ""),

modules/local/normalize_benchmark_jsonl/tests/test_normalize.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def test_cached_count_extracted(make_run, flat_task):
2424
def test_nested_tasks_unwrapped(make_run, nested_task):
2525
run = make_run(tasks=[nested_task(cost=2.0), nested_task(cost=3.0)])
2626
rows = extract_tasks([run])
27-
assert sum(r["cost"] for r in rows) == 5.0
27+
assert all(r["cost"] is None for r in rows)
2828

2929

3030
def test_failed_tasks_filtered(make_run, flat_task):

0 commit comments

Comments
 (0)