Skip to content

Commit 350af30

Browse files
committed
Fix upstreaming dashboard
1 parent b869217 commit 350af30

File tree

1 file changed

+81
-0
lines changed

1 file changed

+81
-0
lines changed

scripts/upstreaming_dashboard.py

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#!/usr/bin/env python3
2+
3+
"""
4+
This script parse the aggregate json file and filters all PRs which touch some given files.
5+
"""
6+
7+
import json
8+
import os
9+
from typing import List
10+
import subprocess
11+
import json
12+
import pathlib
13+
14+
def main():
15+
pr_file = subprocess.run(["curl", "https://raw.githubusercontent.com/leanprover-community/queueboard/refs/heads/master/processed_data/open_pr_data.json"],
16+
capture_output = True,
17+
text = True)
18+
pr_json = json.loads(pr_file.stdout)["pr_statusses"]
19+
pr_dict = {pr["number"] : pr for pr in pr_json}
20+
21+
file_touched_pr = {}
22+
for pr in pr_dict:
23+
for file in pr_dict[pr]["files"]:
24+
pr_data = {
25+
"number" : pr,
26+
"title" : pr_dict[pr]["title"],
27+
"num_files": len(pr_dict[pr]["files"]),
28+
"is_draft": pr_dict[pr]["is_draft"]
29+
}
30+
if file not in file_touched_pr: file_touched_pr[file] = [pr_data]
31+
else: file_touched_pr[file].append(pr_data)
32+
33+
project_files = {}
34+
for entry in pathlib.Path("PersistentDecomp").rglob("*.lean"):
35+
code = None
36+
with open(entry, 'r') as reader:
37+
code = reader.read()
38+
entry = str(entry)
39+
file = "/".join(entry.split("/")[1:])
40+
project_files[entry] = {
41+
"prs" : [] if file not in file_touched_pr else file_touched_pr[file],
42+
"num_sorries" : code.count("sorry"),
43+
"depends" : "import PersistentDecomp" in code
44+
}
45+
print(project_files)
46+
47+
with open("./website/_includes/ready_to_upstream.md", 'w+') as writer:
48+
text = ""
49+
for file_path in project_files:
50+
if project_files[file_path]["num_sorries"] > 0: continue
51+
if project_files[file_path]["depends"]: continue
52+
module_name = file_path.replace('/','.')[:-5]
53+
text += f"* [`{module_name}`](https://github.com/Paul-Lez/PersistentDecomp/blob/master/{file_path}) \n"
54+
for pr in project_files[file_path]["prs"]:
55+
if pr["title"][:4] == "perf": continue
56+
if pr["is_draft"]: continue
57+
58+
print(pr)
59+
text += f" * "
60+
text += f" ["
61+
text += '<svg class="octicon octicon-git-pull-request open color-fg-open mr-1" title="Open" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="M1.5 3.25a2.25 2.25 0 1 1 3 2.122v5.256a2.251 2.251 0 1 1-1.5 0V5.372A2.25 2.25 0 0 1 1.5 3.25Zm5.677-.177L9.573.677A.25.25 0 0 1 10 .854V2.5h1A2.5 2.5 0 0 1 13.5 5v5.628a2.251 2.251 0 1 1-1.5 0V5a1 1 0 0 0-1-1h-1v1.646a.25.25 0 0 1-.427.177L7.177 3.427a.25.25 0 0 1 0-.354ZM3.75 2.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm0 9.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm8.25.75a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0Z"></path></svg>'
62+
text += f" {pr['title']} #{pr['number']}](https://github.com/leanprover-community/mathlib4/pull/{pr['number']})"
63+
64+
text +="\n"
65+
writer.write(text)
66+
67+
with open("./website/_includes/easy_to_unlock.md", 'w+') as writer:
68+
text = ""
69+
for file_path in project_files:
70+
if project_files[file_path]["num_sorries"] == 0: continue
71+
if project_files[file_path]["depends"]: continue
72+
num_sorries = project_files[file_path]["num_sorries"]
73+
module_name = file_path.replace('/','.')[:-5]
74+
if num_sorries == 1:
75+
text += f"* [`{module_name}`](https://github.com/Paul-Lez/PersistentDecomp/blob/master/{file_path}) {num_sorries} sorry\n"
76+
else:
77+
text += f"* [`{module_name}`](https://github.com/Paul-Lez/PersistentDecomp/blob/master/{file_path}) {num_sorries} sorries\n"
78+
79+
writer.write(text)
80+
81+
main()

0 commit comments

Comments
 (0)