Skip to content

Commit 1db350c

Browse files
Create summarize_applications.py
1 parent efb5eff commit 1db350c

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import os
2+
from github import Github
3+
import re
4+
5+
# Get token and repo name from environment variables
6+
GITHUB_TOKEN = os.getenv("GITHUB_TOKEN")
7+
GITHUB_REPOSITORY = os.getenv("GITHUB_REPOSITORY") # Example: 'pytorch-fdn/foundation-programs'
8+
9+
# Authenticate with GitHub
10+
g = Github(GITHUB_TOKEN)
11+
repo = g.get_repo(GITHUB_REPOSITORY)
12+
13+
# Fetch issues with 'ambassador' label
14+
issues = repo.get_issues(state='all', labels=['ambassador'])
15+
16+
# Prepare summary content
17+
summary_lines = []
18+
summary_lines.append("# PyTorch Ambassador Applications Summary\n\n")
19+
summary_lines.append(f"**Total Applications**: {issues.totalCount}\n\n")
20+
summary_lines.append("| Issue # | Nominee Name | Email | Organization | Location |\n")
21+
summary_lines.append("|--------|--------------|------|--------------|----------|\n")
22+
23+
for issue in issues:
24+
body = issue.body
25+
26+
# Helper to extract values
27+
def extract(label):
28+
match = re.search(rf"{label}\s*\n\s*(.+)", body)
29+
return match.group(1).strip() if match else "Not Provided"
30+
31+
name = extract("Nominee Name")
32+
email = extract("Nominee Email")
33+
org = extract("Organization / Affiliation")
34+
location = extract("City, State/Province, Country")
35+
36+
summary_lines.append(f"| {issue.number} | {name} | {email} | {org} | {location} |\n")
37+
38+
# Write summary to SUMMARY.md
39+
output_file = "SUMMARY.md"
40+
with open(output_file, "w") as f:
41+
f.writelines(summary_lines)
42+
43+
print(f"Summary written to {output_file}")

0 commit comments

Comments
 (0)