Spaces:
Running
Running
Update src/aibom_generator/aibom_score_report.py
Browse files
src/aibom_generator/aibom_score_report.py
CHANGED
@@ -5,6 +5,16 @@ def humanize(text: str) -> str:
|
|
5 |
return text.replace('_', ' ').title()
|
6 |
|
7 |
def render_score_html(score_report: Dict[str, any]) -> str:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
html = f"""
|
9 |
<html>
|
10 |
<head>
|
@@ -23,13 +33,14 @@ def render_score_html(score_report: Dict[str, any]) -> str:
|
|
23 |
</style>
|
24 |
</head>
|
25 |
<body>
|
26 |
-
<h2>AIBOM Completeness Score: <strong>{score_report['total_score']}
|
27 |
<h3>Section Scores</h3>
|
28 |
<table>
|
29 |
<tr><th>Section</th><th>Score</th></tr>
|
30 |
"""
|
31 |
for section, score in score_report.get("section_scores", {}).items():
|
32 |
-
|
|
|
33 |
|
34 |
html += "</table>"
|
35 |
|
|
|
5 |
return text.replace('_', ' ').title()
|
6 |
|
7 |
def render_score_html(score_report: Dict[str, any]) -> str:
|
8 |
+
max_scores = score_report.get("max_scores", {
|
9 |
+
"required_fields": 20,
|
10 |
+
"metadata": 20,
|
11 |
+
"component_basic": 20,
|
12 |
+
"component_model_card": 30,
|
13 |
+
"external_references": 10
|
14 |
+
})
|
15 |
+
|
16 |
+
total_max = 100
|
17 |
+
|
18 |
html = f"""
|
19 |
<html>
|
20 |
<head>
|
|
|
33 |
</style>
|
34 |
</head>
|
35 |
<body>
|
36 |
+
<h2>AIBOM Completeness Score: <strong>{score_report['total_score']}/{total_max}</strong></h2>
|
37 |
<h3>Section Scores</h3>
|
38 |
<table>
|
39 |
<tr><th>Section</th><th>Score</th></tr>
|
40 |
"""
|
41 |
for section, score in score_report.get("section_scores", {}).items():
|
42 |
+
max_score = max_scores.get(section, 0)
|
43 |
+
html += f"<tr><td>{humanize(section)}</td><td>{score}/{max_score}</td></tr>"
|
44 |
|
45 |
html += "</table>"
|
46 |
|