Skip to content

Commit

Permalink
Set up automated hash pinning for triton (pytorch#97568)
Browse files Browse the repository at this point in the history
Fixes #ISSUE_NUMBER

Pull Request resolved: pytorch#97568
Approved by: https://github.com/huydhn, https://github.com/malfet
  • Loading branch information
clee2000 authored and pytorchmergebot committed Apr 8, 2023
1 parent f959a0d commit a6155f3
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 6 deletions.
5 changes: 3 additions & 2 deletions .github/scripts/update_commit_hashes.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def parse_args() -> Any:
parser = ArgumentParser("Rebase PR into branch")
parser.add_argument("--repo-name", type=str)
parser.add_argument("--branch", type=str)
parser.add_argument("--pin-folder", type=str)
return parser.parse_args()


Expand Down Expand Up @@ -135,7 +136,7 @@ def main() -> None:
.stdout.decode("utf-8")
.strip()
)
with open(f".github/ci_commit_pins/{args.repo_name}.txt", "r+") as f:
with open(f"{args.pin_folder}/{args.repo_name}.txt", "r+") as f:
old_hash = f.read().strip()
subprocess.run(f"git checkout {old_hash}".split(), cwd=args.repo_name)
f.seek(0)
Expand All @@ -144,7 +145,7 @@ def main() -> None:
if is_newer_hash(hash, old_hash, args.repo_name):
# if there was an update, push to branch
subprocess.run(f"git checkout -b {branch_name}".split())
subprocess.run(f"git add .github/ci_commit_pins/{args.repo_name}.txt".split())
subprocess.run(f"git add {args.pin_folder}/{args.repo_name}.txt".split())
subprocess.run(
"git commit -m".split() + [f"update {args.repo_name} commit hash"]
)
Expand Down
19 changes: 15 additions & 4 deletions .github/workflows/_update-commit-hash.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,24 @@ name: update-commit-hash
on:
workflow_call:
inputs:
repo-owner:
required: false
type: string
description: Name of repository's owner.
default: pytorch
repo-name:
required: true
type: string
description: Name of the repository we're updating commit hash for. Must be in pytorch org.
description: Name of the repository we're updating commit hash for.
branch:
required: true
type: string
description: Branch to fetch commit of
pin-folder:
type: string
description: Path to folder with commit pin
required: false
default: .github/ci_commit_pins
secrets:
MERGEBOT_TOKEN:
required: true
Expand All @@ -23,7 +33,7 @@ env:
NEW_BRANCH_NAME: update-${{ inputs.repo-name }}-commit-hash/${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}

jobs:
update-xla-commit-hash:
update-commit-hash:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
Expand All @@ -36,18 +46,19 @@ jobs:
- name: Checkout
shell: bash
run: |
git clone https://github.com/pytorch/${{ inputs.repo-name }}.git --quiet
git clone https://github.com/${{ inputs.repo-owner }}/${{ inputs.repo-name }}.git --quiet
- name: Check if there already exists a PR
shell: bash
env:
REPO_NAME: ${{ inputs.repo-name }}
BRANCH: ${{ inputs.branch }}
PIN_FOLDER: ${{ inputs.pin-folder }}
MERGEBOT_TOKEN: ${{ secrets.MERGEBOT_TOKEN }}
PYTORCHBOT_TOKEN: ${{ secrets.PYTORCHBOT_TOKEN }}
run: |
# put this here instead of the script to prevent accidentally changing the config when running the script locally
git config --global user.name "PyTorch MergeBot"
git config --global user.email "[email protected]"
python .github/scripts/update_commit_hashes.py --repo-name "${REPO_NAME}" --branch "${BRANCH}"
python .github/scripts/update_commit_hashes.py --repo-name "${REPO_NAME}" --branch "${BRANCH}" --pin-folder "${PIN_FOLDER}"
11 changes: 11 additions & 0 deletions .github/workflows/weekly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,14 @@ jobs:
secrets:
MERGEBOT_TOKEN: ${{ secrets.MERGEBOT_TOKEN }}
PYTORCHBOT_TOKEN: ${{ secrets.GH_PYTORCHBOT_TOKEN }}

update-triton-commit-hash:
uses: ./.github/workflows/_update-commit-hash.yml
with:
repo-owner: openai
repo-name: triton
branch: main
pin-folder: .ci/docker/ci_commit_pins
secrets:
MERGEBOT_TOKEN: ${{ secrets.MERGEBOT_TOKEN }}
PYTORCHBOT_TOKEN: ${{ secrets.GH_PYTORCHBOT_TOKEN }}
1 change: 1 addition & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ nn/qat/ @jerryzh168

# Docker
/.ci/docker/ @jeffdaily
/.ci/docker/ci_commit_pins/triton.txt @desertfire @Chillee @eellison @shunting314 @ngimel

# Github Actions
# This list is for people wanting to be notified every time there's a change
Expand Down

0 comments on commit a6155f3

Please sign in to comment.