diff --git a/requirements.txt b/requirements.txt index 3a7ed497d..4a54851bf 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,3 +2,4 @@ numpy==2.2.3 XlsxWriter==3.2.5 PyYAML==6.0.2 pre-commit==4.2.0 +Jinja2==3.1.6 diff --git a/scoreboard/main.py b/scoreboard/main.py index 82e368da6..67a95913c 100644 --- a/scoreboard/main.py +++ b/scoreboard/main.py @@ -3,6 +3,7 @@ import argparse import yaml import csv +from jinja2 import Environment, FileSystemLoader task_types = ['all', 'mpi', 'omp', 'seq', 'stl', 'tbb'] @@ -33,40 +34,7 @@ plagiarism_cfg = yaml.safe_load(file) assert plagiarism_cfg, "Plagiarism configuration is empty" -columns = ''.join(['' + task_type + '' for task_type in task_types]) -html_content = f""" - - - - Task Directories - - - -

Scoreboard

-

Note: This is experimental and results are for reference only!

-

- (S)olution - The correctness and completeness of the implemented solution.
- (A)cceleration - The process of speeding up software to improve performance. - Speedup = T(seq) / T(parallel)
- (E)fficiency - Optimizing software speed-up by improving CPU utilization and resource management. - Efficiency = Speedup / NumProcs * 100%
- (D)eadline - The timeliness of the submission in relation to the given deadline.
- (P)lagiarism - The originality of the work, ensuring no copied content from external sources.
-

- - - - {columns} - - - - {''.join([ - f'' - for _ in range(len(task_types)) - for letter in ('S', 'A', 'E', 'D', 'P') - ])} - -""" +env = Environment(loader=FileSystemLoader(Path(__file__).parent / "templates")) perf_stat_file_path = Path(__file__).parent.parent / "build" / "perf_stat_dir" / "task_run_perf_table.csv" @@ -88,48 +56,48 @@ else: print(f"Warning: Performance stats CSV not found at {perf_stat_file_path}") - +rows = [] for dir in sorted(directories.keys()): - html_content += f"" + row_types = [] total_count = 0 for task_type in task_types: max_sol_points = int(cfg["scoreboard"]["task"][task_type]["solution"]["max"]) - task_count = 0 - if directories[dir].get(task_type) == "done": - html_content += f'' - task_count += max_sol_points - elif directories[dir].get(task_type) == "disabled": - html_content += f'' - task_count += max_sol_points - else: - html_content += '' - html_content += '' - html_content += '' - html_content += '' - is_cheated = \ - dir in plagiarism_cfg["plagiarism"][task_type] or \ - dir[:-len("_disabled")] in plagiarism_cfg["plagiarism"][task_type] + status = directories[dir].get(task_type) + sol_points = max_sol_points if status in ("done", "disabled") else 0 + solution_style = "" + if status == "done": + solution_style = "background-color: lightgreen;" + elif status == "disabled": + solution_style = "background-color: #6495ED;" + + task_points = sol_points + is_cheated = ( + dir in plagiarism_cfg["plagiarism"][task_type] + or dir.rstrip("_disabled") in plagiarism_cfg["plagiarism"][task_type] + ) + plagiarism_points = 0 if is_cheated: plag_coeff = float(cfg["scoreboard"]["plagiarism"]["coefficient"]) - plagiarism_points = -plag_coeff * task_count - task_count += plagiarism_points - html_content += f'' - else: - html_content += '' - total_count += task_count - html_content += f'' - html_content += "" - -html_content += """ -
TasksTotal
{letter}
{dir}{max_sol_points}{max_sol_points}0' - if dir in perf_stats.keys(): - html_content += perf_stats[dir][task_type] - else: - html_content += '?' - html_content += '00{plagiarism_points}0{total_count}
- - -""" + plagiarism_points = -plag_coeff * task_points + task_points += plagiarism_points + + perf_val = perf_stats.get(dir, {}).get(task_type, "?") + + row_types.append( + { + "solution_points": sol_points, + "solution_style": solution_style, + "perf": perf_val, + "plagiarised": is_cheated, + "plagiarism_points": plagiarism_points, + } + ) + total_count += task_points + + rows.append({"task": dir, "types": row_types, "total": total_count}) + +template = env.get_template("index.html.j2") +html_content = template.render(task_types=task_types, rows=rows) parser = argparse.ArgumentParser(description='Generate HTML scoreboard.') parser.add_argument('-o', '--output', type=str, required=True, help='Output file path') diff --git a/scoreboard/templates/index.html.j2 b/scoreboard/templates/index.html.j2 new file mode 100644 index 000000000..713215a41 --- /dev/null +++ b/scoreboard/templates/index.html.j2 @@ -0,0 +1,49 @@ + + + + Task Directories + + + +

Scoreboard

+

Note: This is experimental and results are for reference only!

+

+ (S)olution - The correctness and completeness of the implemented solution.
+ (A)cceleration - The process of speeding up software to improve performance. + Speedup = T(seq) / T(parallel)
+ (E)fficiency - Optimizing software speed-up by improving CPU utilization and resource management. + Efficiency = Speedup / NumProcs * 100%
+ (D)eadline - The timeliness of the submission in relation to the given deadline.
+ (P)lagiarism - The originality of the work, ensuring no copied content from external sources.
+

+ + + + {% for type in task_types %} + + {% endfor %} + + + + {% for type in task_types %} + {% for letter in ('S', 'A', 'E', 'D', 'P') %} + + {% endfor %} + {% endfor %} + + {% for row in rows %} + + + {% for cell in row.types %} + + + + + + {% endfor %} + + + {% endfor %} +
Tasks{{ type }}Total
{{ letter }}
{{ row.task }}{{ cell.solution_points }}{{ cell.perf }}00{{ cell.plagiarism_points }}{{ row.total }}
+ +