Skip to content

Modify extra PRs diff get method to gh #1707

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 7 additions & 16 deletions .github/scripts/apply_torch_pr.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,12 @@ def check_merged(pr_info):
merged = False
return merged

def appyly_pr(pull_number, re_apply_msg):
# get the diff
os.system(f"\
git fetch origin pull/{pull_number}/head:{pull_number} && \
git checkout -f {pull_number} && \
git merge ci-tmp-$(hostname) --no-edit --no-ff > /dev/null && \
git diff ci-tmp-$(hostname) {pull_number} > {pull_number}.diff \
")
def appyly_pr(pr_info, repo_info, re_apply_msg):
# get pr diff
pr_file = pr_info["diff_url"].split("/")[-1]
os.system(f"gh --repo {repo_info[-4]}/{repo_info[-3]} pr diff {repo_info[-1]} > {pr_file}")
# apply diff
os.system("git checkout ci-test-$(hostname)")
apply_cmd = f"git reset --hard && git apply --3way {pull_number}.diff"
apply_cmd = "git apply --3way " + pr_file
apply_info = subprocess.Popen(apply_cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
apply_message = apply_info.communicate()[0].decode("utf-8")
apply_status = apply_info.returncode
Expand All @@ -88,9 +83,6 @@ def appyly_pr(pull_number, re_apply_msg):
pr_list = args.pr_list + args.extra_pr_list
pr_list = set(pr_list)
pr_list = sorted(pr_list)
# checkout a base branch
os.system("git checkout -b ci-tmp-$(hostname) && git checkout -b ci-test-$(hostname) && rm -f *.diff")
os.system("git config --global user.email intel.com && git config --global user.name intel")
for pr_link in pr_list:
repo_info = pr_link.split("/")
pr_info = requests.get('https://api.' + repo_info[-5] + '/repos/' + repo_info[-4] + '/' + \
Expand All @@ -107,7 +99,7 @@ def appyly_pr(pull_number, re_apply_msg):
continue
else:
re_apply_msg = "is re-opened and reverted,"
appyly_pr(repo_info[-1], re_apply_msg)
appyly_pr(pr_info, repo_info, re_apply_msg)
elif pr_info["state"].lower() == "closed":
merged_id = next((item["id"] for item in pr_info["labels"] if item["name"] == "Merged"), -1)
re_apply_msg = "is closed but not merged"
Expand All @@ -116,8 +108,7 @@ def appyly_pr(pull_number, re_apply_msg):
if merged:
print("{} is closed and merged, no need to apply".format(pr_info["diff_url"]))
continue
appyly_pr(repo_info[-1], re_apply_msg)
appyly_pr(pr_info, repo_info, re_apply_msg)
else:
print("{} is {}, no need to apply".format(pr_info["diff_url"], pr_info["state"]))
sys.exit(1)
os.system("git checkout ci-test-$(hostname) && git reset --hard && git apply --3way *.diff && git status")
4 changes: 2 additions & 2 deletions .github/workflows/_linux_ut.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ jobs:
cd third_party/torch-xpu-ops
git checkout ${TORCH_XPU_OPS_COMMIT}
cd ../..
python third_party/torch-xpu-ops/.github/scripts/apply_torch_pr.py
python ../torch-xpu-ops/.github/scripts/apply_torch_pr.py
fi
pip install -r .ci/docker/requirements-ci.txt
- name: Torch Config
Expand Down Expand Up @@ -412,7 +412,7 @@ jobs:
cd third_party/torch-xpu-ops
git checkout ${TORCH_XPU_OPS_COMMIT}
cd ../..
python third_party/torch-xpu-ops/.github/scripts/apply_torch_pr.py
python ../torch-xpu-ops/.github/scripts/apply_torch_pr.py
fi
pip install -r .ci/docker/requirements-ci.txt
- name: Torch Config
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/nightly_ondemand_whl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ jobs:
cd pytorch && git checkout ${TORCH_COMMIT_ID}
# apply PRs for stock pytorch
pip install requests
# python ../torch-xpu-ops/.github/scripts/apply_torch_pr.py
git status && git show -s
pip install -r requirements.txt
TORCH_XPU_OPS_COMMIT=$(<third_party/xpu.txt)
Expand All @@ -126,7 +125,7 @@ jobs:
cd third_party/torch-xpu-ops
git checkout ${TORCH_XPU_OPS_COMMIT}
cd ../../
python third_party/torch-xpu-ops/.github/scripts/apply_torch_pr.py
python ../torch-xpu-ops/.github/scripts/apply_torch_pr.py
- name: Identify pinned versions
id: pinned
run: |
Expand Down