|
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) |
|
83 | 87 |
|
84 | 88 | perf_val = perf_stats.get(dir, {}).get(task_type, "?") |
85 | 89 |
|
| 90 | + # Calculate efficiency if performance data is available |
| 91 | + efficiency = "?" |
| 92 | + try: |
| 93 | + perf_float = float(perf_val) |
| 94 | + if perf_float > 0: |
| 95 | + speedup = 1.0 / perf_float |
| 96 | + efficiency = f"{speedup / eff_num_proc * 100:.2f}" |
| 97 | + except (ValueError, TypeError): |
| 98 | + pass |
| 99 | + |
| 100 | + # Calculate deadline penalty points |
| 101 | + deadline_points = 0 |
| 102 | + deadline_str = deadlines_cfg.get(task_type) |
| 103 | + if status == "done" and deadline_str: |
| 104 | + try: |
| 105 | + deadline_dt = datetime.fromisoformat(deadline_str) |
| 106 | + git_cmd = [ |
| 107 | + "git", |
| 108 | + "log", |
| 109 | + "-1", |
| 110 | + "--format=%ct", |
| 111 | + str(tasks_dir / (dir + ("_disabled" if status == "disabled" else "")) / task_type), |
| 112 | + ] |
| 113 | + result = subprocess.run(git_cmd, capture_output=True, text=True) |
| 114 | + if result.stdout.strip().isdigit(): |
| 115 | + commit_dt = datetime.fromtimestamp(int(result.stdout.strip())) |
| 116 | + days_late = (commit_dt - deadline_dt).days |
| 117 | + if days_late > 0: |
| 118 | + deadline_points = -days_late |
| 119 | + except Exception: |
| 120 | + pass |
| 121 | + |
86 | 122 | row_types.append( |
87 | 123 | { |
88 | 124 | "solution_points": sol_points, |
89 | 125 | "solution_style": solution_style, |
90 | 126 | "perf": perf_val, |
| 127 | + "efficiency": efficiency, |
| 128 | + "deadline_points": deadline_points, |
91 | 129 | "plagiarised": is_cheated, |
92 | 130 | "plagiarism_points": plagiarism_points, |
93 | 131 | } |
|
0 commit comments