Skip to content

Commit

Permalink
2024-10-23 nightly release (fe20be9)
Browse files Browse the repository at this point in the history
  • Loading branch information
pytorchbot committed Oct 23, 2024
1 parent c13b9f3 commit d518ab9
Show file tree
Hide file tree
Showing 121 changed files with 7,157 additions and 671 deletions.
25 changes: 16 additions & 9 deletions .github/scripts/propose_ghstack_orig_pr.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ def parse_args():
required=True,
)
parser.add_argument(
"--pr",
type=int,
help="Number of the PR in the stack to check and create corresponding PR",
"--ref",
type=str,
help="Ref fo PR in the stack to check and create corresponding PR",
required=True,
)
return parser.parse_args()
Expand Down Expand Up @@ -68,12 +68,18 @@ def extract_stack_from_body(pr_body: str) -> List[int]:
return list(reversed(prs))


def get_pr_stack_from_number(pr_number: int, repo: Repository) -> List[int]:
def get_pr_stack_from_number(ref: str, repo: Repository) -> List[int]:
if ref.isnumeric():
pr_number = int(ref)
else:
branch_name = ref.replace("refs/heads/", "")
pr_number = repo.get_branch(branch_name).commit.get_pulls()[0].number

pr_stack = extract_stack_from_body(repo.get_pull(pr_number).body)

if not pr_stack:
raise Exception(
f"Could not find PR stack in body of #{pr_number}. "
f"Could not find PR stack in body of ref. "
+ "Please make sure that the PR was created with ghstack."
)

Expand All @@ -100,14 +106,15 @@ def create_prs_for_orig_branch(pr_stack: List[int], repo: Repository):
ghstack PR base: https://github.com/pytorch/executorch/tree/{pr.base.ref}
ghstack PR head: https://github.com/pytorch/executorch/tree/{pr.head.ref}
Merge bot PR base: https://github.com/pytorch/executorch/tree/{orig_branch_merge_base}
Merge bot PR head: https://github.com/pytorch/executorch/tree/{orig_branch_merge_head}"""
Merge bot PR head: https://github.com/pytorch/executorch/tree/{orig_branch_merge_head}
@diff-train-skip-merge"""

existing_orig_pr = repo.get_pulls(
head="pytorch:" + orig_branch_merge_head,
base=orig_branch_merge_base,
state="open",
state="all",
)
if existing_orig_pr.totalCount > 0:
if existing_orig_pr.totalCount > 0 and existing_orig_pr[0].title == pr.title:
print(
f"PR for {orig_branch_merge_head} already exists {existing_orig_pr[0]}"
)
Expand All @@ -128,7 +135,7 @@ def main():

with Github(auth=Auth.Token(os.environ["GITHUB_TOKEN"])) as gh:
repo = gh.get_repo(args.repo)
create_prs_for_orig_branch(get_pr_stack_from_number(args.pr, repo), repo)
create_prs_for_orig_branch(get_pr_stack_from_number(args.ref, repo), repo)


if __name__ == "__main__":
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/ghstack_land.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ jobs:
run: |
pip install pygithub
PR_NUMBER=$(echo "$GITHUB_REF" | grep -oE '[0-9]+')
python .github/scripts/propose_ghstack_orig_pr.py --pr $PR_NUMBER --repo pytorch/executorch
python .github/scripts/propose_ghstack_orig_pr.py --ref $GITHUB_REF --repo pytorch/executorch
env:
GITHUB_TOKEN: ${{ secrets.GH_PYTORCHBOT_CHERRY_PICK_TOKEN }}
GITHUB_REF: ${{ github.ref }}
Loading

0 comments on commit d518ab9

Please sign in to comment.