Skip to content

Commit f472b02

Browse files
authored
Implement basic version of scoreboard (#280)
Initial version of #112
1 parent 2abbd77 commit f472b02

File tree

3 files changed

+84
-0
lines changed

3 files changed

+84
-0
lines changed

scoreboard/index.html

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
<!DOCTYPE html>
3+
<html>
4+
<head>
5+
<title>Task Directories</title>
6+
<link rel="stylesheet" type="text/css" href="static/main.css">
7+
</head>
8+
<body>
9+
<h1>Scoreboard</h1>
10+
<table>
11+
<tr>
12+
<th>Tasks</th>
13+
<th>all</th><th>mpi</th><th>omp</th><th>seq</th><th>stl</th><th>tbb</th>
14+
</tr>
15+
<tr><td>example</td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>example_disabled</td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
16+
</table>
17+
</body>
18+
</html>

scoreboard/main.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
from pathlib import Path
2+
from collections import defaultdict
3+
4+
task_types = ['all', 'mpi', 'omp', 'seq', 'stl', 'tbb']
5+
6+
tasks_dir = Path('tasks')
7+
8+
directories = defaultdict(dict)
9+
10+
for task_type in task_types:
11+
task_type_dir = tasks_dir / task_type
12+
if task_type_dir.exists() and task_type_dir.is_dir():
13+
for task_name in (d.name for d in task_type_dir.iterdir() if d.is_dir()):
14+
directories[task_name][task_type] = True
15+
16+
print(directories)
17+
18+
columns = ''.join(['<th>' + task_type + '</th>' for task_type in task_types])
19+
html_content = f"""
20+
<!DOCTYPE html>
21+
<html>
22+
<head>
23+
<title>Task Directories</title>
24+
<link rel="stylesheet" type="text/css" href="static/main.css">
25+
</head>
26+
<body>
27+
<h1>Scoreboard</h1>
28+
<table>
29+
<tr>
30+
<th>Tasks</th>
31+
{columns}
32+
</tr>
33+
"""
34+
35+
for dir in directories:
36+
html_content += f"<tr><td>{dir}</td>"
37+
for task_type in task_types:
38+
if directories[dir].get(task_type):
39+
html_content += "<td>✔</td>"
40+
else:
41+
html_content += "<td>✘</td>"
42+
html_content += "</tr>"
43+
44+
html_content += """
45+
</table>
46+
</body>
47+
</html>
48+
"""
49+
50+
output_file = Path('scoreboard/index.html')
51+
with open(output_file, 'w') as file:
52+
file.write(html_content)
53+
54+
print(f"HTML page generated at {output_file}")

scoreboard/static/main.css

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
table {
2+
width: 100%;
3+
border-collapse: collapse;
4+
}
5+
th, td {
6+
border: 1px solid black;
7+
padding: 8px;
8+
text-align: left;
9+
}
10+
th {
11+
background-color: #f2f2f2;
12+
}

0 commit comments

Comments
 (0)