Commit
·
b8f978e
1
Parent(s):
3bbc731
Configurable
Browse files- app.py +76 -13
- graphql_calls.py +28 -3
app.py
CHANGED
@@ -1,37 +1,100 @@
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
from graphql_calls import get_tag_commit_date, get_commits
|
3 |
|
4 |
|
5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
date = get_tag_commit_date(token, repo, tag)
|
7 |
commits = get_commits(token, repo, date)
|
8 |
|
9 |
-
result =
|
|
|
10 |
|
11 |
for commit in commits:
|
12 |
-
if
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
message = split[0]
|
15 |
-
number = split[1].strip(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
20 |
|
21 |
return result
|
22 |
|
23 |
|
24 |
demo = gr.Interface(
|
25 |
-
fn=
|
26 |
inputs=[
|
27 |
gr.inputs.Textbox(lines=1, placeholder="Your GitHub token"),
|
28 |
-
gr.inputs.Textbox(
|
|
|
|
|
29 |
gr.inputs.Textbox(lines=1, placeholder="The tag from which to get commit"),
|
30 |
-
gr.inputs.Textbox(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
],
|
32 |
-
outputs=
|
33 |
)
|
34 |
|
35 |
|
36 |
if __name__ == "__main__":
|
37 |
-
demo.launch()
|
|
|
1 |
+
from dataclasses import dataclass
|
2 |
+
|
3 |
import gradio as gr
|
4 |
from graphql_calls import get_tag_commit_date, get_commits
|
5 |
|
6 |
|
7 |
+
@dataclass
|
8 |
+
class Contributions:
|
9 |
+
additions: int
|
10 |
+
deletions: int
|
11 |
+
descriptions: list[str]
|
12 |
+
|
13 |
+
|
14 |
+
def get_release_notes(
|
15 |
+
token: str,
|
16 |
+
repo: str,
|
17 |
+
tag: str,
|
18 |
+
branch: str,
|
19 |
+
contributor_treshold: int,
|
20 |
+
ignore_dependabot: bool,
|
21 |
+
ignore_direct: bool,
|
22 |
+
):
|
23 |
date = get_tag_commit_date(token, repo, tag)
|
24 |
commits = get_commits(token, repo, date)
|
25 |
|
26 |
+
result = ""
|
27 |
+
contributors = {}
|
28 |
|
29 |
for commit in commits:
|
30 |
+
if "Hugging Face" not in commit.user.organizations:
|
31 |
+
if commit.user.name not in contributors:
|
32 |
+
contributors[commit.user.name] = Contributions(
|
33 |
+
additions=commit.additions,
|
34 |
+
deletions=commit.deletions,
|
35 |
+
descriptions=[commit.message],
|
36 |
+
)
|
37 |
+
else:
|
38 |
+
contributors[commit.user.name].additions += commit.additions
|
39 |
+
contributors[commit.user.name].deletions += commit.deletions
|
40 |
+
contributors[commit.user.name].descriptions += [commit.message]
|
41 |
+
|
42 |
+
if "(#" in commit.message:
|
43 |
+
if ignore_dependabot and commit.user.name == 'dependabot[bot]':
|
44 |
+
continue
|
45 |
+
|
46 |
+
split = commit.message.split("(#")
|
47 |
message = split[0]
|
48 |
+
number = split[1].strip(")")
|
49 |
+
|
50 |
+
result += f"* {message} by @{commit.user.name} in #{number}\n"
|
51 |
+
elif not ignore_direct:
|
52 |
+
result += f"* {commit.message} by @{commit.user.name} (direct commit on {branch})\n"
|
53 |
+
|
54 |
+
significant_contributors = {
|
55 |
+
k: v for k, v in contributors.items() if (v.additions + v.deletions) > contributor_treshold
|
56 |
+
}
|
57 |
+
|
58 |
+
if len(significant_contributors):
|
59 |
+
result += (
|
60 |
+
"\n## Significant community contributions\n"
|
61 |
+
"\nThe following contributors have made significant "
|
62 |
+
"changes to the library over the last release:\n\n"
|
63 |
+
)
|
64 |
|
65 |
+
for significant_contributor, contributions in significant_contributors.items():
|
66 |
+
result += f"* @{significant_contributor}\n"
|
67 |
+
for description in contributions.descriptions:
|
68 |
+
result += f" * {description}\n"
|
69 |
|
70 |
return result
|
71 |
|
72 |
|
73 |
demo = gr.Interface(
|
74 |
+
fn=get_release_notes,
|
75 |
inputs=[
|
76 |
gr.inputs.Textbox(lines=1, placeholder="Your GitHub token"),
|
77 |
+
gr.inputs.Textbox(
|
78 |
+
lines=1, placeholder="Repository", default="huggingface/transformers"
|
79 |
+
),
|
80 |
gr.inputs.Textbox(lines=1, placeholder="The tag from which to get commit"),
|
81 |
+
gr.inputs.Textbox(
|
82 |
+
lines=1,
|
83 |
+
placeholder="The linear branch on which the new version tag will be added",
|
84 |
+
default="main",
|
85 |
+
),
|
86 |
+
gr.inputs.Slider(
|
87 |
+
minimum=0,
|
88 |
+
maximum=2000,
|
89 |
+
default=500,
|
90 |
+
label="Threshold for significant contributors",
|
91 |
+
),
|
92 |
+
gr.inputs.Checkbox(label="Ignore dependabot commits"),
|
93 |
+
gr.inputs.Checkbox(label="Ignore direct commits"),
|
94 |
],
|
95 |
+
outputs="text",
|
96 |
)
|
97 |
|
98 |
|
99 |
if __name__ == "__main__":
|
100 |
+
demo.launch()
|
graphql_calls.py
CHANGED
@@ -3,10 +3,18 @@ from dataclasses import dataclass
|
|
3 |
import requests
|
4 |
|
5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
@dataclass
|
7 |
class Commit:
|
8 |
message: str
|
9 |
-
user:
|
|
|
|
|
10 |
|
11 |
|
12 |
def call_with_query(query, token):
|
@@ -52,9 +60,16 @@ def get_commits(token, repository, since):
|
|
52 |
history(first: 100, since: "{since}"{next_page}) {{
|
53 |
nodes {{
|
54 |
message
|
|
|
|
|
55 |
author {{
|
56 |
user {{
|
57 |
login
|
|
|
|
|
|
|
|
|
|
|
58 |
}}
|
59 |
}}
|
60 |
}}
|
@@ -83,8 +98,18 @@ def get_commits(token, repository, since):
|
|
83 |
commits = []
|
84 |
for node in nodes:
|
85 |
if node['author']['user'] is None:
|
86 |
-
commits.append(Commit(
|
|
|
|
|
|
|
|
|
|
|
87 |
else:
|
88 |
-
commits.append(Commit(
|
|
|
|
|
|
|
|
|
|
|
89 |
|
90 |
return commits
|
|
|
3 |
import requests
|
4 |
|
5 |
|
6 |
+
@dataclass
|
7 |
+
class User:
|
8 |
+
name: str
|
9 |
+
organizations: list[str]
|
10 |
+
|
11 |
+
|
12 |
@dataclass
|
13 |
class Commit:
|
14 |
message: str
|
15 |
+
user: User
|
16 |
+
additions: int
|
17 |
+
deletions: int
|
18 |
|
19 |
|
20 |
def call_with_query(query, token):
|
|
|
60 |
history(first: 100, since: "{since}"{next_page}) {{
|
61 |
nodes {{
|
62 |
message
|
63 |
+
deletions
|
64 |
+
additions
|
65 |
author {{
|
66 |
user {{
|
67 |
login
|
68 |
+
organizations(first: 100) {{
|
69 |
+
nodes {{
|
70 |
+
name
|
71 |
+
}}
|
72 |
+
}}
|
73 |
}}
|
74 |
}}
|
75 |
}}
|
|
|
98 |
commits = []
|
99 |
for node in nodes:
|
100 |
if node['author']['user'] is None:
|
101 |
+
commits.append(Commit(
|
102 |
+
message=node['message'].split('\n')[0],
|
103 |
+
user=User(name='<NOT FOUND>', organizations=[]),
|
104 |
+
additions=node.get('additions'),
|
105 |
+
deletions=node.get('deletions')
|
106 |
+
))
|
107 |
else:
|
108 |
+
commits.append(Commit(
|
109 |
+
message=node['message'].split('\n')[0],
|
110 |
+
user=User(name=node['author']['user']['login'], organizations=[n['name'] for n in node['author']['user']['organizations']['nodes']]),
|
111 |
+
additions=node.get('additions'),
|
112 |
+
deletions=node.get('deletions')
|
113 |
+
))
|
114 |
|
115 |
return commits
|