Fix ci_url might be None (#17332)

* fix

* Update utils/notification_service.py

Co-authored-by: Lysandre Debut <lysandre.debut@reseau.eseo.fr>

Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
Co-authored-by: Lysandre Debut <lysandre.debut@reseau.eseo.fr>
This commit is contained in:
Yih-Dar 2022-05-18 21:49:08 +02:00 committed by GitHub
parent 6aad3872ce
commit 1b20c970a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)