Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pr metrics improvements #102

Open
wants to merge 8 commits into
base: dev/mpg/pr-metrics
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pr-metrics/get-pr-data.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

prs = list()
for p in r.get_pulls(state="all"):
if p.draft:
continue
print(p.number)
# Accessing p.mergeable forces completion of PR data (by default, only
# basic info such as status and dates is available) but makes things
Expand Down
51 changes: 24 additions & 27 deletions pr-metrics/pr-backlog.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@

import matplotlib.pyplot as plt

new_days = 90
old_days = 365
# Group PRs by age, according to these thresholds
thresholds = [15, 90, 180, 365, 365 * 1000]

new = Counter()
med = Counter()
old = Counter()
counters = {t: Counter() for t in thresholds}

for beg, end, com in pr_dates():
if end is None:
Expand All @@ -30,43 +28,42 @@
# Only count on each quarter's last day
if q == q1:
continue
if i <= new_days:
new[q] += 1
elif i <= old_days:
med[q] += 1
else:
old[q] += 1
for t in thresholds:
if i <= t:
counters[t][q] += 1
break

first_q = quarter(first)
last_q = quarter(last)

quarters = (q for q in chain(new, med, old) if first_q <= q <= last_q)
quarters = (q for q in chain(*counters.values()) if first_q <= q <= last_q)
quarters = tuple(sorted(set(quarters)))

new_y = tuple(new[q] for q in quarters)
med_y = tuple(med[q] for q in quarters)
old_y = tuple(old[q] for q in quarters)
sum_y = tuple(old[q] + med[q] for q in quarters)
buckets_y = {t: tuple(counters[t][q] for q in quarters) for t in thresholds}

old_name = "older than {} days".format(old_days)
med_name = "medium"
new_name = "recent (less {} days old)".format(new_days)
names = {t: None} #f"<= {t} days" for t in thresholds}
names[thresholds[0]] = f"<= {thresholds[0]} days"
for i in range(1, len(thresholds)):
names[thresholds[i]] = f"{thresholds[i-1] + 1}..{thresholds[i]} days"
names[thresholds[-1]] = f"> {thresholds[-2]} days"

width = 0.9
fig, ax = plt.subplots()
ax.bar(quarters, old_y, width, label=old_name)
ax.bar(quarters, med_y, width, label=med_name, bottom=old_y)
ax.bar(quarters, new_y, width, label=new_name, bottom=sum_y)
prev_tops=[0] * len(quarters)
for t in reversed(thresholds):
ax.bar(quarters, buckets_y[t], width, label=names[t], bottom=prev_tops)
prev_tops = [a + b for a,b in zip(prev_tops, buckets_y[t])]
ax.legend(loc="upper left")
ax.grid(True)
ax.set_xlabel("quarter")
ax.set_ylabel("Number or PRs pending")
#ax.set_xlabel("quarter")
ax.set_ylabel("Open PR count")
ax.tick_params(axis="x", labelrotation=90)
fig.suptitle("State of the PR backlog at the end of each quarter")
fig.suptitle("Open PR count, broken down by PR age")
fig.set_size_inches(12.8, 7.2) # default 100 dpi -> 720p
fig.savefig("prs-backlog.png")

print("Quarter,recent,medium,old,total")
for q in quarters:
print("{},{},{},{},{}".format(q, new[q], med[q], old[q],
new[q] + med[q] + old[q]))
s = ", ".join(str(counters[t][q]) for t in thresholds)
t = sum(counters[t][q] for t in thresholds)
print(f"{q}, {s}, {t}")
5 changes: 4 additions & 1 deletion pr-metrics/prs.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"dgreen-arm",
"gabor-mezei-arm",
"gilles-peskine-arm",
"gowthamsk-arm",
"hanno-arm",
"hanno-becker",
"jackbondpreston-arm",
Expand All @@ -55,12 +56,14 @@
"RcColes",
"ronald-cron-arm",
"RonEld",
"Ryan-Everett-arm",
"sbutcher-arm",
"shanechko",
"silabs-hannes",
"silabs-Kusumit",
"silabs-Saketh",
"superna9999",
"tgonzalezorlandoarm",
"tom-cosgrove-arm",
"tom-daubney-arm",
"tuvshinzayaArm",
Expand All @@ -86,7 +89,7 @@ def is_community(pr):
def quarter(date):
"""Return a string decribing this date's quarter, for example 19q3."""

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this comment should be changed now?

q = str(date.year % 100)
q += "q"
q += " Q"
q += str((date.month + 2) // 3)
return q

Expand Down
6 changes: 3 additions & 3 deletions resources/windows/windows_testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import shutil
import sys
import traceback
import glob


class VStestrun(object):
Expand Down Expand Up @@ -581,9 +582,8 @@ def test_visual_studio_built_code(self, test_run, solution_type):
git_worktree_path, test_run, vs_logger
)
else:
solution_dir = os.path.join(
git_worktree_path, "visualc", "VS2010"
)
solution_dir = glob.glob(os.path.join(
git_worktree_path, "visualc", "VS*"))[0]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just in case: we are not expecting it to have more than one VS* folder, right? Otherwise this would bring a problem I think

build_result = self.build_code_using_visual_studio(
solution_dir, test_run, solution_type, vs_logger, c89
)
Expand Down