Skip to content

Commit 54dc528

Browse files
committed
feat: allow basic CSV output for report summary
1 parent 51b7e33 commit 54dc528

File tree

3 files changed

+39
-6
lines changed

3 files changed

+39
-6
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,3 +178,15 @@ SPDX-License-Identifier: Apache-2.0
178178
--skip-expected-failures, --no-skip-expected-failures
179179
Either to save execution into database. (default: True)
180180
```
181+
182+
```
183+
usage: dpbench report [--comparisons [COMPARISON_PAIRS]] [--csv]
184+
185+
Subcommand to generate a summary report from the local DB
186+
187+
options:
188+
-c, --comparisons [COMPARISON_PAIRS]
189+
Comma separated list of implementation pairs to be compared
190+
--csv
191+
Sets the general summary report to output in CSV format (default: False)
192+
```

dpbench/console/report.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ def add_report_arguments(parser: argparse.ArgumentParser):
2828
+ " compared.",
2929
)
3030

31+
parser.add_argument(
32+
"--csv",
33+
action="store_true",
34+
default=False,
35+
help="Sets the summary reports to output in CSV format",
36+
)
37+
3138

3239
def execute_report(args: Namespace, conn: sqlalchemy.Engine):
3340
"""Execute report sub command.
@@ -63,4 +70,5 @@ def execute_report(args: Namespace, conn: sqlalchemy.Engine):
6370
conn=conn,
6471
run_id=args.run_id,
6572
comparison_pairs=comparison_pairs,
73+
csv=args.csv,
6674
)

dpbench/infrastructure/reporter.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,17 +110,22 @@ def generate_legend(conn: sqlalchemy.Engine, run_id: int) -> list[str]:
110110
return legends["postfix"].values.tolist()
111111

112112

113-
def generate_summary(data: pd.DataFrame):
113+
def generate_summary(data: pd.DataFrame, report_csv: bool):
114114
"""prints summary section"""
115115
print("Summary of current implementation")
116116
print("=================================")
117-
print(data.to_string())
117+
118+
if report_csv:
119+
print(data.to_csv(index=False))
120+
else:
121+
print(data.to_string())
118122

119123

120124
def generate_impl_summary_report(
121125
conn: sqlalchemy.Engine,
122126
run_id: int,
123127
implementations: list[str],
128+
report_csv: bool,
124129
):
125130
"""generate implementation summary report with status of each benchmark"""
126131
columns = [
@@ -160,13 +165,14 @@ def generate_impl_summary_report(
160165
con=conn.connect(),
161166
)
162167

163-
generate_summary(df)
168+
generate_summary(df, report_csv)
164169

165170

166171
def generate_performance_report(
167172
conn: sqlalchemy.Engine,
168173
run_id: int,
169174
implementations: list[str],
175+
report_csv: bool,
170176
):
171177
"""generate performance report with median times for each benchmark"""
172178
columns = [
@@ -223,14 +229,15 @@ def generate_performance_report(
223229

224230
df.at[index, impl] = time
225231

226-
generate_summary(df)
232+
generate_summary(df, report_csv)
227233

228234

229235
def generate_comparison_report(
230236
conn: sqlalchemy.Engine,
231237
run_id: int,
232238
implementations: list[str],
233239
comparison_pairs: list[tuple[str, str]],
240+
report_csv: bool,
234241
):
235242
"""generate comparison report with median times for each benchmark"""
236243
if len(comparison_pairs) == 0:
@@ -284,7 +291,7 @@ def generate_comparison_report(
284291
for impl in implementations:
285292
df = df.drop(impl, axis=1)
286293

287-
generate_summary(df)
294+
generate_summary(df, report_csv)
288295

289296

290297
def get_failures_from_results(
@@ -333,26 +340,32 @@ def get_unexpected_failures(
333340
def print_report(
334341
conn: sqlalchemy.Engine,
335342
run_id: int,
343+
csv: bool,
336344
comparison_pairs: list[tuple[str, str]] = [],
337345
):
338346
generate_header(conn, run_id)
339347
implementations = generate_legend(conn, run_id)
340348

341349
generate_impl_summary_report(
342-
conn, run_id=run_id, implementations=implementations
350+
conn,
351+
run_id=run_id,
352+
implementations=implementations,
353+
report_csv=csv,
343354
)
344355

345356
generate_performance_report(
346357
conn,
347358
run_id=run_id,
348359
implementations=implementations,
360+
report_csv=csv,
349361
)
350362

351363
generate_comparison_report(
352364
conn,
353365
run_id=run_id,
354366
implementations=implementations,
355367
comparison_pairs=comparison_pairs,
368+
report_csv=csv,
356369
)
357370

358371
unexpected_failures = get_unexpected_failures(conn, run_id=run_id)

0 commit comments

Comments
 (0)