ultralytics-actions 0.0.47__py3-none-any.whl → 0.0.49__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 +13 -4
- {ultralytics_actions-0.0.47.dist-info → ultralytics_actions-0.0.49.dist-info}/METADATA +1 -1
- {ultralytics_actions-0.0.47.dist-info → ultralytics_actions-0.0.49.dist-info}/RECORD +9 -9
- {ultralytics_actions-0.0.47.dist-info → ultralytics_actions-0.0.49.dist-info}/LICENSE +0 -0
- {ultralytics_actions-0.0.47.dist-info → ultralytics_actions-0.0.49.dist-info}/WHEEL +0 -0
- {ultralytics_actions-0.0.47.dist-info → ultralytics_actions-0.0.49.dist-info}/entry_points.txt +0 -0
- {ultralytics_actions-0.0.47.dist-info → ultralytics_actions-0.0.49.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
@@ -22,7 +22,18 @@ REQUESTS_HEADERS = {
|
|
22
22
|
"Referer": "https://www.google.com/",
|
23
23
|
"Origin": "https://www.google.com/",
|
24
24
|
}
|
25
|
-
|
25
|
+
BAD_HTTP_CODES = frozenset(
|
26
|
+
{
|
27
|
+
# 403, # Forbidden - client lacks permission to access the resource (commented as works in browser typically)
|
28
|
+
404, # Not Found - requested resource doesn't exist
|
29
|
+
405, # Method Not Allowed - HTTP method not supported for this endpoint
|
30
|
+
410, # Gone - resource permanently removed
|
31
|
+
500, # Internal Server Error - server encountered an error
|
32
|
+
502, # Bad Gateway - upstream server sent invalid response
|
33
|
+
503, # Service Unavailable - server temporarily unable to handle request
|
34
|
+
504, # Gateway Timeout - upstream server didn't respond in time
|
35
|
+
}
|
36
|
+
)
|
26
37
|
URL_IGNORE_LIST = frozenset(
|
27
38
|
{
|
28
39
|
"localhost",
|
@@ -44,7 +55,6 @@ URL_IGNORE_LIST = frozenset(
|
|
44
55
|
"storage.googleapis.com", # private GCS buckets
|
45
56
|
}
|
46
57
|
)
|
47
|
-
|
48
58
|
URL_PATTERN = re.compile(
|
49
59
|
r"\[([^]]+)]\(([^)]+)\)" # Matches Markdown links [text](url)
|
50
60
|
r"|"
|
@@ -85,7 +95,6 @@ def is_url(url, session=None, check=True, max_attempts=3, timeout=2):
|
|
85
95
|
|
86
96
|
if check:
|
87
97
|
requester = session or requests
|
88
|
-
bad_codes = {404, 410, 500, 502, 503, 504}
|
89
98
|
kwargs = {"timeout": timeout, "allow_redirects": True}
|
90
99
|
if not session:
|
91
100
|
kwargs["headers"] = REQUESTS_HEADERS
|
@@ -94,7 +103,7 @@ def is_url(url, session=None, check=True, max_attempts=3, timeout=2):
|
|
94
103
|
try:
|
95
104
|
# Try HEAD first, then GET if needed
|
96
105
|
for method in (requester.head, requester.get):
|
97
|
-
if method(url, stream=method == requester.get, **kwargs).status_code not in
|
106
|
+
if method(url, stream=method == requester.get, **kwargs).status_code not in BAD_HTTP_CODES:
|
98
107
|
return True
|
99
108
|
return False
|
100
109
|
except Exception:
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: ultralytics-actions
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.49
|
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=YUeY18AoDEXKIMWCCr6xUi_stDUqF6_LCok9BxN8iQg,742
|
2
2
|
actions/first_interaction.py,sha256=Oosw3GlXObF4RxYJG8haIjKXSV4MAx_uPXfMdRKY5qA,17851
|
3
|
-
actions/summarize_pr.py,sha256=
|
3
|
+
actions/summarize_pr.py,sha256=dnjZcbGItvhpxq2yNiSWuiPBmZTHAW3ufu2upDgOT3I,11074
|
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=o2dMSS7TxpwJLU58ybcZFgtaV-PM5lzQRP0B9cW-bBc,5420
|
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.49.dist-info/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
|
11
|
+
ultralytics_actions-0.0.49.dist-info/METADATA,sha256=nw_Qne-ukAxDpCNRxbDRqN7jiTTIHNZqf5xxK8XxU3w,10561
|
12
|
+
ultralytics_actions-0.0.49.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
13
|
+
ultralytics_actions-0.0.49.dist-info/entry_points.txt,sha256=GowvOFplj0C7JmsjbKcbpgLpdf2r921pcaOQkAHWZRA,378
|
14
|
+
ultralytics_actions-0.0.49.dist-info/top_level.txt,sha256=5apM5x80QlJcGbACn1v3fkmIuL1-XQCKcItJre7w7Tw,8
|
15
|
+
ultralytics_actions-0.0.49.dist-info/RECORD,,
|
File without changes
|
File without changes
|
{ultralytics_actions-0.0.47.dist-info → ultralytics_actions-0.0.49.dist-info}/entry_points.txt
RENAMED
File without changes
|
File without changes
|