Update app.py
Browse files
app.py
CHANGED
|
@@ -240,9 +240,15 @@ 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 |
-
|
| 244 |
-
|
| 245 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 246 |
by_test_rows.append([test_name, str(count), error_str])
|
| 247 |
|
| 248 |
# By model table
|
|
@@ -251,52 +257,20 @@ def _generate_summary_tables(record: dict) -> Tuple[List[List[str]], List[List[s
|
|
| 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 |
-
|
| 255 |
-
|
| 256 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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."""
|
|
@@ -385,7 +359,6 @@ def _generate_pytest_commands(record: dict) -> str:
|
|
| 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,7 +375,6 @@ def query(repo: str, pr: str, sha: str) -> Tuple[
|
|
| 402 |
if not pr:
|
| 403 |
return (
|
| 404 |
"**Error:** PR number is required.",
|
| 405 |
-
"",
|
| 406 |
[],
|
| 407 |
[],
|
| 408 |
"",
|
|
@@ -417,7 +389,6 @@ def query(repo: str, pr: str, sha: str) -> Tuple[
|
|
| 417 |
if not records:
|
| 418 |
return (
|
| 419 |
f"**No records found** for PR {pr}.",
|
| 420 |
-
"",
|
| 421 |
[],
|
| 422 |
[],
|
| 423 |
"",
|
|
@@ -442,9 +413,6 @@ def query(repo: str, pr: str, sha: str) -> Tuple[
|
|
| 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,7 +429,6 @@ def query(repo: str, pr: str, sha: str) -> Tuple[
|
|
| 461 |
|
| 462 |
return (
|
| 463 |
metadata_info,
|
| 464 |
-
readable_summary,
|
| 465 |
by_test_rows,
|
| 466 |
by_model_rows,
|
| 467 |
markdown_summary,
|
|
@@ -535,26 +502,23 @@ with gr.Blocks(title="CircleCI Test Results Viewer") as demo:
|
|
| 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)"],
|
| 549 |
wrap=True,
|
| 550 |
interactive=False,
|
|
|
|
| 551 |
)
|
| 552 |
|
|
|
|
| 553 |
gr.Markdown("### π·οΈ By Model")
|
|
|
|
| 554 |
by_model_table = gr.Dataframe(
|
| 555 |
headers=["Model", "Failures", "Full error(s)"],
|
| 556 |
wrap=True,
|
| 557 |
interactive=False,
|
|
|
|
| 558 |
)
|
| 559 |
|
| 560 |
with gr.Tab("π Copy for GitHub"):
|
|
@@ -610,7 +574,6 @@ with gr.Blocks(title="CircleCI Test Results Viewer") as demo:
|
|
| 610 |
else:
|
| 611 |
return (
|
| 612 |
"Enter a PR number and click Search",
|
| 613 |
-
"",
|
| 614 |
[],
|
| 615 |
[],
|
| 616 |
"",
|
|
@@ -625,7 +588,6 @@ with gr.Blocks(title="CircleCI Test Results Viewer") as demo:
|
|
| 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,7 +609,6 @@ with gr.Blocks(title="CircleCI Test Results Viewer") as demo:
|
|
| 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,
|
|
|
|
| 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 |
+
|
| 244 |
+
# Format errors with each on a NEW line, like GitHub table format
|
| 245 |
+
error_lines = []
|
| 246 |
+
for err, cnt in errors.items():
|
| 247 |
+
error_lines.append(f"{cnt}Γ {err}")
|
| 248 |
+
|
| 249 |
+
# Join with actual newlines - Gradio will render these in the table
|
| 250 |
+
error_str = "\n".join(error_lines)
|
| 251 |
+
|
| 252 |
by_test_rows.append([test_name, str(count), error_str])
|
| 253 |
|
| 254 |
# By model table
|
|
|
|
| 257 |
for model_name, model_info in by_model_data.items():
|
| 258 |
count = model_info.get("count", 0)
|
| 259 |
errors = model_info.get("errors", {})
|
| 260 |
+
|
| 261 |
+
# Format errors with each on a NEW line
|
| 262 |
+
error_lines = []
|
| 263 |
+
for err, cnt in errors.items():
|
| 264 |
+
error_lines.append(f"{cnt}Γ {err}")
|
| 265 |
+
|
| 266 |
+
# Join with actual newlines
|
| 267 |
+
error_str = "\n".join(error_lines)
|
| 268 |
+
|
| 269 |
by_model_rows.append([model_name, str(count), error_str])
|
| 270 |
|
| 271 |
return by_test_rows, by_model_rows
|
| 272 |
|
| 273 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 274 |
|
| 275 |
def _generate_markdown_summary(record: dict) -> str:
|
| 276 |
"""Generate markdown summary for copy-paste to GitHub."""
|
|
|
|
| 359 |
|
| 360 |
def query(repo: str, pr: str, sha: str) -> Tuple[
|
| 361 |
str, # metadata_info
|
|
|
|
| 362 |
List[List[str]], # by_test_table
|
| 363 |
List[List[str]], # by_model_table
|
| 364 |
str, # markdown_summary
|
|
|
|
| 375 |
if not pr:
|
| 376 |
return (
|
| 377 |
"**Error:** PR number is required.",
|
|
|
|
| 378 |
[],
|
| 379 |
[],
|
| 380 |
"",
|
|
|
|
| 389 |
if not records:
|
| 390 |
return (
|
| 391 |
f"**No records found** for PR {pr}.",
|
|
|
|
| 392 |
[],
|
| 393 |
[],
|
| 394 |
"",
|
|
|
|
| 413 |
]
|
| 414 |
metadata_info = "\n\n".join(metadata_lines)
|
| 415 |
|
|
|
|
|
|
|
|
|
|
| 416 |
# Generate tables
|
| 417 |
by_test_rows, by_model_rows = _generate_summary_tables(latest_record)
|
| 418 |
|
|
|
|
| 429 |
|
| 430 |
return (
|
| 431 |
metadata_info,
|
|
|
|
| 432 |
by_test_rows,
|
| 433 |
by_model_rows,
|
| 434 |
markdown_summary,
|
|
|
|
| 502 |
metadata_box = gr.Markdown(label="Metadata")
|
| 503 |
|
| 504 |
gr.Markdown("---")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 505 |
gr.Markdown("### π By Test")
|
| 506 |
+
|
| 507 |
by_test_table = gr.Dataframe(
|
| 508 |
headers=["Test", "Failures", "Full error(s)"],
|
| 509 |
wrap=True,
|
| 510 |
interactive=False,
|
| 511 |
+
row_count=(5, "dynamic"), # Start with 5 rows, expand as needed
|
| 512 |
)
|
| 513 |
|
| 514 |
+
gr.Markdown("---")
|
| 515 |
gr.Markdown("### π·οΈ By Model")
|
| 516 |
+
|
| 517 |
by_model_table = gr.Dataframe(
|
| 518 |
headers=["Model", "Failures", "Full error(s)"],
|
| 519 |
wrap=True,
|
| 520 |
interactive=False,
|
| 521 |
+
row_count=(3, "dynamic"), # Start with 3 rows, expand as needed
|
| 522 |
)
|
| 523 |
|
| 524 |
with gr.Tab("π Copy for GitHub"):
|
|
|
|
| 574 |
else:
|
| 575 |
return (
|
| 576 |
"Enter a PR number and click Search",
|
|
|
|
| 577 |
[],
|
| 578 |
[],
|
| 579 |
"",
|
|
|
|
| 588 |
inputs=[repo_box, pr_box, sha_box],
|
| 589 |
outputs=[
|
| 590 |
metadata_box,
|
|
|
|
| 591 |
by_test_table,
|
| 592 |
by_model_table,
|
| 593 |
markdown_output,
|
|
|
|
| 609 |
inputs=[repo_box, pr_box, sha_box],
|
| 610 |
outputs=[
|
| 611 |
metadata_box,
|
|
|
|
| 612 |
by_test_table,
|
| 613 |
by_model_table,
|
| 614 |
markdown_output,
|