From 1b20c970a204c85dfa7bc61837c9462f240a5746 Mon Sep 17 00:00:00 2001 From: Yih-Dar <2521628+ydshieh@users.noreply.github.com> Date: Wed, 18 May 2022 21:49:08 +0200 Subject: [PATCH] Fix ci_url might be None (#17332) * fix * Update utils/notification_service.py Co-authored-by: Lysandre Debut Co-authored-by: ydshieh Co-authored-by: Lysandre Debut --- utils/notification_service.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/utils/notification_service.py b/utils/notification_service.py index 8cede02145..12fb6c0656 100644 --- a/utils/notification_service.py +++ b/utils/notification_service.py @@ -741,15 +741,16 @@ if __name__ == "__main__": ci_title = os.environ.get("CI_TITLE") ci_url = os.environ.get("CI_COMMIT_URL") - commit_number = ci_url.split("/")[-1] - ci_detail_url = f"https://api.github.com/repos/huggingface/transformers/commits/{commit_number}" - ci_details = requests.get(ci_detail_url).json() - ci_author = ci_details["author"]["login"] - if ci_title is not None: assert ci_url is not None ci_title = ci_title.strip().split("\n")[0].strip() + # Retrieve the PR title and author login to complete the report + commit_number = ci_url.split("/")[-1] + ci_detail_url = f"https://api.github.com/repos/huggingface/transformers/commits/{commit_number}" + ci_details = requests.get(ci_detail_url).json() + ci_author = ci_details["author"]["login"] + merged_by = None # Find the PR number (if any) and change the url to the actual PR page. numbers = pr_number_re.findall(ci_title)