Skip to content

Commit e13dc4f

Browse files
authored
Merge branch 'main' into slogdet
2 parents af8b4ce + 6c833e1 commit e13dc4f

7 files changed

+34
-13
lines changed

.github/scripts/apply_torch_pr.py

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11

22
import requests
33
import argparse
4-
import urllib
54
import subprocess
65
import sys
6+
import os
77

88

99
parser = argparse.ArgumentParser()
@@ -54,12 +54,17 @@ def check_merged(pr_info):
5454
merged = False
5555
return merged
5656

57-
def appyly_pr(pr_info, re_apply_msg):
58-
# get pr diff
59-
pr_file = pr_info["diff_url"].split("/")[-1]
60-
urllib.request.urlretrieve(pr_info["diff_url"], pr_file)
57+
def appyly_pr(pull_number, re_apply_msg):
58+
# get the diff
59+
os.system(f"\
60+
git fetch origin pull/{pull_number}/head:{pull_number} && \
61+
git checkout -f {pull_number} && \
62+
git merge ci-tmp-$(hostname) --no-edit --no-ff > /dev/null && \
63+
git diff ci-tmp-$(hostname) {pull_number} > {pull_number}.diff \
64+
")
6165
# apply diff
62-
apply_cmd = "git apply --3way " + pr_file
66+
os.system("git checkout ci-test-$(hostname)")
67+
apply_cmd = f"git reset --hard && git apply --3way {pull_number}.diff"
6368
apply_info = subprocess.Popen(apply_cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
6469
apply_message = apply_info.communicate()[0].decode("utf-8")
6570
apply_status = apply_info.returncode
@@ -72,15 +77,22 @@ def appyly_pr(pr_info, re_apply_msg):
7277
sys.exit(1)
7378

7479

75-
# headers = {'Authorization': 'Bearer ' + args.token} if args.token != None else args.token
80+
github_token = os.environ.get("GH_TOKEN")
81+
headers = {
82+
"Authorization": f"Bearer {github_token}",
83+
"Accept": "application/vnd.github+json",
84+
"X-GitHub-Api-Version": "2022-11-28",
85+
}
7686
pr_list = args.pr_list + args.extra_pr_list
7787
pr_list = set(pr_list)
7888
pr_list = sorted(pr_list)
89+
# checkout a base branch
90+
os.system("git checkout -b ci-tmp-$(hostname) && git checkout -b ci-test-$(hostname) && rm -f *.diff")
91+
os.system("git config --global user.email intel.com && git config --global user.name intel")
7992
for pr_link in pr_list:
8093
repo_info = pr_link.split("/")
8194
pr_info = requests.get('https://api.' + repo_info[-5] + '/repos/' + repo_info[-4] + '/' + \
82-
repo_info[-3] + '/pulls/' + repo_info[-1], timeout=60).json()
83-
95+
repo_info[-3] + '/pulls/' + repo_info[-1], headers=headers, timeout=60).json()
8496
if pr_info["state"].lower() == "open":
8597
# for reverted PR
8698
reverted_id = next((item["id"] for item in pr_info["labels"] if item["name"] == "Reverted"), -1)
@@ -93,7 +105,7 @@ def appyly_pr(pr_info, re_apply_msg):
93105
continue
94106
else:
95107
re_apply_msg = "is re-opened and reverted,"
96-
appyly_pr(pr_info, re_apply_msg)
108+
appyly_pr(repo_info[-1], re_apply_msg)
97109
elif pr_info["state"].lower() == "closed":
98110
merged_id = next((item["id"] for item in pr_info["labels"] if item["name"] == "Merged"), -1)
99111
re_apply_msg = "is closed but not merged"
@@ -102,7 +114,8 @@ def appyly_pr(pr_info, re_apply_msg):
102114
if merged:
103115
print("{} is closed and merged, no need to apply".format(pr_info["diff_url"]))
104116
continue
105-
appyly_pr(pr_info, re_apply_msg)
117+
appyly_pr(repo_info[-1], re_apply_msg)
106118
else:
107119
print("{} is {}, no need to apply".format(pr_info["diff_url"], pr_info["state"]))
108120
sys.exit(1)
121+
os.system("git checkout ci-test-$(hostname) && git reset --hard && git apply --3way *.diff && git status")

.github/workflows/_linux_op_benchmark.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ jobs:
4141
runs-on: ${{ inputs.runner }}
4242
timeout-minutes: 900
4343
env:
44+
GH_TOKEN: ${{ github.token }}
4445
NEOReadDebugKeys: ${{ inputs.driver == 'rolling' && '1' || '0' }}
4546
DisableScratchPages: ${{ inputs.driver == 'rolling' && '1' || '0' }}
4647
steps:

.github/workflows/_linux_ut.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ jobs:
4747
if: ${{ inputs.ut != 'xpu_distributed' }}
4848
timeout-minutes: 900
4949
env:
50+
GH_TOKEN: ${{ github.token }}
5051
NEOReadDebugKeys: ${{ inputs.driver == 'rolling' && '1' || '0' }}
5152
DisableScratchPages: ${{ inputs.driver == 'rolling' && '1' || '0' }}
5253
steps:
@@ -279,6 +280,7 @@ jobs:
279280
if: contains(inputs.ut, 'xpu_distributed')
280281
timeout-minutes: 900
281282
env:
283+
GH_TOKEN: ${{ github.token }}
282284
NEOReadDebugKeys: ${{ inputs.driver == 'rolling' && '1' || '0' }}
283285
DisableScratchPages: ${{ inputs.driver == 'rolling' && '1' || '0' }}
284286
steps:

.github/workflows/nightly_ondemand.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ jobs:
101101
needs: Linux-Nightly-Ondemand-Build
102102
timeout-minutes: 3600
103103
env:
104+
GH_TOKEN: ${{ github.token }}
104105
pytorch: ${{ needs.Linux-Nightly-Ondemand-Build.outputs.torch_commit_id }}
105106
keep_torch_xpu_ops: ${{ github.event_name == 'schedule' && 'false' || inputs.keep_torch_xpu_ops }}
106107
python: ${{ github.event_name == 'schedule' && '3.10' || inputs.python }}

.github/workflows/nightly_ondemand_rolling.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ jobs:
116116
needs: Linux-Nightly-Ondemand-Build-Rolling
117117
timeout-minutes: 3600
118118
env:
119+
GH_TOKEN: ${{ github.token }}
119120
pytorch: ${{ needs.Linux-Nightly-Ondemand-Build-Rolling.outputs.torch_commit_id }}
120121
keep_torch_xpu_ops: ${{ github.event_name == 'schedule' && 'false' || inputs.keep_torch_xpu_ops }}
121122
python: ${{ github.event_name == 'schedule' && '3.10' || inputs.python }}

.github/workflows/nightly_ondemand_whl.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ jobs:
7171
if: ${{ github.repository_owner == 'intel' }}
7272
timeout-minutes: 3600
7373
env:
74+
GH_TOKEN: ${{ github.token }}
7475
pytorch: ${{ github.event_name == 'schedule' && 'nightly' || inputs.pytorch }}
7576
python: ${{ github.event_name == 'schedule' && '3.10' || inputs.python }}
7677
run_type: ${{ (github.event_name == 'schedule' && (github.event.schedule == '0 17 * * 5' && 'weekly' || 'nightly')) || 'on-demand' }}

.github/workflows/pull.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ jobs:
7171
name: preci-linux / e2e_test
7272
needs: preci-linux-build
7373
runs-on: pvc_e2e
74+
env:
75+
GH_TOKEN: ${{ github.token }}
7476
# Don't run on forked repos and draft PRs
7577
if: ${{ (github.repository_owner == 'intel') && (github.event.pull_request.draft == false) }}
7678
timeout-minutes: 900
@@ -93,8 +95,8 @@ jobs:
9395
cd pytorch && git checkout ${{ needs.preci-linux-build.outputs.torch_commit_id }}
9496
# apply PRs for stock pytorch
9597
pip install requests
96-
# https://github.com/mengfei25/pytorch/pull/18 internal use only for subset model list
97-
python ../torch-xpu-ops/.github/scripts/apply_torch_pr.py -e https://github.com/mengfei25/pytorch/pull/18
98+
# https://github.com/pytorch/pytorch/pull/152940 internal use only for subset model list
99+
python ../torch-xpu-ops/.github/scripts/apply_torch_pr.py -e https://github.com/pytorch/pytorch/pull/152940
98100
git status && git show -s
99101
rm -rf third_party/torch-xpu-ops && cp -r ../torch-xpu-ops third_party/
100102
# Workaround for torch-xpu-ops ci test

0 commit comments

Comments
 (0)