Add offline runners info in the Slack report (#19169)

* send slack report for offline runners

Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
This commit is contained in:
Yih-Dar
2022-09-23 19:23:05 +02:00
committed by GitHub
parent 49bf569830
commit 0cea8d5555
3 changed files with 34 additions and 3 deletions

View File

@@ -5,6 +5,8 @@ import subprocess
def get_runner_status(target_runners, token):
offline_runners = []
cmd = (
f'curl -H "Accept: application/vnd.github+json" -H "Authorization: Bearer {token}"'
" https://api.github.com/repos/huggingface/transformers/actions/runners"
@@ -17,7 +19,15 @@ def get_runner_status(target_runners, token):
for runner in runners:
if runner["name"] in target_runners:
if runner["status"] == "offline":
raise ValueError(f"{runner['name']} is offline!")
offline_runners.append(runner)
# save the result so we can report them on Slack
with open("offline_runners.txt", "w") as fp:
fp.write(json.dumps(offline_runners))
if len(offline_runners) > 0:
failed = "\n".join(offline_runners)
raise ValueError(f"The following runners are offline:\n{failed}")
if __name__ == "__main__":