Skip to content

Commit 2ab7bdc

Browse files
authored
notify new model merged to main (#36375)
notify new model Co-authored-by: ydshieh <[email protected]>
1 parent 05dfed0 commit 2ab7bdc

File tree

2 files changed

+84
-9
lines changed

2 files changed

+84
-9
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Used to notify core maintainers about new model PR being merged
2+
name: New model PR merged notification
3+
4+
on:
5+
push:
6+
branches:
7+
- main
8+
paths:
9+
- 'src/transformers/models/*/modeling_*'
10+
11+
jobs:
12+
notify_new_model:
13+
name: Notify new model
14+
runs-on: ubuntu-22.04
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
- name: Check new model
20+
shell: bash
21+
run: |
22+
python -m pip install gitpython
23+
python -c 'from utils.pr_slow_ci_models import get_new_model; new_model = get_new_model(diff_with_last_commit=True); print(new_model)' | tee output.txt
24+
echo "NEW_MODEL=$(tail -n 1 output.txt)" >> $GITHUB_ENV
25+
echo "COMMIT_SHA=$(git log -1 --format=%H)" >> $GITHUB_ENV
26+
27+
- name: print commit sha
28+
if: ${{ env.NEW_MODEL != ''}}
29+
shell: bash
30+
run: |
31+
echo "$COMMIT_SHA"
32+
33+
- name: print new model
34+
if: ${{ env.NEW_MODEL != ''}}
35+
shell: bash
36+
run: |
37+
echo "$NEW_MODEL"
38+
39+
- name: Notify
40+
if: ${{ env.NEW_MODEL != ''}}
41+
uses: slackapi/slack-github-action@6c661ce58804a1a20f6dc5fbee7f0381b469e001
42+
with:
43+
# Slack channel id, channel name, or user id to post message.
44+
# See also: https://api.slack.com/methods/chat.postMessage#channels
45+
channel-id: transformers-new-model-notification
46+
# For posting a rich message using Block Kit
47+
payload: |
48+
{
49+
"blocks": [
50+
{
51+
"type": "header",
52+
"text": {
53+
"type": "plain_text",
54+
"text": "New model!",
55+
"emoji": true
56+
}
57+
},
58+
{
59+
"type": "section",
60+
"text": {
61+
"type": "mrkdwn",
62+
"text": "<https://github.com/huggingface/transformers/commit/${{ env.COMMIT_SHA }}|New model: ${{ env.NEW_MODEL }}> GH_ArthurZucker, GH_lysandrejik, GH_ydshieh"
63+
}
64+
}
65+
]
66+
}
67+
env:
68+
SLACK_BOT_TOKEN: ${{ secrets.SLACK_CIFEEDBACK_BOT_TOKEN }}

utils/pr_slow_ci_models.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def get_new_python_files_between_commits(base_commit: str, commits: List[str]) -
6464
return code_diff
6565

6666

67-
def get_new_python_files() -> List[str]:
67+
def get_new_python_files(diff_with_last_commit=False) -> List[str]:
6868
"""
6969
Return a list of python files that have been added between the current head and the main branch.
7070
@@ -80,17 +80,24 @@ def get_new_python_files() -> List[str]:
8080
# On GitHub Actions runners, it doesn't have local main branch
8181
main = repo.remotes.origin.refs.main
8282

83-
print(f"main is at {main.commit}")
84-
print(f"Current head is at {repo.head.commit}")
83+
if not diff_with_last_commit:
84+
print(f"main is at {main.commit}")
85+
print(f"Current head is at {repo.head.commit}")
8586

86-
branching_commits = repo.merge_base(main, repo.head)
87-
for commit in branching_commits:
88-
print(f"Branching commit: {commit}")
89-
return get_new_python_files_between_commits(repo.head.commit, branching_commits)
87+
commits = repo.merge_base(main, repo.head)
88+
for commit in commits:
89+
print(f"Branching commit: {commit}")
90+
else:
91+
print(f"main is at {main.commit}")
92+
commits = main.commit.parents
93+
for commit in commits:
94+
print(f"Parent commit: {commit}")
9095

96+
return get_new_python_files_between_commits(repo.head.commit, commits)
9197

92-
def get_new_model():
93-
new_files = get_new_python_files()
98+
99+
def get_new_model(diff_with_last_commit=False):
100+
new_files = get_new_python_files(diff_with_last_commit)
94101
reg = re.compile(r"src/transformers/models/(.*)/modeling_.*\.py")
95102

96103
new_model = ""

0 commit comments

Comments
 (0)