Skip to content
Open
Show file tree
Hide file tree
Changes from 5 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
14 changes: 12 additions & 2 deletions pr-metrics/get-pr-data.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@

"""Get PR data from github and pickle it."""

import pickle
import os
import requests.exceptions
import time

from github import Github

Expand Down Expand Up @@ -38,4 +39,13 @@
p.update()

with open("pr-data.p", "wb") as f:
pickle.dump(prs, f)

Choose a reason for hiding this comment

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

I put this comment here as it does not let me put it in unchanged lines of code:
Nit: Maybe we can change r = g.get_repo("ARMMbed/mbedtls") from line 18 to r = g.get_repo("Mbed-TLS/mbedtls") ?

for i, p in enumerate(prs):
for retry in range(0, 9):
try:
g.dump(p, f)
break
except requests.exceptions.ReadTimeout:
delay = 2 ** retry
print(f"timeout; sleeping {delay} s and retrying...")
time.sleep(2 ** delay)
print(f"saved {i+1}/{len(prs)}")
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}")
13 changes: 9 additions & 4 deletions pr-metrics/prs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@

"""PR data an misc common functions."""

import pickle
import datetime
import os
from github import Github

prs = []
with open("pr-data.p", "rb") as f:
prs = pickle.load(f)

g = Github()
try:
while True:
prs.append(g.load(f))
except EOFError:
pass

# Current and past core contributors, alphabetical order (sort -f).
#
Expand Down Expand Up @@ -86,7 +91,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