Skip to content

Commit c40c9dc

Browse files
committed
Add basic YAML config for the scoreboard
1 parent fca26a9 commit c40c9dc

File tree

5 files changed

+75
-6
lines changed

5 files changed

+75
-6
lines changed

Diff for: requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
numpy==2.2.2
22
XlsxWriter==3.2.2
3+
PyYAML==6.0.2

Diff for: scoreboard/data/performance.yml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
performance:

Diff for: scoreboard/data/plagiarism.yml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
plagiarism:
2+
mpi: []
3+
omp: []
4+
seq:
5+
- broken_example
6+
stl: []
7+
tbb: []
8+
all: []

Diff for: scoreboard/data/threads-config.yml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
scoreboard:
2+
task:
3+
mpi:
4+
solution:
5+
max: 10
6+
plagiarism:
7+
coefficient: 0.5
8+
visible: true
9+
omp:
10+
solution:
11+
max: 9
12+
plagiarism:
13+
coefficient: 0.5
14+
visible: true
15+
seq:
16+
solution:
17+
max: 4
18+
plagiarism:
19+
coefficient: 0.5
20+
visible: true
21+
stl:
22+
solution:
23+
max: 14
24+
plagiarism:
25+
coefficient: 0.5
26+
visible: true
27+
tbb:
28+
solution:
29+
max: 9
30+
plagiarism:
31+
coefficient: 0.5
32+
visible: true
33+
all:
34+
solution:
35+
max: 18
36+
plagiarism:
37+
coefficient: 0.5
38+
visible: true

Diff for: scoreboard/main.py

+27-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from pathlib import Path
22
from collections import defaultdict
33
import argparse
4+
import yaml
45

56
task_types = ['all', 'mpi', 'omp', 'seq', 'stl', 'tbb']
67

@@ -18,7 +19,15 @@
1819
else:
1920
directories[task_name][task_type] = "done"
2021

21-
print(directories)
22+
config_path = Path(__file__).parent / "data" / "threads-config.yml"
23+
assert config_path.exists(), f"Config file not found: {config_path}"
24+
with open(config_path, 'r') as file:
25+
cfg = yaml.safe_load(file)
26+
assert cfg, "Configuration is empty"
27+
plagiarism_config_path = Path(__file__).parent / "data" / "plagiarism.yml"
28+
with open(plagiarism_config_path, 'r') as file:
29+
plagiarism_cfg = yaml.safe_load(file)
30+
assert plagiarism_cfg, "Plagiarism configuration is empty"
2231

2332
columns = ''.join(['<th colspan=5 style="text-align: center;">' + task_type + '</th>' for task_type in task_types])
2433
html_content = f"""
@@ -56,18 +65,30 @@
5665
html_content += f"<tr><td colspan=5>{dir}</td>"
5766
total_count = 0
5867
for task_type in task_types:
68+
max_sol_points = int(cfg["scoreboard"]["task"][task_type]["solution"]["max"])
69+
task_count = 0
5970
if directories[dir].get(task_type) == "done":
60-
html_content += '<td style="text-align: center;">1</td>'
61-
total_count += 1
71+
html_content += f'<td style="text-align: center;">{max_sol_points}</td>'
72+
task_count += max_sol_points
6273
elif directories[dir].get(task_type) == "disabled":
63-
html_content += '<td style="text-align: center;background-color: lightblue;">1</td>'
64-
total_count += 1
74+
html_content += f'<td style="text-align: center;background-color: lightblue;">{max_sol_points}</td>'
75+
task_count += max_sol_points
6576
else:
6677
html_content += '<td style="text-align: center;">0</td>'
6778
html_content += '<td style="text-align: center;">0</td>'
6879
html_content += '<td style="text-align: center;">0</td>'
6980
html_content += '<td style="text-align: center;">0</td>'
70-
html_content += '<td style="text-align: center;">0</td>'
81+
is_cheated = \
82+
dir in plagiarism_cfg["plagiarism"][task_type] or \
83+
dir[:-len("_disabled")] in plagiarism_cfg["plagiarism"][task_type]
84+
if is_cheated:
85+
plag_coeff = float(cfg["scoreboard"]["task"][task_type]["plagiarism"]["coefficient"])
86+
plagiarism_points = -plag_coeff * task_count
87+
task_count += plagiarism_points
88+
html_content += f'<td style="text-align: center; background-color: pink;">{plagiarism_points}</td>'
89+
else:
90+
html_content += '<td style="text-align: center;">0</td>'
91+
total_count += task_count
7192
html_content += f'<td style="text-align: center;">{total_count}</td>'
7293
html_content += "</tr>"
7394

0 commit comments

Comments
 (0)