Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/check_kernel_freshness.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ def _format_freshness_report(results: list[dict], skipped_kernels: list[str]) ->

items = []
for result in sorted_results:
items.append(f"• {result['source_url']}: upstream is {result['days_behind']} days newer")
items.append(f"• {result['kernel_dir']} ({result['source_url']}): upstream is {result['days_behind']} days newer")

report = f"{heading}\n\n" + "\n".join(items)

Expand Down
40 changes: 39 additions & 1 deletion scripts/test_kernel_freshness_lookup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import sys
from datetime import datetime
from pathlib import Path

from check_kernel_freshness import KERNEL_SOURCE_MAPPING
Expand Down Expand Up @@ -66,11 +67,48 @@ def test_kernel_mapping_completeness(root_path: Path) -> bool:
return all_passed


def test_freshness_report_includes_kernel_dir() -> bool:
"""Verify that _format_freshness_report includes kernel_dir in each line.

Regression test for: multiple kernels sharing the same source_url would
produce duplicate, unactionable alert lines with no local directory name.
"""
from datetime import timezone
from check_kernel_freshness import _format_freshness_report

shared_url = "https://github.com/Dao-AILab/flash-attention"
now = datetime.now(tz=timezone.utc)
results = [
{"kernel_dir": "flash-attn2", "source_url": shared_url, "days_behind": 12,
"upstream_date": now, "local_date": now},
{"kernel_dir": "flash-attn3", "source_url": shared_url, "days_behind": 5,
"upstream_date": now, "local_date": now},
]

report = _format_freshness_report(results, skipped_kernels=[])

all_passed = True
for result in results:
if result["kernel_dir"] not in report:
print(f"❌ ERROR: '{result['kernel_dir']}' not found in freshness report")
all_passed = False

if all_passed:
print("✅ _format_freshness_report correctly includes kernel_dir in each report line")

return all_passed


def main() -> int:
root_path = Path(__file__).parent.parent.resolve()
print(f"Testing kernel mapping in: {root_path}\n")

if test_kernel_mapping_completeness(root_path):
results = [
test_kernel_mapping_completeness(root_path),
test_freshness_report_includes_kernel_dir(),
]

if all(results):
print("\n✅ All tests passed!")
return 0
else:
Expand Down