Skip to content

Commit 613de3e

Browse files
ydshiehLysandreJik
authored andcommitted
Fix ci_url might be None (huggingface#17332)
* fix * Update utils/notification_service.py Co-authored-by: Lysandre Debut <[email protected]> Co-authored-by: ydshieh <[email protected]> Co-authored-by: Lysandre Debut <[email protected]>
1 parent e177be3 commit 613de3e

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

utils/notification_service.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -741,15 +741,16 @@ def add_path(self, path: str, gpu: str = None):
741741
ci_title = os.environ.get("CI_TITLE")
742742
ci_url = os.environ.get("CI_COMMIT_URL")
743743

744-
commit_number = ci_url.split("/")[-1]
745-
ci_detail_url = f"https://api.github.com/repos/huggingface/transformers/commits/{commit_number}"
746-
ci_details = requests.get(ci_detail_url).json()
747-
ci_author = ci_details["author"]["login"]
748-
749744
if ci_title is not None:
750745
assert ci_url is not None
751746
ci_title = ci_title.strip().split("\n")[0].strip()
752747

748+
# Retrieve the PR title and author login to complete the report
749+
commit_number = ci_url.split("/")[-1]
750+
ci_detail_url = f"https://api.github.com/repos/huggingface/transformers/commits/{commit_number}"
751+
ci_details = requests.get(ci_detail_url).json()
752+
ci_author = ci_details["author"]["login"]
753+
753754
merged_by = None
754755
# Find the PR number (if any) and change the url to the actual PR page.
755756
numbers = pr_number_re.findall(ci_title)

0 commit comments

Comments
 (0)