classify_prs.py 1.85 KB
Newer Older
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
# In[1]:


import pandas as pd


# In[2]:


# from https://github.com/pytorch/audio/blob/main/.github/process_commit.py
primary_labels_mapping = {
    "BC-breaking": "Backward-incompatible changes",
    "deprecation": "Deprecations",
    "bug fix": "Bug Fixes",
    "new feature": "New Features",
    "improvement": "Improvements",
    "example": "Examples",
    "prototype": "Prototypes",
    "other": "Other",
    "None": "Missing",
}

secondary_labels_mapping = {
    "module: I/O": "I/O",
    "module: ops": "Ops",
    "module: models": "Models",
    "module: pipelines": "Pipelines",
    "module: datasets": "Datasets",
    "module: docs": "Documentation",
    "module: tests": "Tests",
    "build": "Build",
    "style": "Style",
    "perf": "Performance",
    "other": "Other",
    "None": "Missing",
}


# In[3]:


df = pd.read_json("data.json").T
df.tail()


# In[4]:


def get_labels(col_name, labels):
    df[col_name] = [[] for _ in range(len(df))]
51
    for _, row in df.iterrows():
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
        row[col_name] = "None"
        for label in labels:
            if label in row["labels"]:
                row[col_name] = label
                break


# In[5]:


get_labels("primary_label", primary_labels_mapping.keys())
get_labels("secondary_label", secondary_labels_mapping.keys())
df.tail(5)


# In[6]:


for primary_label in primary_labels_mapping.keys():
    primary_df = df[df["primary_label"] == primary_label]
    if primary_df.empty:
        continue
    print(f"## {primary_labels_mapping[primary_label]}")
    for secondary_label in secondary_labels_mapping.keys():
        secondary_df = primary_df[primary_df["secondary_label"] == secondary_label]
        if secondary_df.empty:
            continue
        print(f"### {secondary_labels_mapping[secondary_label]}")
80
        for _, row in secondary_df.iterrows():
81
82
83
            print(f"- {row['title']}")
        print()
    print()