ultralytics-actions 0.0.48__py3-none-any.whl → 0.0.50__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- actions/__init__.py +1 -1
- actions/summarize_pr.py +16 -16
- actions/utils/common_utils.py +29 -22
- {ultralytics_actions-0.0.48.dist-info → ultralytics_actions-0.0.50.dist-info}/METADATA +1 -1
- {ultralytics_actions-0.0.48.dist-info → ultralytics_actions-0.0.50.dist-info}/RECORD +9 -9
- {ultralytics_actions-0.0.48.dist-info → ultralytics_actions-0.0.50.dist-info}/LICENSE +0 -0
- {ultralytics_actions-0.0.48.dist-info → ultralytics_actions-0.0.50.dist-info}/WHEEL +0 -0
- {ultralytics_actions-0.0.48.dist-info → ultralytics_actions-0.0.50.dist-info}/entry_points.txt +0 -0
- {ultralytics_actions-0.0.48.dist-info → ultralytics_actions-0.0.50.dist-info}/top_level.txt +0 -0
actions/__init__.py
CHANGED
actions/summarize_pr.py
CHANGED
@@ -16,29 +16,29 @@ SUMMARY_START = (
|
|
16
16
|
)
|
17
17
|
|
18
18
|
|
19
|
-
def generate_merge_message(pr_summary=None, pr_credit=None):
|
20
|
-
"""Generates a thank-you message for merged PR contributors."""
|
19
|
+
def generate_merge_message(pr_summary=None, pr_credit=None, pr_url=None):
|
20
|
+
"""Generates a motivating thank-you message for merged PR contributors."""
|
21
21
|
messages = [
|
22
22
|
{
|
23
23
|
"role": "system",
|
24
|
-
"content": "You are an Ultralytics AI assistant. Generate
|
24
|
+
"content": "You are an Ultralytics AI assistant. Generate inspiring, appreciative messages for GitHub contributors.",
|
25
25
|
},
|
26
26
|
{
|
27
27
|
"role": "user",
|
28
|
-
"content":
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
28
|
+
"content": (
|
29
|
+
f"Write a warm thank-you comment for the merged PR {pr_url} by {pr_credit}. "
|
30
|
+
f"Context:\n{pr_summary}\n\n"
|
31
|
+
f"Start with an enthusiastic note about the merge, incorporate a relevant inspirational quote from a historical "
|
32
|
+
f"figure, and connect it to the PR’s impact. Keep it concise yet meaningful, ensuring contributors feel valued."
|
33
|
+
),
|
34
34
|
},
|
35
35
|
]
|
36
36
|
return get_completion(messages)
|
37
37
|
|
38
38
|
|
39
|
-
def post_merge_message(pr_number, repository, summary, pr_credit, headers):
|
39
|
+
def post_merge_message(pr_number, pr_url, repository, summary, pr_credit, headers):
|
40
40
|
"""Posts thank you message on PR after merge."""
|
41
|
-
message = generate_merge_message(summary, pr_credit)
|
41
|
+
message = generate_merge_message(summary, pr_credit, pr_url)
|
42
42
|
comment_url = f"{GITHUB_API_URL}/repos/{repository}/issues/{pr_number}/comments"
|
43
43
|
response = requests.post(comment_url, json={"body": message}, headers=headers)
|
44
44
|
return response.status_code == 201
|
@@ -94,9 +94,8 @@ def generate_pr_summary(repository, diff_text):
|
|
94
94
|
return SUMMARY_START + reply
|
95
95
|
|
96
96
|
|
97
|
-
def update_pr_description(
|
97
|
+
def update_pr_description(pr_url, new_summary, headers, max_retries=2):
|
98
98
|
"""Updates PR description with new summary, retrying if description is None."""
|
99
|
-
pr_url = f"{GITHUB_API_URL}/repos/{repository}/pulls/{pr_number}"
|
100
99
|
description = ""
|
101
100
|
for i in range(max_retries + 1):
|
102
101
|
description = requests.get(pr_url, headers=headers).json().get("body") or ""
|
@@ -210,9 +209,10 @@ def remove_todos_on_merge(pr_number, repository, headers):
|
|
210
209
|
def main(*args, **kwargs):
|
211
210
|
"""Summarize a pull request and update its description with a summary."""
|
212
211
|
action = Action(*args, **kwargs)
|
213
|
-
pr_number = action.pr["number"]
|
214
212
|
headers = action.headers
|
215
213
|
repository = action.repository
|
214
|
+
pr_number = action.pr["number"]
|
215
|
+
pr_url = f"{GITHUB_API_URL}/repos/{repository}/pulls/{pr_number}"
|
216
216
|
|
217
217
|
print(f"Retrieving diff for PR {pr_number}")
|
218
218
|
diff = action.get_pr_diff()
|
@@ -223,7 +223,7 @@ def main(*args, **kwargs):
|
|
223
223
|
|
224
224
|
# Update PR description
|
225
225
|
print("Updating PR description...")
|
226
|
-
status_code = update_pr_description(
|
226
|
+
status_code = update_pr_description(pr_url, summary, headers)
|
227
227
|
if status_code == 200:
|
228
228
|
print("PR description updated successfully.")
|
229
229
|
else:
|
@@ -237,7 +237,7 @@ def main(*args, **kwargs):
|
|
237
237
|
remove_todos_on_merge(pr_number, repository, headers)
|
238
238
|
if pr_credit:
|
239
239
|
print("Posting PR author thank you message...")
|
240
|
-
post_merge_message(pr_number, repository, summary, pr_credit, headers)
|
240
|
+
post_merge_message(pr_number, pr_url, repository, summary, pr_credit, headers)
|
241
241
|
|
242
242
|
|
243
243
|
if __name__ == "__main__":
|
actions/utils/common_utils.py
CHANGED
@@ -34,27 +34,24 @@ BAD_HTTP_CODES = frozenset(
|
|
34
34
|
504, # Gateway Timeout - upstream server didn't respond in time
|
35
35
|
}
|
36
36
|
)
|
37
|
-
URL_IGNORE_LIST = frozenset
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
"storage.googleapis.com", # private GCS buckets
|
56
|
-
}
|
57
|
-
)
|
37
|
+
URL_IGNORE_LIST = { # use a set (not frozenset) to update with possible private GitHub repos
|
38
|
+
"localhost",
|
39
|
+
"127.0.0",
|
40
|
+
":5000",
|
41
|
+
":3000",
|
42
|
+
":8000",
|
43
|
+
":8080",
|
44
|
+
":6006",
|
45
|
+
"MODEL_ID",
|
46
|
+
"API_KEY",
|
47
|
+
"url",
|
48
|
+
"example",
|
49
|
+
"mailto:",
|
50
|
+
"linkedin.com",
|
51
|
+
"twitter.com",
|
52
|
+
"x.com",
|
53
|
+
"storage.googleapis.com", # private GCS buckets
|
54
|
+
}
|
58
55
|
URL_PATTERN = re.compile(
|
59
56
|
r"\[([^]]+)]\(([^)]+)\)" # Matches Markdown links [text](url)
|
60
57
|
r"|"
|
@@ -81,7 +78,7 @@ def clean_url(url):
|
|
81
78
|
|
82
79
|
|
83
80
|
def is_url(url, session=None, check=True, max_attempts=3, timeout=2):
|
84
|
-
"""Check if string is URL and optionally verify it exists."""
|
81
|
+
"""Check if string is URL and optionally verify it exists, with fallback for GitHub repos."""
|
85
82
|
try:
|
86
83
|
# Check allow list
|
87
84
|
if any(x in url for x in URL_IGNORE_LIST):
|
@@ -105,6 +102,16 @@ def is_url(url, session=None, check=True, max_attempts=3, timeout=2):
|
|
105
102
|
for method in (requester.head, requester.get):
|
106
103
|
if method(url, stream=method == requester.get, **kwargs).status_code not in BAD_HTTP_CODES:
|
107
104
|
return True
|
105
|
+
|
106
|
+
# If GitHub and check fails (repo might be private), add the base GitHub URL to ignore list
|
107
|
+
if result.hostname == "github.com":
|
108
|
+
parts = result.path.strip("/").split("/")
|
109
|
+
if len(parts) >= 2:
|
110
|
+
base_url = f"https://github.com/{parts[0]}/{parts[1]}" # https://github.com/org/repo
|
111
|
+
if requester.head(base_url, **kwargs).status_code == 404:
|
112
|
+
URL_IGNORE_LIST.add(base_url)
|
113
|
+
return True
|
114
|
+
|
108
115
|
return False
|
109
116
|
except Exception:
|
110
117
|
if attempt == max_attempts - 1: # last attempt
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: ultralytics-actions
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.50
|
4
4
|
Summary: Ultralytics Actions for GitHub automation and PR management.
|
5
5
|
Author-email: Glenn Jocher <glenn.jocher@ultralytics.com>
|
6
6
|
Maintainer-email: Ultralytics <hello@ultralytics.com>
|
@@ -1,15 +1,15 @@
|
|
1
|
-
actions/__init__.py,sha256=
|
1
|
+
actions/__init__.py,sha256=4U8iPnscnkKIwXcYrHT-0T4HHmy37vzw_sbFoMwGSyw,742
|
2
2
|
actions/first_interaction.py,sha256=Oosw3GlXObF4RxYJG8haIjKXSV4MAx_uPXfMdRKY5qA,17851
|
3
|
-
actions/summarize_pr.py,sha256=
|
3
|
+
actions/summarize_pr.py,sha256=gLtKlE_iKzP92vBfA-KA9bXUwdrKIe79pH2f4Oyq_gg,11075
|
4
4
|
actions/summarize_release.py,sha256=2D1IIeS4xrQNEJER3HItm5u9XvTL8hwGX_jWD2S8q1Y,8455
|
5
5
|
actions/update_markdown_code_blocks.py,sha256=DN6rrDw2VHXUTetrrg1SHlYDco9iaGOfQBKFORqbCBI,6362
|
6
6
|
actions/utils/__init__.py,sha256=WStdEAYROVnF0nubEOmrFLrejkRiMXIefA5O1ckfcFs,476
|
7
|
-
actions/utils/common_utils.py,sha256=
|
7
|
+
actions/utils/common_utils.py,sha256=LJ79U5sQuTnVyhc22Bryb5YUBAWy13rGoHdfbaBQl3s,5988
|
8
8
|
actions/utils/github_utils.py,sha256=0h0Hz2tgUta61Ymn9YggRXBZ7aZdF5krKnX7Tj9jqRU,7068
|
9
9
|
actions/utils/openai_utils.py,sha256=U7DjxTdFGdhmWSE4_KIg1yPQdtrfG4GkbNZCgMw4_1Q,1822
|
10
|
-
ultralytics_actions-0.0.
|
11
|
-
ultralytics_actions-0.0.
|
12
|
-
ultralytics_actions-0.0.
|
13
|
-
ultralytics_actions-0.0.
|
14
|
-
ultralytics_actions-0.0.
|
15
|
-
ultralytics_actions-0.0.
|
10
|
+
ultralytics_actions-0.0.50.dist-info/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
|
11
|
+
ultralytics_actions-0.0.50.dist-info/METADATA,sha256=qPiz8EXLadPuzCesY3Sojb5Hs-D-B2j5znK16qmYR9I,10561
|
12
|
+
ultralytics_actions-0.0.50.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
13
|
+
ultralytics_actions-0.0.50.dist-info/entry_points.txt,sha256=GowvOFplj0C7JmsjbKcbpgLpdf2r921pcaOQkAHWZRA,378
|
14
|
+
ultralytics_actions-0.0.50.dist-info/top_level.txt,sha256=5apM5x80QlJcGbACn1v3fkmIuL1-XQCKcItJre7w7Tw,8
|
15
|
+
ultralytics_actions-0.0.50.dist-info/RECORD,,
|
File without changes
|
File without changes
|
{ultralytics_actions-0.0.48.dist-info → ultralytics_actions-0.0.50.dist-info}/entry_points.txt
RENAMED
File without changes
|
File without changes
|