MCPcopy Create free account
hub / github.com/apache/tvm / check_pr

Function check_pr

ci/scripts/github/ping_reviewers.py:103–174  ·  view source on GitHub ↗
(pr, wait_time, now)

Source from the content-addressed store, hash-verified

101
102
103def check_pr(pr, wait_time, now):
104 last_action = None
105
106 author = pr["author"]["login"]
107
108 def update_last(new_time, description):
109 if isinstance(new_time, str):
110 new_time = datetime.datetime.strptime(new_time, GIT_DATE_FORMAT)
111 if new_time is None:
112 print(f" time not found: {description}")
113 return
114 nonlocal last_action
115 if last_action is None or new_time > last_action[0]:
116 last_action = (new_time, description)
117
118 def check_obj(obj, name):
119 update_last(obj["publishedAt"], f"{name} publishedAt: {obj}")
120 update_last(obj["updatedAt"], f"{name} updatedAt: {obj}")
121 update_last(obj["lastEditedAt"], f"{name} lastEditedAt: {obj}")
122 update_last(obj["createdAt"], f"{name} lastEditedAt: {obj}")
123
124 check_obj(pr, "pr")
125
126 # GitHub counts comments left as part of a review separately than standalone
127 # comments
128 reviews = pr["reviews"]["nodes"]
129 review_comments = []
130 for review in reviews:
131 review_comments += review["comments"]["nodes"]
132 check_obj(review, "review")
133
134 # Collate all comments
135 comments = pr["comments"]["nodes"] + review_comments
136
137 # Find the last date of any comment
138 for comment in comments:
139 check_obj(comment, "comment")
140
141 time_since_last_action = now - last_action[0]
142
143 # Find reviewers in the PR's body
144 pr_body_reviewers = find_reviewers(pr["body"])
145
146 # Pull out reviewers from any cc @... text in a comment
147 cc_reviewers = [find_reviewers(c["bodyText"]) for c in comments]
148 cc_reviewers = [r for revs in cc_reviewers for r in revs]
149
150 # Anyone that has left a review as a reviewer (this may include the PR
151 # author since their responses count as reviews)
152 review_reviewers = list(set(r["author"]["login"] for r in reviews))
153
154 reviewers = cc_reviewers + review_reviewers + pr_body_reviewers
155 reviewers = list(set(reviewers))
156 reviewers = [r for r in reviewers if r != author]
157
158 if time_since_last_action > wait_time:
159 print(
160 " Pinging reviewers",

Callers 1

ping_reviewers.pyFile · 0.85

Calls 3

check_objFunction · 0.85
printFunction · 0.85
find_reviewersFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…