Skip to content
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
21 changes: 16 additions & 5 deletions .github/scripts/assign_reviewers.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,19 @@
import github
import json
from github import Github
from fnmatch import fnmatch
import re
from collections import Counter
from pathlib import Path

def pattern_to_regex(pattern):
start_anchor = pattern.startswith("/")
pattern = re.escape(pattern)
# Replace `*` with "any number of non-slash characters"
pattern = pattern.replace(r"\*", "[^/]*")
if start_anchor:
pattern = "^" + pattern
return pattern

def get_file_owners(file_path, codeowners_lines):
# Process lines in reverse (last matching pattern takes precedence)
for line in reversed(codeowners_lines):
Expand All @@ -36,18 +45,20 @@ def get_file_owners(file_path, codeowners_lines):
owners = [owner.removeprefix("@") for owner in parts[1:]]

# Check if file matches pattern
if fnmatch(file_path, pattern):
file_regex = pattern_to_regex(pattern)
if re.search(file_regex, file_path) is not None:
return owners # Remember, can still be empty!
return [] # Should never happen, but just in case

def main():
script_dir = Path(__file__).parent.absolute()
with open(script_dir / "codeowners_for_review_action") as f:
codeowners_lines = f.readlines()

g = Github(os.environ['GITHUB_TOKEN'])
repo = g.get_repo("huggingface/transformers")
with open(os.environ['GITHUB_EVENT_PATH']) as f:
event = json.load(f)
script_dir = Path(__file__).parent.absolute()
with open(script_dir / "codeowners_for_review_action") as f:
codeowners_lines = f.readlines()

# The PR number is available in the event payload
pr_number = event['pull_request']['number']
Expand Down
6 changes: 3 additions & 3 deletions .github/scripts/codeowners_for_review_action
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ docs/ @stevhliu
/src/transformers/models/*/image_processing* @qubvel
/src/transformers/models/*/image_processing_*_fast* @yonigozlan


# Owners of subsections of the library
/src/transformers/generation/ @gante
/src/transformers/pipeline/ @Rocketknight1 @yonigozlan
/src/transformers/integrations/ @SunMarc @MekkCyber @muellerzr
/src/transformers/quantizers/ @SunMarc @MekkCyber
/src/transformers/tests/ @ydshieh
/src/transformers/tests/generation/ @gante
tests/ @ydshieh
tests/generation/ @gante

/src/transformers/models/auto/ @ArthurZucker
/src/transformers/utils/ @ArthurZucker @Rocketknight1
/src/transformers/loss/ @ArthurZucker
Expand Down