Skip to content

Commit f477fd5

Browse files
authored
Label checker fix (#6953)
* Label checker fix * Try on this pr * See what's up with topic not user facing * Git rebase on torch main * only main * back * Remove all print statements
1 parent eae0b04 commit f477fd5

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

.github/scripts/check_labels.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ def main() -> None:
4545

4646
try:
4747
if not has_required_labels(pr):
48-
print(LABEL_ERR_MSG)
48+
print(LABEL_ERR_MSG, flush=True)
4949
add_label_err_comment(pr)
5050
if args.exit_non_zero:
51-
sys.exit(1)
51+
raise RuntimeError("PR does not have required labels")
5252
else:
5353
delete_all_label_err_comments(pr)
5454
except Exception as e:
5555
if args.exit_non_zero:
56-
sys.exit(1)
56+
raise RuntimeError(f"Error checking labels: {e}") from e
5757

5858
sys.exit(0)
5959

.github/scripts/github_utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ def gh_fetch_url(
7272
headers: Optional[Dict[str, str]] = None,
7373
data: Union[Optional[Dict[str, Any]], str] = None,
7474
method: Optional[str] = None,
75-
reader: Callable[[Any], Any] = lambda x: x.read(),
75+
reader: Callable[[Any], Any] = json.load,
7676
) -> Any:
7777
return gh_fetch_url_and_headers(
78-
url, headers=headers, data=data, reader=json.load, method=method
78+
url, headers=headers, data=data, reader=reader, method=method
7979
)[1]
8080

8181

@@ -169,7 +169,7 @@ def gh_post_commit_comment(
169169

170170
def gh_delete_comment(org: str, repo: str, comment_id: int) -> None:
171171
url = f"{GITHUB_API_URL}/repos/{org}/{repo}/issues/comments/{comment_id}"
172-
gh_fetch_url(url, method="DELETE")
172+
gh_fetch_url(url, method="DELETE", reader=lambda x: x.read())
173173

174174

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

0 commit comments

Comments
 (0)