forked from tddschn/easygraph-bench
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gen_results_markdown.py
executable file
·69 lines (56 loc) · 2.03 KB
/
gen_results_markdown.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env python3
from itertools import takewhile
from jinja2 import FileSystemLoader, Environment
from pathlib import Path
marker = '<!-- the markdown code below this line is auto generated by `./gen_results_markdown.py` -->'
from config import (
get_method_order,
eg_master_dir,
load_functions_name,
di_load_functions_name,
clustering_methods,
shortest_path_methods,
# connected_components_methods,
connected_components_methods_G,
connected_components_methods_G_node,
mst_methods,
other_methods,
method_groups,
dataset_names,
)
e = Environment(loader=FileSystemLoader('templates'))
# Load the Jinja2 template.
template = e.get_template('result_template.jinja.md')
datasets = {
'cheminformatics': 'ENZYMES_g1: nodes: 37 edges: 84',
'bio': 'bio-yeast: nodes: 1458 edges: 1948',
'eco': 'econ-mahindas: nodes: 1258 edges: 7619',
'pgp': 'pgp network of trust: nodes: 39796 edges: 301498',
'pgp_undirected': 'pgp network of trust: nodes: 39796 edges: 197150',
'enron': 'SNAP email-Enron dataset: nodes: 36692 edges: 367662',
'coauthorship': 'Yang Chen\'s co-authorship network on Google Scholar: nodes: 402392 edges: 1234019',
}
# data = {'method_name': 'Dijkstra', 'dataset_name': 'bio'}
# rendered = template.render(data)
# print(rendered)
output = []
for dataset_path, dataset_display_name in datasets.items():
output.append('')
output.append(f'#### {dataset_path}')
output.append('')
output.append(f'{dataset_display_name}')
output.append('')
method_name_list = get_method_order()
for method in method_name_list:
rendered = template.render(
method_name=method,
dataset_name=dataset_path,
)
output.append(rendered)
output.append('')
readme = Path('README.md')
readme_lines_orig = readme.read_text().splitlines()
readme_lines = list(takewhile(lambda line: marker not in line, readme_lines_orig))
readme_lines.append(marker)
readme_lines.extend(output)
readme.write_text('\n'.join(readme_lines))