Some checks failed
Self-hosted runner (nightly-past-ci-caller) / Get number (push) Has been cancelled
Self-hosted runner (nightly-past-ci-caller) / TensorFlow 2.11 (push) Has been cancelled
Self-hosted runner (nightly-past-ci-caller) / TensorFlow 2.10 (push) Has been cancelled
Self-hosted runner (nightly-past-ci-caller) / TensorFlow 2.9 (push) Has been cancelled
Self-hosted runner (nightly-past-ci-caller) / TensorFlow 2.8 (push) Has been cancelled
Self-hosted runner (nightly-past-ci-caller) / TensorFlow 2.7 (push) Has been cancelled
Self-hosted runner (nightly-past-ci-caller) / TensorFlow 2.6 (push) Has been cancelled
Self-hosted runner (nightly-past-ci-caller) / TensorFlow 2.5 (push) Has been cancelled
Self-hosted runner (benchmark) / Benchmark (aws-g5-4xlarge-cache) (push) Has been cancelled
Build documentation / build (push) Has been cancelled
Build documentation / build_other_lang (push) Has been cancelled
CodeQL Security Analysis / CodeQL Analysis (push) Has been cancelled
New model PR merged notification / Notify new model (push) Has been cancelled
PR CI / pr-ci (push) Has been cancelled
Slow tests on important models (on Push - A10) / Get all modified files (push) Has been cancelled
Secret Leaks / trufflehog (push) Has been cancelled
Update Transformers metadata / build_and_package (push) Has been cancelled
Slow tests on important models (on Push - A10) / Model CI (push) Has been cancelled
Check Tiny Models / Check tiny models (push) Has been cancelled
Self-hosted runner (Intel Gaudi3 scheduled CI caller) / Model CI (push) Has been cancelled
Self-hosted runner (Intel Gaudi3 scheduled CI caller) / Pipeline CI (push) Has been cancelled
Self-hosted runner (Intel Gaudi3 scheduled CI caller) / Example CI (push) Has been cancelled
Self-hosted runner (Intel Gaudi3 scheduled CI caller) / DeepSpeed CI (push) Has been cancelled
Self-hosted runner (Intel Gaudi3 scheduled CI caller) / Trainer/FSDP CI (push) Has been cancelled
Nvidia CI - Flash Attn / Setup (push) Has been cancelled
Nvidia CI - Flash Attn / Model CI (push) Has been cancelled
Nvidia CI / Setup (push) Has been cancelled
Nvidia CI / Model CI (push) Has been cancelled
Nvidia CI / Torch pipeline CI (push) Has been cancelled
Nvidia CI / Example CI (push) Has been cancelled
Nvidia CI / Trainer/FSDP CI (push) Has been cancelled
Nvidia CI / DeepSpeed CI (push) Has been cancelled
Nvidia CI / Quantization CI (push) Has been cancelled
Nvidia CI / Kernels CI (push) Has been cancelled
Doctests / Setup (push) Has been cancelled
Doctests / Call doctest jobs (push) Has been cancelled
Doctests / Send results to webhook (push) Has been cancelled
Extras Smoke Test / Get supported Python versions (push) Has been cancelled
Extras Smoke Test / Test extras on Python ${{ matrix.python-version }} (push) Has been cancelled
Extras Smoke Test / Check Slack token availability (push) Has been cancelled
Extras Smoke Test / Notify failures to Slack (push) Has been cancelled
Self-hosted runner (AMD scheduled CI caller) / Trigger Scheduled AMD CI (push) Has been cancelled
Stale Bot / Close Stale Issues (push) Has been cancelled
72 lines
2.1 KiB
Python
72 lines
2.1 KiB
Python
import argparse
|
|
import math
|
|
import traceback
|
|
|
|
import dateutil.parser as date_parser
|
|
import requests
|
|
|
|
|
|
def extract_time_from_single_job(job):
|
|
"""Extract time info from a single job in a GitHub Actions workflow run"""
|
|
|
|
job_info = {}
|
|
|
|
start = job["started_at"]
|
|
end = job["completed_at"]
|
|
|
|
start_datetime = date_parser.parse(start)
|
|
end_datetime = date_parser.parse(end)
|
|
|
|
duration_in_min = round((end_datetime - start_datetime).total_seconds() / 60.0)
|
|
|
|
job_info["started_at"] = start
|
|
job_info["completed_at"] = end
|
|
job_info["duration"] = duration_in_min
|
|
|
|
return job_info
|
|
|
|
|
|
def get_job_time(workflow_run_id, token=None):
|
|
"""Extract time info for all jobs in a GitHub Actions workflow run"""
|
|
|
|
headers = None
|
|
if token is not None:
|
|
headers = {"Accept": "application/vnd.github+json", "Authorization": f"Bearer {token}"}
|
|
|
|
url = f"https://api.github.com/repos/huggingface/transformers/actions/runs/{workflow_run_id}/jobs?per_page=100"
|
|
result = requests.get(url, headers=headers).json()
|
|
job_time = {}
|
|
|
|
try:
|
|
job_time.update({job["name"]: extract_time_from_single_job(job) for job in result["jobs"]})
|
|
pages_to_iterate_over = math.ceil((result["total_count"] - 100) / 100)
|
|
|
|
for i in range(pages_to_iterate_over):
|
|
result = requests.get(url + f"&page={i + 2}", headers=headers).json()
|
|
job_time.update({job["name"]: extract_time_from_single_job(job) for job in result["jobs"]})
|
|
|
|
return job_time
|
|
except Exception:
|
|
print(f"Unknown error, could not fetch links:\n{traceback.format_exc()}")
|
|
|
|
return {}
|
|
|
|
|
|
if __name__ == "__main__":
|
|
r"""
|
|
Example:
|
|
|
|
python get_github_job_time.py --workflow_run_id 2945609517
|
|
"""
|
|
|
|
parser = argparse.ArgumentParser()
|
|
# Required parameters
|
|
parser.add_argument("--workflow_run_id", type=str, required=True, help="A GitHub Actions workflow run id.")
|
|
args = parser.parse_args()
|
|
|
|
job_time = get_job_time(args.workflow_run_id)
|
|
job_time = dict(sorted(job_time.items(), key=lambda item: item[1]["duration"], reverse=True))
|
|
|
|
for k, v in job_time.items():
|
|
print(f"{k}: {v['duration']}")
|