ydshieh HF Staff commited on
Commit
97a677b
Β·
verified Β·
1 Parent(s): 8646488

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +63 -9
app.py CHANGED
@@ -240,14 +240,10 @@ def _generate_summary_tables(record: dict) -> Tuple[List[List[str]], List[List[s
240
  for test_name, test_info in by_test_data.items():
241
  count = test_info.get("count", 0)
242
  errors = test_info.get("errors", {})
243
- # Format errors with line breaks between each error type
244
  error_list = [f"{cnt}Γ— {err}" for err, cnt in errors.items()]
245
- error_str = "\nβ€”β€”β€”β€”β€”\n".join(error_list) # Use separator line between errors
246
-
247
- # Format test name with line breaks at :: for better readability
248
- formatted_test_name = test_name.replace("::", "\n::\n")
249
-
250
- by_test_rows.append([formatted_test_name, str(count), error_str])
251
 
252
  # By model table
253
  by_model_rows = []
@@ -255,14 +251,53 @@ def _generate_summary_tables(record: dict) -> Tuple[List[List[str]], List[List[s
255
  for model_name, model_info in by_model_data.items():
256
  count = model_info.get("count", 0)
257
  errors = model_info.get("errors", {})
258
- # Format errors with line breaks between each error type
259
  error_list = [f"{cnt}Γ— {err}" for err, cnt in errors.items()]
260
- error_str = "\nβ€”β€”β€”β€”β€”\n".join(error_list) # Use separator line between errors
261
  by_model_rows.append([model_name, str(count), error_str])
262
 
263
  return by_test_rows, by_model_rows
264
 
265
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
266
  def _generate_markdown_summary(record: dict) -> str:
267
  """Generate markdown summary for copy-paste to GitHub."""
268
 
@@ -350,6 +385,7 @@ def _generate_pytest_commands(record: dict) -> str:
350
 
351
  def query(repo: str, pr: str, sha: str) -> Tuple[
352
  str, # metadata_info
 
353
  List[List[str]], # by_test_table
354
  List[List[str]], # by_model_table
355
  str, # markdown_summary
@@ -366,6 +402,7 @@ def query(repo: str, pr: str, sha: str) -> Tuple[
366
  if not pr:
367
  return (
368
  "**Error:** PR number is required.",
 
369
  [],
370
  [],
371
  "",
@@ -380,6 +417,7 @@ def query(repo: str, pr: str, sha: str) -> Tuple[
380
  if not records:
381
  return (
382
  f"**No records found** for PR {pr}.",
 
383
  [],
384
  [],
385
  "",
@@ -404,6 +442,9 @@ def query(repo: str, pr: str, sha: str) -> Tuple[
404
  ]
405
  metadata_info = "\n\n".join(metadata_lines)
406
 
 
 
 
407
  # Generate tables
408
  by_test_rows, by_model_rows = _generate_summary_tables(latest_record)
409
 
@@ -420,6 +461,7 @@ def query(repo: str, pr: str, sha: str) -> Tuple[
420
 
421
  return (
422
  metadata_info,
 
423
  by_test_rows,
424
  by_model_rows,
425
  markdown_summary,
@@ -492,6 +534,15 @@ with gr.Blocks(title="CircleCI Test Results Viewer") as demo:
492
  with gr.Tab("πŸ“Š Summary"):
493
  metadata_box = gr.Markdown(label="Metadata")
494
 
 
 
 
 
 
 
 
 
 
495
  gr.Markdown("### πŸ“ By Test")
496
  by_test_table = gr.Dataframe(
497
  headers=["Test", "Failures", "Full error(s)"],
@@ -559,6 +610,7 @@ with gr.Blocks(title="CircleCI Test Results Viewer") as demo:
559
  else:
560
  return (
561
  "Enter a PR number and click Search",
 
562
  [],
563
  [],
564
  "",
@@ -573,6 +625,7 @@ with gr.Blocks(title="CircleCI Test Results Viewer") as demo:
573
  inputs=[repo_box, pr_box, sha_box],
574
  outputs=[
575
  metadata_box,
 
576
  by_test_table,
577
  by_model_table,
578
  markdown_output,
@@ -594,6 +647,7 @@ with gr.Blocks(title="CircleCI Test Results Viewer") as demo:
594
  inputs=[repo_box, pr_box, sha_box],
595
  outputs=[
596
  metadata_box,
 
597
  by_test_table,
598
  by_model_table,
599
  markdown_output,
 
240
  for test_name, test_info in by_test_data.items():
241
  count = test_info.get("count", 0)
242
  errors = test_info.get("errors", {})
243
+ # Format errors as "Nx error_message" for each unique error
244
  error_list = [f"{cnt}Γ— {err}" for err, cnt in errors.items()]
245
+ error_str = "; ".join(error_list)
246
+ by_test_rows.append([test_name, str(count), error_str])
 
 
 
 
247
 
248
  # By model table
249
  by_model_rows = []
 
251
  for model_name, model_info in by_model_data.items():
252
  count = model_info.get("count", 0)
253
  errors = model_info.get("errors", {})
254
+ # Format errors as "Nx error_message" for each unique error
255
  error_list = [f"{cnt}Γ— {err}" for err, cnt in errors.items()]
256
+ error_str = "; ".join(error_list)
257
  by_model_rows.append([model_name, str(count), error_str])
258
 
259
  return by_test_rows, by_model_rows
260
 
261
 
262
+ def _generate_readable_summary(record: dict) -> str:
263
+ """Generate a readable text summary instead of cramped tables."""
264
+
265
+ by_test_data = record.get("by_test", {})
266
+ by_model_data = record.get("by_model", {})
267
+
268
+ summary = []
269
+
270
+ # By Test Summary
271
+ if by_test_data:
272
+ summary.append("## πŸ“ Failed Tests\n")
273
+ for test_name, test_info in by_test_data.items():
274
+ count = test_info.get("count", 0)
275
+ errors = test_info.get("errors", {})
276
+
277
+ summary.append(f"### {test_name}")
278
+ summary.append(f"**Failures:** {count}\n")
279
+ summary.append("**Errors:**")
280
+ for err, cnt in errors.items():
281
+ summary.append(f"- `{cnt}Γ—` {err}")
282
+ summary.append("\n---\n")
283
+
284
+ # By Model Summary
285
+ if by_model_data:
286
+ summary.append("\n## 🏷️ Failed Models\n")
287
+ for model_name, model_info in by_model_data.items():
288
+ count = model_info.get("count", 0)
289
+ errors = model_info.get("errors", {})
290
+
291
+ summary.append(f"### {model_name}")
292
+ summary.append(f"**Failures:** {count}\n")
293
+ summary.append("**Errors:**")
294
+ for err, cnt in errors.items():
295
+ summary.append(f"- `{cnt}Γ—` {err}")
296
+ summary.append("\n---\n")
297
+
298
+ return "\n".join(summary)
299
+
300
+
301
  def _generate_markdown_summary(record: dict) -> str:
302
  """Generate markdown summary for copy-paste to GitHub."""
303
 
 
385
 
386
  def query(repo: str, pr: str, sha: str) -> Tuple[
387
  str, # metadata_info
388
+ str, # readable_summary
389
  List[List[str]], # by_test_table
390
  List[List[str]], # by_model_table
391
  str, # markdown_summary
 
402
  if not pr:
403
  return (
404
  "**Error:** PR number is required.",
405
+ "",
406
  [],
407
  [],
408
  "",
 
417
  if not records:
418
  return (
419
  f"**No records found** for PR {pr}.",
420
+ "",
421
  [],
422
  [],
423
  "",
 
442
  ]
443
  metadata_info = "\n\n".join(metadata_lines)
444
 
445
+ # Generate readable summary
446
+ readable_summary = _generate_readable_summary(latest_record)
447
+
448
  # Generate tables
449
  by_test_rows, by_model_rows = _generate_summary_tables(latest_record)
450
 
 
461
 
462
  return (
463
  metadata_info,
464
+ readable_summary,
465
  by_test_rows,
466
  by_model_rows,
467
  markdown_summary,
 
534
  with gr.Tab("πŸ“Š Summary"):
535
  metadata_box = gr.Markdown(label="Metadata")
536
 
537
+ gr.Markdown("---")
538
+
539
+ # Use a scrollable Markdown display instead of cramped tables
540
+ readable_summary = gr.Markdown(
541
+ label="Test Failures",
542
+ value="",
543
+ )
544
+
545
+ with gr.Tab("πŸ“‹ Tables (Compact View)"):
546
  gr.Markdown("### πŸ“ By Test")
547
  by_test_table = gr.Dataframe(
548
  headers=["Test", "Failures", "Full error(s)"],
 
610
  else:
611
  return (
612
  "Enter a PR number and click Search",
613
+ "",
614
  [],
615
  [],
616
  "",
 
625
  inputs=[repo_box, pr_box, sha_box],
626
  outputs=[
627
  metadata_box,
628
+ readable_summary,
629
  by_test_table,
630
  by_model_table,
631
  markdown_output,
 
647
  inputs=[repo_box, pr_box, sha_box],
648
  outputs=[
649
  metadata_box,
650
+ readable_summary,
651
  by_test_table,
652
  by_model_table,
653
  markdown_output,