|
1 | 1 | from pathlib import Path |
2 | 2 | from collections import defaultdict |
| 3 | +from datetime import datetime |
3 | 4 | import argparse |
| 5 | +import subprocess |
4 | 6 | import yaml |
5 | 7 | import csv |
6 | 8 | from jinja2 import Environment, FileSystemLoader |
|
29 | 31 | with open(config_path, "r") as file: |
30 | 32 | cfg = yaml.safe_load(file) |
31 | 33 | assert cfg, "Configuration is empty" |
| 34 | +eff_num_proc = int(cfg["scoreboard"].get("efficiency", {}).get("num_proc", 1)) |
| 35 | +deadlines_cfg = cfg["scoreboard"].get("deadlines", {}) |
32 | 36 | plagiarism_config_path = Path(__file__).parent / "data" / "plagiarism.yml" |
33 | 37 | with open(plagiarism_config_path, "r") as file: |
34 | 38 | plagiarism_cfg = yaml.safe_load(file) |
|
85 | 89 |
|
86 | 90 | perf_val = perf_stats.get(dir, {}).get(task_type, "?") |
87 | 91 |
|
| 92 | + # Calculate efficiency if performance data is available |
| 93 | + efficiency = "?" |
| 94 | + try: |
| 95 | + perf_float = float(perf_val) |
| 96 | + if perf_float > 0: |
| 97 | + speedup = 1.0 / perf_float |
| 98 | + efficiency = f"{speedup / eff_num_proc * 100:.2f}" |
| 99 | + except (ValueError, TypeError): |
| 100 | + pass |
| 101 | + |
| 102 | + # Calculate deadline penalty points |
| 103 | + deadline_points = 0 |
| 104 | + deadline_str = deadlines_cfg.get(task_type) |
| 105 | + if status == "done" and deadline_str: |
| 106 | + try: |
| 107 | + deadline_dt = datetime.fromisoformat(deadline_str) |
| 108 | + git_cmd = [ |
| 109 | + "git", |
| 110 | + "log", |
| 111 | + "-1", |
| 112 | + "--format=%ct", |
| 113 | + str(tasks_dir / (dir + ("_disabled" if status == "disabled" else "")) / task_type), |
| 114 | + ] |
| 115 | + result = subprocess.run(git_cmd, capture_output=True, text=True) |
| 116 | + if result.stdout.strip().isdigit(): |
| 117 | + commit_dt = datetime.fromtimestamp(int(result.stdout.strip())) |
| 118 | + days_late = (commit_dt - deadline_dt).days |
| 119 | + if days_late > 0: |
| 120 | + deadline_points = -days_late |
| 121 | + except Exception: |
| 122 | + pass |
| 123 | + |
88 | 124 | row_types.append( |
89 | 125 | { |
90 | 126 | "solution_points": sol_points, |
91 | 127 | "solution_style": solution_style, |
92 | 128 | "perf": perf_val, |
| 129 | + "efficiency": efficiency, |
| 130 | + "deadline_points": deadline_points, |
93 | 131 | "plagiarised": is_cheated, |
94 | 132 | "plagiarism_points": plagiarism_points, |
95 | 133 | } |
|
0 commit comments