mirror of
https://github.com/huggingface/transformers.git
synced 2025-07-03 04:40:06 +06:00
notify new model merged to main
(#36375)
notify new model Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
This commit is contained in:
parent
05dfed06d7
commit
2ab7bdc403
68
.github/workflows/new_model_pr_merged_notification.yml
vendored
Normal file
68
.github/workflows/new_model_pr_merged_notification.yml
vendored
Normal file
@ -0,0 +1,68 @@
|
||||
# Used to notify core maintainers about new model PR being merged
|
||||
name: New model PR merged notification
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- 'src/transformers/models/*/modeling_*'
|
||||
|
||||
jobs:
|
||||
notify_new_model:
|
||||
name: Notify new model
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Check new model
|
||||
shell: bash
|
||||
run: |
|
||||
python -m pip install gitpython
|
||||
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
|
||||
echo "NEW_MODEL=$(tail -n 1 output.txt)" >> $GITHUB_ENV
|
||||
echo "COMMIT_SHA=$(git log -1 --format=%H)" >> $GITHUB_ENV
|
||||
|
||||
- name: print commit sha
|
||||
if: ${{ env.NEW_MODEL != ''}}
|
||||
shell: bash
|
||||
run: |
|
||||
echo "$COMMIT_SHA"
|
||||
|
||||
- name: print new model
|
||||
if: ${{ env.NEW_MODEL != ''}}
|
||||
shell: bash
|
||||
run: |
|
||||
echo "$NEW_MODEL"
|
||||
|
||||
- name: Notify
|
||||
if: ${{ env.NEW_MODEL != ''}}
|
||||
uses: slackapi/slack-github-action@6c661ce58804a1a20f6dc5fbee7f0381b469e001
|
||||
with:
|
||||
# Slack channel id, channel name, or user id to post message.
|
||||
# See also: https://api.slack.com/methods/chat.postMessage#channels
|
||||
channel-id: transformers-new-model-notification
|
||||
# For posting a rich message using Block Kit
|
||||
payload: |
|
||||
{
|
||||
"blocks": [
|
||||
{
|
||||
"type": "header",
|
||||
"text": {
|
||||
"type": "plain_text",
|
||||
"text": "New model!",
|
||||
"emoji": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "section",
|
||||
"text": {
|
||||
"type": "mrkdwn",
|
||||
"text": "<https://github.com/huggingface/transformers/commit/${{ env.COMMIT_SHA }}|New model: ${{ env.NEW_MODEL }}> GH_ArthurZucker, GH_lysandrejik, GH_ydshieh"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
env:
|
||||
SLACK_BOT_TOKEN: ${{ secrets.SLACK_CIFEEDBACK_BOT_TOKEN }}
|
@ -64,7 +64,7 @@ def get_new_python_files_between_commits(base_commit: str, commits: List[str]) -
|
||||
return code_diff
|
||||
|
||||
|
||||
def get_new_python_files() -> List[str]:
|
||||
def get_new_python_files(diff_with_last_commit=False) -> List[str]:
|
||||
"""
|
||||
Return a list of python files that have been added between the current head and the main branch.
|
||||
|
||||
@ -80,17 +80,24 @@ def get_new_python_files() -> List[str]:
|
||||
# On GitHub Actions runners, it doesn't have local main branch
|
||||
main = repo.remotes.origin.refs.main
|
||||
|
||||
print(f"main is at {main.commit}")
|
||||
print(f"Current head is at {repo.head.commit}")
|
||||
if not diff_with_last_commit:
|
||||
print(f"main is at {main.commit}")
|
||||
print(f"Current head is at {repo.head.commit}")
|
||||
|
||||
branching_commits = repo.merge_base(main, repo.head)
|
||||
for commit in branching_commits:
|
||||
print(f"Branching commit: {commit}")
|
||||
return get_new_python_files_between_commits(repo.head.commit, branching_commits)
|
||||
commits = repo.merge_base(main, repo.head)
|
||||
for commit in commits:
|
||||
print(f"Branching commit: {commit}")
|
||||
else:
|
||||
print(f"main is at {main.commit}")
|
||||
commits = main.commit.parents
|
||||
for commit in commits:
|
||||
print(f"Parent commit: {commit}")
|
||||
|
||||
return get_new_python_files_between_commits(repo.head.commit, commits)
|
||||
|
||||
|
||||
def get_new_model():
|
||||
new_files = get_new_python_files()
|
||||
def get_new_model(diff_with_last_commit=False):
|
||||
new_files = get_new_python_files(diff_with_last_commit)
|
||||
reg = re.compile(r"src/transformers/models/(.*)/modeling_.*\.py")
|
||||
|
||||
new_model = ""
|
||||
|
Loading…
Reference in New Issue
Block a user