mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 12:20:52 +01:00
[CI] Reuse old whl: track why failed to use the old whl (#155860)
As in title Any other things I should track? Pull Request resolved: https://github.com/pytorch/pytorch/pull/155860 Approved by: https://github.com/malfet
This commit is contained in:
parent
3596c0c77f
commit
d59ed21d0f
9
.github/actions/reuse-old-whl/action.yml
vendored
9
.github/actions/reuse-old-whl/action.yml
vendored
|
|
@ -13,6 +13,12 @@ inputs:
|
|||
github-token:
|
||||
description: GitHub token
|
||||
required: true
|
||||
job-id:
|
||||
description: Job ID
|
||||
required: true
|
||||
job-name:
|
||||
description: Job name
|
||||
required: true
|
||||
|
||||
outputs:
|
||||
reuse:
|
||||
|
|
@ -30,8 +36,11 @@ runs:
|
|||
continue-on-error: true
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ inputs.github-token }}
|
||||
JOB_ID: ${{ inputs.job-id }}
|
||||
JOB_NAME: ${{ inputs.job-name }}
|
||||
run: |
|
||||
set -x
|
||||
python3 -m pip install boto3==1.35.42
|
||||
python3 ${GITHUB_ACTION_PATH}/reuse_old_whl.py \
|
||||
--build-environment "${{ inputs.build-environment }}" \
|
||||
--run-id "${{ inputs.run-id }}" \
|
||||
|
|
|
|||
40
.github/actions/reuse-old-whl/reuse_old_whl.py
vendored
40
.github/actions/reuse-old-whl/reuse_old_whl.py
vendored
|
|
@ -1,6 +1,7 @@
|
|||
import argparse
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
from functools import lru_cache
|
||||
from pathlib import Path
|
||||
from typing import Any, cast, Optional, Union
|
||||
|
|
@ -8,6 +9,14 @@ from typing import Any, cast, Optional, Union
|
|||
import requests
|
||||
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parent.parent.parent.parent
|
||||
sys.path.insert(0, str(REPO_ROOT))
|
||||
from tools.stats.upload_metrics import emit_metric
|
||||
|
||||
|
||||
sys.path.remove(str(REPO_ROOT)) # Clean up sys.path after import
|
||||
|
||||
|
||||
FORCE_REBUILD_LABEL = "ci-force-rebuild"
|
||||
|
||||
|
||||
|
|
@ -308,7 +317,7 @@ def parse_args() -> argparse.Namespace:
|
|||
return parser.parse_args()
|
||||
|
||||
|
||||
def can_reuse_whl(args: argparse.Namespace) -> bool:
|
||||
def can_reuse_whl(args: argparse.Namespace) -> tuple[bool, str]:
|
||||
if args.github_ref and any(
|
||||
args.github_ref.startswith(x)
|
||||
for x in [
|
||||
|
|
@ -318,37 +327,50 @@ def can_reuse_whl(args: argparse.Namespace) -> bool:
|
|||
]
|
||||
):
|
||||
print("Release branch, rebuild whl")
|
||||
return False
|
||||
return (False, "Release branch")
|
||||
|
||||
if not check_changed_files(get_merge_base()):
|
||||
print("Cannot use old whl due to the changed files, rebuild whl")
|
||||
return False
|
||||
return (False, "Changed files not allowed")
|
||||
|
||||
if check_labels_for_pr():
|
||||
print(f"Found {FORCE_REBUILD_LABEL} label on PR, rebuild whl")
|
||||
return False
|
||||
return (False, "Found FORCE_REBUILD_LABEL on PR")
|
||||
|
||||
if check_issue_open():
|
||||
print("Issue #153759 is open, rebuild whl")
|
||||
return False
|
||||
return (False, "Issue #153759 is open")
|
||||
|
||||
workflow_id = get_workflow_id(args.run_id)
|
||||
if workflow_id is None:
|
||||
print("No workflow ID found, rebuild whl")
|
||||
return False
|
||||
return (False, "No workflow ID found")
|
||||
|
||||
if not find_old_whl(workflow_id, args.build_environment, get_merge_base()):
|
||||
print("No old whl found, rebuild whl")
|
||||
return (False, "No old whl found")
|
||||
# TODO: go backwards from merge base to find more runs
|
||||
return False
|
||||
|
||||
return True
|
||||
return (True, "Found old whl")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
args = parse_args()
|
||||
|
||||
if can_reuse_whl(args):
|
||||
reuse_whl, reason = can_reuse_whl(args)
|
||||
|
||||
if reuse_whl:
|
||||
print("Reusing old whl")
|
||||
unzip_artifact_and_replace_files()
|
||||
set_output()
|
||||
|
||||
emit_metric(
|
||||
"reuse_old_whl",
|
||||
{
|
||||
"reuse_whl": reuse_whl,
|
||||
"reason": reason,
|
||||
"build_environment": args.build_environment,
|
||||
"merge_base": get_merge_base(),
|
||||
"head_sha": get_head_sha(),
|
||||
},
|
||||
)
|
||||
|
|
|
|||
16
.github/workflows/_linux-build.yml
vendored
16
.github/workflows/_linux-build.yml
vendored
|
|
@ -158,6 +158,13 @@ jobs:
|
|||
role-session-name: gha-linux-build
|
||||
aws-region: us-east-1
|
||||
|
||||
- name: Get workflow job id
|
||||
id: get-job-id
|
||||
uses: ./.github/actions/get-workflow-job-id
|
||||
if: always()
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Check if can use old whl build
|
||||
id: use-old-whl
|
||||
uses: ./.github/actions/reuse-old-whl
|
||||
|
|
@ -166,6 +173,8 @@ jobs:
|
|||
build-environment: ${{ inputs.build-environment }}
|
||||
run-id: ${{ github.run_id }}
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
job-id: ${{ steps.get-job-id.outputs.job-id }}
|
||||
job-name: ${{ steps.get-job-id.outputs.job-name }}
|
||||
|
||||
- name: Calculate docker image
|
||||
id: calculate-docker-image
|
||||
|
|
@ -194,13 +203,6 @@ jobs:
|
|||
id: parse-ref
|
||||
run: .github/scripts/parse_ref.py
|
||||
|
||||
- name: Get workflow job id
|
||||
id: get-job-id
|
||||
uses: ./.github/actions/get-workflow-job-id
|
||||
if: always()
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
# Apply the filter logic to the build step too if the test-config label is already there
|
||||
- name: Select all requested test configurations (if the test matrix is available)
|
||||
id: filter
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user