Skip to content

Commit dd9fe34

Browse files
committed
Git rebase on torch main
1 parent 1440c88 commit dd9fe34

File tree

2 files changed

+25
-9
lines changed

2 files changed

+25
-9
lines changed

.github/scripts/check_labels.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,18 @@ def main() -> None:
5151

5252
try:
5353
if not has_required_labels(pr):
54-
print(LABEL_ERR_MSG)
54+
print(LABEL_ERR_MSG, flush=True)
5555
add_label_err_comment(pr)
5656
if args.exit_non_zero:
57-
sys.exit(1)
57+
raise RuntimeError("PR does not have required labels")
5858
else:
5959
print("pass")
6060
delete_all_label_err_comments(pr)
6161
except Exception as e:
6262
print("general exception")
6363
print(e)
6464
if args.exit_non_zero:
65-
sys.exit(1)
65+
raise RuntimeError(f"Error checking labels: {e}") from e
6666

6767
print("success")
6868
sys.exit(0)

.github/scripts/github_utils.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,29 @@ def gh_fetch_url_and_headers(
6666
raise
6767

6868

69+
# def gh_fetch_url(
70+
# url: str,
71+
# *,
72+
# headers: Optional[Dict[str, str]] = None,
73+
# data: Union[Optional[Dict[str, Any]], str] = None,
74+
# method: Optional[str] = None,
75+
# reader: Callable[[Any], Any] = lambda x: x.read(),
76+
# ) -> Any:
77+
# print(f"api return conent: {gh_fetch_url_and_headers(url, headers=headers, data=data, reader=json.load, method=method)}")
78+
# return gh_fetch_url_and_headers(
79+
# url, headers=headers, data=data, reader=json.load, method=method
80+
# )[1]
81+
6982
def gh_fetch_url(
7083
url: str,
7184
*,
7285
headers: Optional[Dict[str, str]] = None,
7386
data: Union[Optional[Dict[str, Any]], str] = None,
7487
method: Optional[str] = None,
75-
reader: Callable[[Any], Any] = lambda x: x.read(),
88+
reader: Callable[[Any], Any] = json.load,
7689
) -> Any:
77-
print(f"api return conent: {gh_fetch_url_and_headers(url, headers=headers, data=data, reader=json.load, method=method)}")
7890
return gh_fetch_url_and_headers(
79-
url, headers=headers, data=data, reader=json.load, method=method
91+
url, headers=headers, data=data, reader=reader, method=method
8092
)[1]
8193

8294

@@ -168,11 +180,15 @@ def gh_post_commit_comment(
168180
)
169181

170182

183+
# def gh_delete_comment(org: str, repo: str, comment_id: int) -> None:
184+
# print("deleting comment")
185+
# url = f"{GITHUB_API_URL}/repos/{org}/{repo}/issues/comments/{comment_id}"
186+
# print(f"url: {url}")
187+
# gh_fetch_url(url, method="DELETE")
188+
171189
def gh_delete_comment(org: str, repo: str, comment_id: int) -> None:
172-
print("deleting comment")
173190
url = f"{GITHUB_API_URL}/repos/{org}/{repo}/issues/comments/{comment_id}"
174-
print(f"url: {url}")
175-
gh_fetch_url(url, method="DELETE")
191+
gh_fetch_url(url, method="DELETE", reader=lambda x: x.read())
176192

177193

178194
def gh_fetch_merge_base(org: str, repo: str, base: str, head: str) -> str:

0 commit comments

Comments
 (0)