ultralytics-actions 0.0.7__py3-none-any.whl → 0.0.15__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/first_interaction.py +21 -24
- actions/summarize_pr.py +30 -17
- actions/summarize_release.py +5 -5
- actions/utils/__init__.py +10 -4
- actions/utils/common_utils.py +10 -1
- actions/utils/github_utils.py +50 -7
- actions/utils/openai_utils.py +1 -1
- {ultralytics_actions-0.0.7.dist-info → ultralytics_actions-0.0.15.dist-info}/METADATA +1 -1
- ultralytics_actions-0.0.15.dist-info/RECORD +15 -0
- {ultralytics_actions-0.0.7.dist-info → ultralytics_actions-0.0.15.dist-info}/entry_points.txt +1 -0
- ultralytics_actions-0.0.7.dist-info/RECORD +0 -15
- {ultralytics_actions-0.0.7.dist-info → ultralytics_actions-0.0.15.dist-info}/LICENSE +0 -0
- {ultralytics_actions-0.0.7.dist-info → ultralytics_actions-0.0.15.dist-info}/WHEEL +0 -0
- {ultralytics_actions-0.0.7.dist-info → ultralytics_actions-0.0.15.dist-info}/top_level.txt +0 -0
actions/__init__.py
CHANGED
actions/first_interaction.py
CHANGED
@@ -1,17 +1,16 @@
|
|
1
1
|
# Ultralytics Actions 🚀, AGPL-3.0 license https://ultralytics.com/license
|
2
2
|
|
3
|
-
import json
|
4
3
|
import os
|
5
4
|
from typing import Dict, List, Tuple
|
6
5
|
|
7
6
|
import requests
|
8
7
|
|
9
8
|
from .utils import (
|
9
|
+
EVENT_DATA,
|
10
10
|
GITHUB_API_URL,
|
11
11
|
GITHUB_EVENT_NAME,
|
12
|
-
GITHUB_EVENT_PATH,
|
13
12
|
GITHUB_HEADERS,
|
14
|
-
|
13
|
+
GITHUB_REPOSITORY,
|
15
14
|
get_completion,
|
16
15
|
get_github_data,
|
17
16
|
get_pr_diff,
|
@@ -25,18 +24,16 @@ BLOCK_USER = os.getenv("BLOCK_USER", "false").lower() == "true"
|
|
25
24
|
|
26
25
|
def get_event_content() -> Tuple[int, str, str, str, str, str, str]:
|
27
26
|
"""Extracts key information from GitHub event data for issues, pull requests, or discussions."""
|
28
|
-
|
29
|
-
data = json.load(f)
|
30
|
-
action = data["action"] # 'opened', 'closed', 'created' (discussion), etc.
|
27
|
+
action = EVENT_DATA["action"] # 'opened', 'closed', 'created' (discussion), etc.
|
31
28
|
if GITHUB_EVENT_NAME == "issues":
|
32
|
-
item =
|
29
|
+
item = EVENT_DATA["issue"]
|
33
30
|
issue_type = "issue"
|
34
31
|
elif GITHUB_EVENT_NAME in ["pull_request", "pull_request_target"]:
|
35
|
-
pr_number =
|
32
|
+
pr_number = EVENT_DATA["pull_request"]["number"]
|
36
33
|
item = get_github_data(f"pulls/{pr_number}")
|
37
34
|
issue_type = "pull request"
|
38
35
|
elif GITHUB_EVENT_NAME == "discussion":
|
39
|
-
item =
|
36
|
+
item = EVENT_DATA["discussion"]
|
40
37
|
issue_type = "discussion"
|
41
38
|
else:
|
42
39
|
raise ValueError(f"Unsupported event type: {GITHUB_EVENT_NAME}")
|
@@ -73,7 +70,7 @@ mutation($discussionId: ID!, $title: String!, $body: String!) {
|
|
73
70
|
"""
|
74
71
|
graphql_request(mutation, variables={"discussionId": node_id, "title": new_title, "body": new_body})
|
75
72
|
else:
|
76
|
-
url = f"{GITHUB_API_URL}/repos/{
|
73
|
+
url = f"{GITHUB_API_URL}/repos/{GITHUB_REPOSITORY}/issues/{number}"
|
77
74
|
r = requests.patch(url, json={"title": new_title, "body": new_body}, headers=GITHUB_HEADERS)
|
78
75
|
print(f"{'Successful' if r.status_code == 200 else 'Fail'} issue/PR #{number} update: {r.status_code}")
|
79
76
|
|
@@ -92,7 +89,7 @@ mutation($discussionId: ID!) {
|
|
92
89
|
"""
|
93
90
|
graphql_request(mutation, variables={"discussionId": node_id})
|
94
91
|
else:
|
95
|
-
url = f"{GITHUB_API_URL}/repos/{
|
92
|
+
url = f"{GITHUB_API_URL}/repos/{GITHUB_REPOSITORY}/issues/{number}"
|
96
93
|
r = requests.patch(url, json={"state": "closed"}, headers=GITHUB_HEADERS)
|
97
94
|
print(f"{'Successful' if r.status_code == 200 else 'Fail'} issue/PR #{number} close: {r.status_code}")
|
98
95
|
|
@@ -113,14 +110,14 @@ mutation($lockableId: ID!, $lockReason: LockReason) {
|
|
113
110
|
"""
|
114
111
|
graphql_request(mutation, variables={"lockableId": node_id, "lockReason": "OFF_TOPIC"})
|
115
112
|
else:
|
116
|
-
url = f"{GITHUB_API_URL}/repos/{
|
113
|
+
url = f"{GITHUB_API_URL}/repos/{GITHUB_REPOSITORY}/issues/{number}/lock"
|
117
114
|
r = requests.put(url, json={"lock_reason": "off-topic"}, headers=GITHUB_HEADERS)
|
118
115
|
print(f"{'Successful' if r.status_code in {200, 204} else 'Fail'} issue/PR #{number} lock: {r.status_code}")
|
119
116
|
|
120
117
|
|
121
118
|
def block_user(username: str):
|
122
119
|
"""Blocks a user from the organization using the GitHub API."""
|
123
|
-
url = f"{GITHUB_API_URL}/orgs/{
|
120
|
+
url = f"{GITHUB_API_URL}/orgs/{GITHUB_REPOSITORY.split('/')[0]}/blocks/{username}"
|
124
121
|
r = requests.put(url, headers=GITHUB_HEADERS)
|
125
122
|
print(f"{'Successful' if r.status_code == 204 else 'Fail'} user block for {username}: {r.status_code}")
|
126
123
|
|
@@ -200,7 +197,7 @@ query($owner: String!, $name: String!) {
|
|
200
197
|
}
|
201
198
|
}
|
202
199
|
"""
|
203
|
-
owner, repo =
|
200
|
+
owner, repo = GITHUB_REPOSITORY.split("/")
|
204
201
|
result = graphql_request(query, variables={"owner": owner, "name": repo})
|
205
202
|
if "data" in result and "repository" in result["data"]:
|
206
203
|
all_labels = result["data"]["repository"]["labels"]["nodes"]
|
@@ -237,7 +234,7 @@ mutation($labelableId: ID!, $labelIds: [ID!]!) {
|
|
237
234
|
graphql_request(mutation, {"labelableId": node_id, "labelIds": label_ids})
|
238
235
|
print(f"Successfully applied labels: {', '.join(labels)}")
|
239
236
|
else:
|
240
|
-
url = f"{GITHUB_API_URL}/repos/{
|
237
|
+
url = f"{GITHUB_API_URL}/repos/{GITHUB_REPOSITORY}/issues/{number}/labels"
|
241
238
|
r = requests.post(url, json={"labels": labels}, headers=GITHUB_HEADERS)
|
242
239
|
print(f"{'Successful' if r.status_code == 200 else 'Fail'} apply labels {', '.join(labels)}: {r.status_code}")
|
243
240
|
|
@@ -245,12 +242,12 @@ mutation($labelableId: ID!, $labelIds: [ID!]!) {
|
|
245
242
|
def create_alert_label():
|
246
243
|
"""Creates the 'Alert' label in the repository if it doesn't exist, with a red color and description."""
|
247
244
|
alert_label = {"name": "Alert", "color": "FF0000", "description": "Potential spam, abuse, or off-topic."}
|
248
|
-
requests.post(f"{GITHUB_API_URL}/repos/{
|
245
|
+
requests.post(f"{GITHUB_API_URL}/repos/{GITHUB_REPOSITORY}/labels", json=alert_label, headers=GITHUB_HEADERS)
|
249
246
|
|
250
247
|
|
251
248
|
def is_org_member(username: str) -> bool:
|
252
249
|
"""Checks if a user is a member of the organization using the GitHub API."""
|
253
|
-
org_name =
|
250
|
+
org_name = GITHUB_REPOSITORY.split("/")[0]
|
254
251
|
url = f"{GITHUB_API_URL}/orgs/{org_name}/members/{username}"
|
255
252
|
r = requests.get(url, headers=GITHUB_HEADERS)
|
256
253
|
return r.status_code == 204 # 204 means the user is a member
|
@@ -270,7 +267,7 @@ mutation($discussionId: ID!, $body: String!) {
|
|
270
267
|
"""
|
271
268
|
graphql_request(mutation, variables={"discussionId": node_id, "body": comment})
|
272
269
|
else:
|
273
|
-
url = f"{GITHUB_API_URL}/repos/{
|
270
|
+
url = f"{GITHUB_API_URL}/repos/{GITHUB_REPOSITORY}/issues/{number}/comments"
|
274
271
|
r = requests.post(url, json={"body": comment}, headers=GITHUB_HEADERS)
|
275
272
|
print(f"{'Successful' if r.status_code in {200, 201} else 'Fail'} issue/PR #{number} comment: {r.status_code}")
|
276
273
|
|
@@ -278,7 +275,7 @@ mutation($discussionId: ID!, $body: String!) {
|
|
278
275
|
def get_first_interaction_response(issue_type: str, title: str, body: str, username: str, number: int) -> str:
|
279
276
|
"""Generates a custom LLM response for GitHub issues, PRs, or discussions based on content."""
|
280
277
|
issue_discussion_response = f"""
|
281
|
-
👋 Hello @{username}, thank you for submitting a `{
|
278
|
+
👋 Hello @{username}, thank you for submitting a `{GITHUB_REPOSITORY}` 🚀 {issue_type.capitalize()}. To help us address your concern efficiently, please ensure you've provided the following information:
|
282
279
|
|
283
280
|
1. For bug reports:
|
284
281
|
- A clear and concise description of the bug
|
@@ -303,10 +300,10 @@ Thank you for your contribution to improving our project!
|
|
303
300
|
"""
|
304
301
|
|
305
302
|
pr_response = f"""
|
306
|
-
👋 Hello @{username}, thank you for submitting an `{
|
303
|
+
👋 Hello @{username}, thank you for submitting an `{GITHUB_REPOSITORY}` 🚀 PR! To ensure a seamless integration of your work, please review the following checklist:
|
307
304
|
|
308
|
-
- ✅ **Define a Purpose**: Clearly explain the purpose of your fix or feature in your PR description, and link to any [relevant issues](https://github.com/{
|
309
|
-
- ✅ **Synchronize with Source**: Confirm your PR is synchronized with the `{
|
305
|
+
- ✅ **Define a Purpose**: Clearly explain the purpose of your fix or feature in your PR description, and link to any [relevant issues](https://github.com/{GITHUB_REPOSITORY}/issues). Ensure your commit messages are clear, concise, and adhere to the project's conventions.
|
306
|
+
- ✅ **Synchronize with Source**: Confirm your PR is synchronized with the `{GITHUB_REPOSITORY}` `main` branch. If it's behind, update it by clicking the 'Update branch' button or by running `git pull` and `git merge main` locally.
|
310
307
|
- ✅ **Ensure CI Checks Pass**: Verify all Ultralytics [Continuous Integration (CI)](https://docs.ultralytics.com/help/CI/) checks are passing. If any checks fail, please address the issues.
|
311
308
|
- ✅ **Update Documentation**: Update the relevant [documentation](https://docs.ultralytics.com) for any new or modified features.
|
312
309
|
- ✅ **Add Tests**: If applicable, include or update tests to cover your changes, and confirm that all tests are passing.
|
@@ -321,8 +318,8 @@ For more guidance, please refer to our [Contributing Guide](https://docs.ultraly
|
|
321
318
|
else:
|
322
319
|
example = os.getenv("FIRST_ISSUE_RESPONSE") or issue_discussion_response
|
323
320
|
|
324
|
-
org_name, repo_name =
|
325
|
-
repo_url = f"https://github.com/{
|
321
|
+
org_name, repo_name = GITHUB_REPOSITORY.split("/")
|
322
|
+
repo_url = f"https://github.com/{GITHUB_REPOSITORY}"
|
326
323
|
diff = get_pr_diff(number)[:32000] if issue_type == "pull request" else ""
|
327
324
|
|
328
325
|
prompt = f"""Generate a customized response to the new GitHub {issue_type} below:
|
actions/summarize_pr.py
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
# Ultralytics Actions 🚀, AGPL-3.0 license https://ultralytics.com/license
|
2
2
|
|
3
|
+
import time
|
4
|
+
|
3
5
|
import requests
|
4
6
|
|
5
7
|
from .utils import (
|
6
8
|
GITHUB_API_URL,
|
7
9
|
GITHUB_HEADERS,
|
8
|
-
|
9
|
-
|
10
|
+
GITHUB_REPOSITORY,
|
11
|
+
PR,
|
10
12
|
get_completion,
|
11
13
|
get_pr_diff,
|
12
14
|
)
|
@@ -39,24 +41,30 @@ def generate_pr_summary(repo_name, diff_text):
|
|
39
41
|
]
|
40
42
|
reply = get_completion(messages)
|
41
43
|
if len(diff_text) > limit:
|
42
|
-
|
43
|
-
|
44
|
-
return SUMMARY_START + reply
|
44
|
+
reply = "**WARNING ⚠️** this PR is very large, summary may not cover all changes.\n\n" + reply
|
45
|
+
return reply
|
45
46
|
|
46
47
|
|
47
|
-
def update_pr_description(repo_name, pr_number, new_summary):
|
48
|
-
"""Updates
|
49
|
-
# Fetch the current PR description
|
48
|
+
def update_pr_description(repo_name, pr_number, new_summary, max_retries=2):
|
49
|
+
"""Updates PR description with new summary, retrying if description is None."""
|
50
50
|
pr_url = f"{GITHUB_API_URL}/repos/{repo_name}/pulls/{pr_number}"
|
51
|
-
|
52
|
-
|
53
|
-
|
51
|
+
description = ""
|
52
|
+
for i in range(max_retries + 1):
|
53
|
+
description = requests.get(pr_url, headers=GITHUB_HEADERS).json().get("body") or ""
|
54
|
+
if description:
|
55
|
+
break
|
56
|
+
if i < max_retries:
|
57
|
+
print("No current PR description found, retrying...")
|
58
|
+
time.sleep(1)
|
54
59
|
|
55
60
|
# Check if existing summary is present and update accordingly
|
56
|
-
|
57
|
-
|
61
|
+
start = "## 🛠️ PR Summary"
|
62
|
+
if start in description:
|
63
|
+
print("Existing PR Summary found, replacing.")
|
64
|
+
updated_description = description.split(start)[0] + new_summary
|
58
65
|
else:
|
59
|
-
|
66
|
+
print("PR Summary not found, appending.")
|
67
|
+
updated_description = description + "\n\n" + new_summary
|
60
68
|
|
61
69
|
# Update the PR description
|
62
70
|
update_response = requests.patch(pr_url, json={"body": updated_description}, headers=GITHUB_HEADERS)
|
@@ -65,13 +73,18 @@ def update_pr_description(repo_name, pr_number, new_summary):
|
|
65
73
|
|
66
74
|
def main():
|
67
75
|
"""Summarize a pull request and update its description with an AI-generated summary."""
|
68
|
-
|
76
|
+
pr_number = PR["number"]
|
77
|
+
|
78
|
+
print(f"Retrieving diff for PR {pr_number}")
|
79
|
+
diff = get_pr_diff(PR["number"])
|
69
80
|
|
70
81
|
# Generate PR summary
|
71
|
-
|
82
|
+
print("Generating PR summary...")
|
83
|
+
summary = generate_pr_summary(GITHUB_REPOSITORY, diff)
|
72
84
|
|
73
85
|
# Update PR description
|
74
|
-
|
86
|
+
print("Updating PR description...")
|
87
|
+
status_code = update_pr_description(GITHUB_REPOSITORY, pr_number, summary)
|
75
88
|
if status_code == 200:
|
76
89
|
print("PR description updated successfully.")
|
77
90
|
else:
|
actions/summarize_release.py
CHANGED
@@ -12,8 +12,8 @@ from .utils import (
|
|
12
12
|
GITHUB_API_URL,
|
13
13
|
GITHUB_HEADERS,
|
14
14
|
GITHUB_HEADERS_DIFF,
|
15
|
+
GITHUB_REPOSITORY,
|
15
16
|
GITHUB_TOKEN,
|
16
|
-
REPO_NAME,
|
17
17
|
get_completion,
|
18
18
|
remove_html_comments,
|
19
19
|
)
|
@@ -164,14 +164,14 @@ def main():
|
|
164
164
|
previous_tag = PREVIOUS_TAG or get_previous_tag()
|
165
165
|
|
166
166
|
# Get the diff between the tags
|
167
|
-
diff = get_release_diff(
|
167
|
+
diff = get_release_diff(GITHUB_REPOSITORY, previous_tag, CURRENT_TAG)
|
168
168
|
|
169
169
|
# Get PRs merged between the tags
|
170
|
-
prs = get_prs_between_tags(
|
170
|
+
prs = get_prs_between_tags(GITHUB_REPOSITORY, previous_tag, CURRENT_TAG)
|
171
171
|
|
172
172
|
# Generate release summary
|
173
173
|
try:
|
174
|
-
summary = generate_release_summary(diff, prs, CURRENT_TAG, previous_tag,
|
174
|
+
summary = generate_release_summary(diff, prs, CURRENT_TAG, previous_tag, GITHUB_REPOSITORY)
|
175
175
|
except Exception as e:
|
176
176
|
print(f"Failed to generate summary: {str(e)}")
|
177
177
|
summary = "Failed to generate summary."
|
@@ -181,7 +181,7 @@ def main():
|
|
181
181
|
commit_message = subprocess.run(cmd, check=True, text=True, capture_output=True).stdout.split("\n")[0].strip()
|
182
182
|
|
183
183
|
# Create the release on GitHub
|
184
|
-
status_code = create_github_release(
|
184
|
+
status_code = create_github_release(GITHUB_REPOSITORY, CURRENT_TAG, f"{CURRENT_TAG} - {commit_message}", summary)
|
185
185
|
if status_code == 201:
|
186
186
|
print(f"Successfully created release {CURRENT_TAG}")
|
187
187
|
else:
|
actions/utils/__init__.py
CHANGED
@@ -2,29 +2,34 @@
|
|
2
2
|
|
3
3
|
from .common_utils import remove_html_comments
|
4
4
|
from .github_utils import (
|
5
|
+
DISCUSSION,
|
6
|
+
EVENT_DATA,
|
5
7
|
GITHUB_API_URL,
|
6
8
|
GITHUB_EVENT_NAME,
|
7
9
|
GITHUB_EVENT_PATH,
|
8
10
|
GITHUB_HEADERS,
|
9
11
|
GITHUB_HEADERS_DIFF,
|
12
|
+
GITHUB_REPOSITORY,
|
10
13
|
GITHUB_TOKEN,
|
11
|
-
|
12
|
-
REPO_NAME,
|
14
|
+
PR,
|
13
15
|
check_pypi_version,
|
14
16
|
get_github_data,
|
15
17
|
get_pr_diff,
|
16
18
|
graphql_request,
|
19
|
+
ultralytics_actions_info,
|
17
20
|
)
|
18
21
|
from .openai_utils import OPENAI_API_KEY, OPENAI_MODEL, get_completion
|
19
22
|
|
20
23
|
__all__ = (
|
21
24
|
"remove_html_comments",
|
25
|
+
"EVENT_DATA",
|
22
26
|
"GITHUB_API_URL",
|
23
27
|
"GITHUB_HEADERS",
|
24
28
|
"GITHUB_HEADERS_DIFF",
|
25
29
|
"GITHUB_TOKEN",
|
26
|
-
"
|
27
|
-
"
|
30
|
+
"GITHUB_REPOSITORY",
|
31
|
+
"PR",
|
32
|
+
"DISCUSSION",
|
28
33
|
"GITHUB_EVENT_NAME",
|
29
34
|
"GITHUB_EVENT_PATH",
|
30
35
|
"get_github_data",
|
@@ -34,4 +39,5 @@ __all__ = (
|
|
34
39
|
"OPENAI_MODEL",
|
35
40
|
"get_completion",
|
36
41
|
"check_pypi_version",
|
42
|
+
"ultralytics_actions_info",
|
37
43
|
)
|
actions/utils/common_utils.py
CHANGED
@@ -34,6 +34,9 @@ def is_url(url, check=True, max_attempts=3, timeout=2):
|
|
34
34
|
"url",
|
35
35
|
"example",
|
36
36
|
"mailto:",
|
37
|
+
"github.com", # ignore GitHub links that may be private repos
|
38
|
+
"kaggle.com", # blocks automated header requests
|
39
|
+
"reddit.com", # blocks automated header requests
|
37
40
|
)
|
38
41
|
try:
|
39
42
|
# Check allow list
|
@@ -49,7 +52,13 @@ def is_url(url, check=True, max_attempts=3, timeout=2):
|
|
49
52
|
if check:
|
50
53
|
for attempt in range(max_attempts):
|
51
54
|
try:
|
52
|
-
req = urllib.request.Request(
|
55
|
+
req = urllib.request.Request(
|
56
|
+
url,
|
57
|
+
method="HEAD",
|
58
|
+
headers={
|
59
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
|
60
|
+
},
|
61
|
+
)
|
53
62
|
with urllib.request.urlopen(req, timeout=timeout) as response:
|
54
63
|
return response.getcode() < 400
|
55
64
|
except (urllib.error.URLError, socket.timeout):
|
actions/utils/github_utils.py
CHANGED
@@ -1,30 +1,41 @@
|
|
1
1
|
# Ultralytics Actions 🚀, AGPL-3.0 license https://ultralytics.com/license
|
2
|
-
|
2
|
+
import json
|
3
3
|
import os
|
4
|
+
from pathlib import Path
|
4
5
|
|
5
6
|
import requests
|
6
7
|
|
8
|
+
from actions import __version__
|
9
|
+
|
7
10
|
GITHUB_TOKEN = os.getenv("GITHUB_TOKEN")
|
11
|
+
GITHUB_REPOSITORY = os.getenv("GITHUB_REPOSITORY")
|
12
|
+
GITHUB_EVENT_NAME = os.getenv("GITHUB_EVENT_NAME")
|
13
|
+
GITHUB_EVENT_PATH = os.getenv("GITHUB_EVENT_PATH")
|
8
14
|
GITHUB_API_URL = "https://api.github.com"
|
9
15
|
GITHUB_HEADERS = {"Authorization": f"token {GITHUB_TOKEN}", "Accept": "application/vnd.github.v3+json"}
|
10
16
|
GITHUB_HEADERS_DIFF = {"Authorization": f"token {GITHUB_TOKEN}", "Accept": "application/vnd.github.v3.diff"}
|
11
17
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
18
|
+
EVENT_DATA = {}
|
19
|
+
if GITHUB_EVENT_PATH:
|
20
|
+
event_path = Path(GITHUB_EVENT_PATH)
|
21
|
+
if event_path.exists():
|
22
|
+
EVENT_DATA = json.loads(event_path.read_text())
|
23
|
+
PR = EVENT_DATA.get("pull_request", {})
|
24
|
+
DISCUSSION = EVENT_DATA.get("discussion", {})
|
25
|
+
|
26
|
+
INPUTS = {k[6:].lower(): v for k, v in os.environ.items() if k.startswith("INPUT_")} # actions inputs dictionary
|
16
27
|
|
17
28
|
|
18
29
|
def get_pr_diff(pr_number: int) -> str:
|
19
30
|
"""Retrieves the diff content for a specified pull request in a GitHub repository."""
|
20
|
-
url = f"{GITHUB_API_URL}/repos/{
|
31
|
+
url = f"{GITHUB_API_URL}/repos/{GITHUB_REPOSITORY}/pulls/{pr_number}"
|
21
32
|
r = requests.get(url, headers=GITHUB_HEADERS_DIFF)
|
22
33
|
return r.text if r.status_code == 200 else ""
|
23
34
|
|
24
35
|
|
25
36
|
def get_github_data(endpoint: str) -> dict:
|
26
37
|
"""Fetches GitHub repository data from a specified endpoint using the GitHub API."""
|
27
|
-
r = requests.get(f"{GITHUB_API_URL}/repos/{
|
38
|
+
r = requests.get(f"{GITHUB_API_URL}/repos/{GITHUB_REPOSITORY}/{endpoint}", headers=GITHUB_HEADERS)
|
28
39
|
r.raise_for_status()
|
29
40
|
return r.json()
|
30
41
|
|
@@ -85,3 +96,35 @@ def check_pypi_version(pyproject_toml="pyproject.toml"):
|
|
85
96
|
publish = True # publish as this is likely a first release
|
86
97
|
|
87
98
|
return local_version, online_version, publish
|
99
|
+
|
100
|
+
|
101
|
+
def ultralytics_actions_info():
|
102
|
+
"""Print Ultralytics Actions information."""
|
103
|
+
info = {
|
104
|
+
"github.event_name": GITHUB_EVENT_NAME,
|
105
|
+
"github.event.action": EVENT_DATA.get("action"),
|
106
|
+
"github.repository": GITHUB_REPOSITORY,
|
107
|
+
"github.event.pull_request.number": PR.get("number"),
|
108
|
+
"github.event.pull_request.head.repo.full_name": PR.get("head", {}).get("repo", {}).get("full_name"),
|
109
|
+
"github.actor": os.environ.get("GITHUB_ACTOR"),
|
110
|
+
"github.event.pull_request.head.ref": PR.get("head", {}).get("ref"),
|
111
|
+
"github.ref": os.environ.get("GITHUB_REF"),
|
112
|
+
"github.head_ref": os.environ.get("GITHUB_HEAD_REF"),
|
113
|
+
"github.base_ref": os.environ.get("GITHUB_BASE_REF"),
|
114
|
+
}
|
115
|
+
|
116
|
+
if GITHUB_EVENT_NAME == "discussion":
|
117
|
+
info.update(
|
118
|
+
{
|
119
|
+
"github.event.discussion.node_id": DISCUSSION.get("node_id"),
|
120
|
+
"github.event.discussion.number": DISCUSSION.get("number"),
|
121
|
+
}
|
122
|
+
)
|
123
|
+
|
124
|
+
# Print information
|
125
|
+
max_key_length = max(len(key) for key in info.keys())
|
126
|
+
header = f"Ultralytics Actions {__version__} Information " + "-" * 40
|
127
|
+
print(header)
|
128
|
+
for key, value in info.items():
|
129
|
+
print(f"{key:<{max_key_length + 5}}{value}")
|
130
|
+
print("-" * len(header)) # footer
|
actions/utils/openai_utils.py
CHANGED
@@ -8,8 +8,8 @@ import requests
|
|
8
8
|
|
9
9
|
from actions.utils.common_utils import check_links_in_string
|
10
10
|
|
11
|
-
OPENAI_MODEL = os.getenv("OPENAI_MODEL", "gpt-4o")
|
12
11
|
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
|
12
|
+
OPENAI_MODEL = os.getenv("OPENAI_MODEL", "gpt-4o")
|
13
13
|
|
14
14
|
|
15
15
|
def get_completion(
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: ultralytics-actions
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.15
|
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>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
actions/__init__.py,sha256=-twfs7j2m4ct0xLlHB60aH9eWJoaq7i25OfUkFPQ0BE,749
|
2
|
+
actions/first_interaction.py,sha256=cLXo5hmhOgTfk7F9LbGJeRdg6vvrKUe-0taCa_TkpAg,17683
|
3
|
+
actions/summarize_pr.py,sha256=mJTV0VnihAru5PZ7_9jETcDumB5HYt8yfDTZxDrx4yI,3952
|
4
|
+
actions/summarize_release.py,sha256=l8NBdTAXLysfNKl1Kf_1tyuBRmeEBLyzTDXS6s5_eQg,8350
|
5
|
+
actions/update_markdown_code_blocks.py,sha256=WBNcMD_KKsZS-qSPBn6O1G0ggQ_VrT-jTQffbg7xH_M,6369
|
6
|
+
actions/utils/__init__.py,sha256=0vRjFc7i2WOlphuxdUxQo5BuNipgwGw2Bs-fdUBDeUw,973
|
7
|
+
actions/utils/common_utils.py,sha256=XT8GG0SWBtlZLruA0nKrY4AJpkitvPbM8zndE8etuDo,3548
|
8
|
+
actions/utils/github_utils.py,sha256=dnrbU4Z4LJBIOZLCRifZqVfyiOqsJMIHBHOssj-Y2y8,5488
|
9
|
+
actions/utils/openai_utils.py,sha256=SQWOjU3hdfI_0LKb3uqM5pNsoMyE7W0hGxXy7ISk97M,1823
|
10
|
+
ultralytics_actions-0.0.15.dist-info/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
|
11
|
+
ultralytics_actions-0.0.15.dist-info/METADATA,sha256=Fy7Pp6FSDo53-OVfvXgcNZaRqjt1IB53somkaWiuiZ0,10535
|
12
|
+
ultralytics_actions-0.0.15.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
|
13
|
+
ultralytics_actions-0.0.15.dist-info/entry_points.txt,sha256=GowvOFplj0C7JmsjbKcbpgLpdf2r921pcaOQkAHWZRA,378
|
14
|
+
ultralytics_actions-0.0.15.dist-info/top_level.txt,sha256=5apM5x80QlJcGbACn1v3fkmIuL1-XQCKcItJre7w7Tw,8
|
15
|
+
ultralytics_actions-0.0.15.dist-info/RECORD,,
|
{ultralytics_actions-0.0.7.dist-info → ultralytics_actions-0.0.15.dist-info}/entry_points.txt
RENAMED
@@ -1,5 +1,6 @@
|
|
1
1
|
[console_scripts]
|
2
2
|
ultralytics-actions-first-interaction = actions.first_interaction:main
|
3
|
+
ultralytics-actions-info = actions.utils:ultralytics_actions_info
|
3
4
|
ultralytics-actions-summarize-pr = actions.summarize_pr:main
|
4
5
|
ultralytics-actions-summarize-release = actions.summarize_release:main
|
5
6
|
ultralytics-actions-update-markdown-code-blocks = actions.update_markdown_code_blocks:main
|
@@ -1,15 +0,0 @@
|
|
1
|
-
actions/__init__.py,sha256=CGVVuKax1RTt6njhOvvF8wC74JpEIADTWL1M2wlXeeE,748
|
2
|
-
actions/first_interaction.py,sha256=3xGCYjYM0Z8OYfvvHCMTVBevCb8gZV2DtuLaGIQtgIE,17617
|
3
|
-
actions/summarize_pr.py,sha256=5ya-rLD5va-1-AO146ZrgvSIpREZZTCsPY6eMArs8A0,3602
|
4
|
-
actions/summarize_release.py,sha256=Hv8GyIrfUxpia95QRYbYoNBfJ316l9IJdTPQZDIed-k,8310
|
5
|
-
actions/update_markdown_code_blocks.py,sha256=WBNcMD_KKsZS-qSPBn6O1G0ggQ_VrT-jTQffbg7xH_M,6369
|
6
|
-
actions/utils/__init__.py,sha256=WM4ZRt6TLYxD2MHQtWObnIB3PoP8xsT0ToxGidejnJI,841
|
7
|
-
actions/utils/common_utils.py,sha256=zuGKef8po6hW7cQMPlrxhN9uTzoXbEb8feFO0q_mr70,3116
|
8
|
-
actions/utils/github_utils.py,sha256=fBkglc-XTFK6VDPuiwbqDE7iVamuuarE2qak5wx2Nh0,3771
|
9
|
-
actions/utils/openai_utils.py,sha256=P_xyUX9x5rhNUj9kngrCCFrJgloPHe4a1LhRCobB-ig,1823
|
10
|
-
ultralytics_actions-0.0.7.dist-info/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
|
11
|
-
ultralytics_actions-0.0.7.dist-info/METADATA,sha256=UuntvHdlFajNMo_co8OuE4s9pjcC0D4xSpUrVvwsQd4,10534
|
12
|
-
ultralytics_actions-0.0.7.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
|
13
|
-
ultralytics_actions-0.0.7.dist-info/entry_points.txt,sha256=S8UXCzr5pW9tUAPck-gZTfdvX10a-gambB9wmFRWDnw,312
|
14
|
-
ultralytics_actions-0.0.7.dist-info/top_level.txt,sha256=5apM5x80QlJcGbACn1v3fkmIuL1-XQCKcItJre7w7Tw,8
|
15
|
-
ultralytics_actions-0.0.7.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|