[ez] Fix check labels error when deleting comment (#140578)

Re make of https://github.com/pytorch/pytorch/pull/140587
Pull Request resolved: https://github.com/pytorch/pytorch/pull/140578
Approved by: https://github.com/huydhn
This commit is contained in:
Catherine Lee
2024-11-13 23:00:58 +00:00
committed by PyTorch MergeBot
parent 274f4cfacb
commit 08acfcddc4
2 changed files with 6 additions and 6 deletions

View File

@ -45,15 +45,15 @@ def main() -> None:
try:
if not has_required_labels(pr):
print(LABEL_ERR_MSG)
print(LABEL_ERR_MSG, flush=True)
add_label_err_comment(pr)
if args.exit_non_zero:
sys.exit(1)
raise RuntimeError("PR does not have required labels")
else:
delete_all_label_err_comments(pr)
except Exception as e:
if args.exit_non_zero:
sys.exit(1)
raise RuntimeError(f"Error checking labels: {e}") from e
sys.exit(0)

View File

@ -73,10 +73,10 @@ def gh_fetch_url(
headers: Optional[Dict[str, str]] = None,
data: Union[Optional[Dict[str, Any]], str] = None,
method: Optional[str] = None,
reader: Callable[[Any], Any] = lambda x: x.read(),
reader: Callable[[Any], Any] = json.load,
) -> Any:
return gh_fetch_url_and_headers(
url, headers=headers, data=data, reader=json.load, method=method
url, headers=headers, data=data, reader=reader, method=method
)[1]
@ -178,7 +178,7 @@ def gh_close_pr(org: str, repo: str, pr_num: int, dry_run: bool = False) -> None
def gh_delete_comment(org: str, repo: str, comment_id: int) -> None:
url = f"{GITHUB_API_URL}/repos/{org}/{repo}/issues/comments/{comment_id}"
gh_fetch_url(url, method="DELETE")
gh_fetch_url(url, method="DELETE", reader=lambda x: x.read())
def gh_fetch_merge_base(org: str, repo: str, base: str, head: str) -> str: