Skip to content

Commit c5e3616

Browse files
committed
lint
1 parent f3f4a3d commit c5e3616

3 files changed

Lines changed: 39 additions & 23 deletions

File tree

‎src/abench/report.py‎

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,9 @@ def outcome_keys(runs):
246246
"""Preserve first-appearance order across runs, mirroring component ordering."""
247247
keys = []
248248
for run in runs:
249-
for component, cdata in run["component_summaries"].get("components", {}).items():
249+
for component, cdata in (
250+
run["component_summaries"].get("components", {}).items()
251+
):
250252
for table, tdata in cdata.get("tables", {}).items():
251253
for outcome in tdata.get("outcomes", {}):
252254
key = (component, table, outcome)
@@ -258,7 +260,10 @@ def outcome_keys(runs):
258260
def outcome_data(run, key):
259261
component, table, outcome = key
260262
tables = (
261-
run["component_summaries"].get("components", {}).get(component, {}).get("tables", {})
263+
run["component_summaries"]
264+
.get("components", {})
265+
.get(component, {})
266+
.get("tables", {})
262267
)
263268
return tables.get(table, {}).get("outcomes", {}).get(outcome)
264269

@@ -274,7 +279,9 @@ def outcome_categories(runs, key):
274279

275280

276281
def outcome_totals(runs, key):
277-
return [sum((outcome_data(run, key) or {}).get("counts", {}).values()) for run in runs]
282+
return [
283+
sum((outcome_data(run, key) or {}).get("counts", {}).values()) for run in runs
284+
]
278285

279286

280287
def outcome_table(runs, key, categories):
@@ -319,7 +326,7 @@ def outcome_chart(runs, key, categories):
319326
width = share * 5.3
320327
rows.append(
321328
f'<rect x="310" y="{y}" width="{width:.2f}" height="12" fill="{COLORS[i % len(COLORS)]}">'
322-
f'<title>{escape(run["spec"]["label"])}: {count:,} ({share:.1f}%)</title></rect>'
329+
f"<title>{escape(run['spec']['label'])}: {count:,} ({share:.1f}%)</title></rect>"
323330
)
324331
y += 17
325332
y += 10
@@ -358,15 +365,15 @@ def numeric_chart(runs, key):
358365
hi_x = 310 + (value["max"] - minimum) * scale
359366
rows.append(
360367
f'<rect x="{mean_x - 2:.2f}" y="{y}" width="4" height="12" fill="{COLORS[i % len(COLORS)]}">'
361-
f'<title>{escape(run["spec"]["label"])}: mean {value["mean"]:.3f}, '
362-
f'range [{value["min"]:.3f}, {value["max"]:.3f}]</title></rect>'
368+
f"<title>{escape(run['spec']['label'])}: mean {value['mean']:.3f}, "
369+
f"range [{value['min']:.3f}, {value['max']:.3f}]</title></rect>"
363370
f'<path d="M {lo_x:.2f} {y + 6} H {hi_x:.2f}" stroke="#222"/>'
364371
)
365372
y += 17
366373
return (
367374
f'<svg viewBox="0 0 900 {y + 20}" role="img" aria-label="Outcome numeric range">'
368375
f'<text x="310" y="18">{minimum:.2f}</text><text x="790" y="18">{maximum:.2f}</text>'
369-
f'{"".join(rows)}</svg>'
376+
f"{''.join(rows)}</svg>"
370377
)
371378

372379

@@ -382,7 +389,9 @@ def summary_table(runs, key):
382389
cells = []
383390
for run in runs:
384391
data = outcome_data(run, key)
385-
cells.append(f"<td>{data[stat]:,}</td>" if data and stat in data else "<td>—</td>")
392+
cells.append(
393+
f"<td>{data[stat]:,}</td>" if data and stat in data else "<td>—</td>"
394+
)
386395
rows.append(f"<tr><th>{label}</th>{''.join(cells)}</tr>")
387396
return f"<table><tr><th>Statistic</th>{headers}</tr>{''.join(rows)}</table>"
388397

@@ -414,7 +423,9 @@ def outcomes_section(runs):
414423
else:
415424
body = summary_table(runs, key)
416425
style = "" if index == 0 else "display:none"
417-
panels.append(f'<div class="outcome-panel" id="{anchor}" style="{style}">{body}</div>')
426+
panels.append(
427+
f'<div class="outcome-panel" id="{anchor}" style="{style}">{body}</div>'
428+
)
418429
return (
419430
"<h2>Component outcomes</h2>"
420431
"<p>Model choice distributions recovered from ActivitySim checkpoints, merged across "
@@ -618,7 +629,8 @@ def report(directories, destination):
618629
"""
619630
outcomes_html = outcomes_section(runs)
620631
# Outcome labels live only in escaped HTML attributes/text, never in JS.
621-
outcomes_script = """
632+
outcomes_script = (
633+
"""
622634
<script>
623635
const outcomeSelect = document.getElementById('outcome-select');
624636
const outcomesSection = document.getElementById('outcomes-section');
@@ -638,7 +650,10 @@ def report(directories, destination):
638650
});
639651
}
640652
</script>
641-
""" if outcomes_html else ""
653+
"""
654+
if outcomes_html
655+
else ""
656+
)
642657
document = f"""<!doctype html><html lang="en"><meta charset="utf-8"><meta name="viewport" content="width=device-width"><title>abench report</title>
643658
<style>body{{font:15px system-ui;margin:2rem;color:#17212b}}.cards{{display:flex;gap:24px;overflow-x:auto}}article{{flex:1;min-width:420px;border:1px solid #ccc;padding:16px}}pre{{white-space:pre-wrap;overflow-wrap:anywhere;font-size:12px}}svg{{width:100%;min-width:420px}}table{{border-collapse:collapse;width:100%}}th,td{{padding:10px;text-align:left;border-bottom:1px solid #ddd}}.fastest{{background:#d7f3dc}}small{{color:#58616a}}.runtime{{max-width:1200px}}.scroll{{overflow-x:auto}}.outcome-toggle button{{margin-left:4px;border:1px solid #ccc;background:#f4f6f8;padding:4px 10px;border-radius:4px;cursor:pointer}}.outcome-toggle button.active{{background:#0072b2;color:#fff;border-color:#0072b2}}.plot-view{{display:none}}#outcomes-section.plot-mode .table-view{{display:none}}#outcomes-section.plot-mode .plot-view{{display:block}}</style>
644659
<h1>abench report</h1><p>Whole-container cgroup v2 memory counts shared pages once, including file cache, kernel memory and the supervisor. Swap is recorded separately in memory.csv. Cache preparation and post-run summaries are excluded. Peak is the kernel high-water mark sampled during the model lifetime, including container startup. Memory panels use identical axes.</p>

‎src/abench/runtime/component_summary.py‎

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,9 @@ def add(*names):
201201

202202

203203
def inferred_segments(outcomes, columns):
204-
return [
205-
name for name in AUTO_SEGMENTS if name in columns and name not in outcomes
206-
][:1]
204+
return [name for name in AUTO_SEGMENTS if name in columns and name not in outcomes][
205+
:1
206+
]
207207

208208

209209
def add_counts(target, series):
@@ -307,7 +307,9 @@ def component_summary(output, profile=None):
307307
if rule is None and not store.changed(table, component, previous):
308308
continue
309309
columns = store.columns(table, component)
310-
previous_columns = store.columns(table, previous) if previous else []
310+
previous_columns = (
311+
store.columns(table, previous) if previous else []
312+
)
311313
new_columns = [c for c in columns if c not in previous_columns]
312314
if rule:
313315
requested = (
@@ -356,12 +358,12 @@ def component_summary(output, profile=None):
356358
frame = apply_filters(frame, filters)
357359
add_frame(table_result, frame, outcomes, segments)
358360
else:
359-
table_result["rows"] = table_result.get(
360-
"rows", 0
361-
) + store.rows(table, component)
362-
table_result["partitions"] = table_result.get(
363-
"partitions", 0
364-
) + 1
361+
table_result["rows"] = table_result.get("rows", 0) + store.rows(
362+
table, component
363+
)
364+
table_result["partitions"] = (
365+
table_result.get("partitions", 0) + 1
366+
)
365367
finally:
366368
store.close()
367369
finalize_counts(result, category_limit)

‎tests/test_measurement.py‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,7 @@ def test_post_run_component_summaries_merge_worker_segments(self):
289289
]
290290
for worker_number, frame in enumerate(partitions):
291291
pipeline = (
292-
output
293-
/ f"mp_households_{worker_number}-pipeline.parquetpipeline"
292+
output / f"mp_households_{worker_number}-pipeline.parquetpipeline"
294293
)
295294
(pipeline / "trips").mkdir(parents=True)
296295
frame[["primary_purpose"]].to_parquet(pipeline / "trips/seed.parquet")

0 commit comments

Comments
 (0)