ultralytics-actions 0.0.82__py3-none-any.whl → 0.0.84__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 CHANGED
@@ -22,4 +22,4 @@
22
22
  # ├── test_summarize_pr.py
23
23
  # └── ...
24
24
 
25
- __version__ = "0.0.82"
25
+ __version__ = "0.0.84"
actions/utils/__init__.py CHANGED
@@ -8,8 +8,9 @@ from .common_utils import (
8
8
  allow_redirect,
9
9
  remove_html_comments,
10
10
  )
11
- from .github_utils import GITHUB_API_URL, GITHUB_GRAPHQL_URL, Action, check_pypi_version, ultralytics_actions_info
11
+ from .github_utils import GITHUB_API_URL, GITHUB_GRAPHQL_URL, Action, ultralytics_actions_info
12
12
  from .openai_utils import get_completion
13
+ from .version_utils import check_pubdev_version, check_pypi_version
13
14
 
14
15
  __all__ = (
15
16
  "GITHUB_API_URL",
@@ -20,6 +21,7 @@ __all__ = (
20
21
  "REDIRECT_END_IGNORE_LIST",
21
22
  "Action",
22
23
  "allow_redirect",
24
+ "check_pubdev_version",
23
25
  "check_pypi_version",
24
26
  "get_completion",
25
27
  "remove_html_comments",
@@ -115,7 +115,12 @@ class Action:
115
115
  """Retrieves the diff content for a specified pull request."""
116
116
  url = f"{GITHUB_API_URL}/repos/{self.repository}/pulls/{self.pr.get('number')}"
117
117
  response = self.get(url, headers=self.headers_diff)
118
- return response.text if response.status_code == 200 else ""
118
+ if response.status_code == 200:
119
+ return response.text
120
+ elif response.status_code == 406:
121
+ return "**ERROR: DIFF TOO LARGE - PR exceeds GitHub's 20,000 line limit, unable to retrieve diff."
122
+ else:
123
+ return "**ERROR: UNABLE TO RETRIEVE DIFF."
119
124
 
120
125
  def get_repo_data(self, endpoint: str) -> dict:
121
126
  """Fetches repository data from a specified endpoint."""
@@ -185,53 +190,3 @@ class Action:
185
190
  def ultralytics_actions_info():
186
191
  """Return GitHub Actions environment information and configuration details for Ultralytics workflows."""
187
192
  Action().print_info()
188
-
189
-
190
- def check_pypi_version(pyproject_toml="pyproject.toml"):
191
- """Compares local and PyPI package versions to determine if a new version should be published."""
192
- import re
193
-
194
- import tomllib # requires Python>=3.11
195
-
196
- version_pattern = re.compile(r"^\d+\.\d+\.\d+$") # e.g. 0.0.0
197
-
198
- with open(pyproject_toml, "rb") as f:
199
- pyproject = tomllib.load(f)
200
-
201
- package_name = pyproject["project"]["name"]
202
- local_version = pyproject["project"].get("version", "dynamic")
203
-
204
- # If version is dynamic, extract it from the specified file
205
- if local_version == "dynamic":
206
- version_attr = pyproject["tool"]["setuptools"]["dynamic"]["version"]["attr"]
207
- module_path, attr_name = version_attr.rsplit(".", 1)
208
- with open(f"{module_path.replace('.', '/')}/__init__.py") as f:
209
- local_version = next(line.split("=")[1].strip().strip("'\"") for line in f if line.startswith(attr_name))
210
-
211
- print(f"Local Version: {local_version}")
212
- if not bool(version_pattern.match(local_version)):
213
- print("WARNING: Incorrect local version pattern")
214
- return "0.0.0", "0.0.0", False
215
-
216
- # Get online version from PyPI
217
- response = requests.get(f"https://pypi.org/pypi/{package_name}/json")
218
- online_version = response.json()["info"]["version"] if response.status_code == 200 else None
219
- print(f"Online Version: {online_version or 'Not Found'}")
220
-
221
- # Determine if a new version should be published
222
- if online_version:
223
- local_ver = tuple(map(int, local_version.split(".")))
224
- online_ver = tuple(map(int, online_version.split(".")))
225
- major_diff = local_ver[0] - online_ver[0]
226
- minor_diff = local_ver[1] - online_ver[1]
227
- patch_diff = local_ver[2] - online_ver[2]
228
-
229
- publish = (
230
- (major_diff == 0 and minor_diff == 0 and 0 < patch_diff <= 2)
231
- or (major_diff == 0 and minor_diff == 1 and local_ver[2] == 0)
232
- or (major_diff == 1 and local_ver[1] == 0 and local_ver[2] == 0)
233
- ) # should publish an update
234
- else:
235
- publish = True # publish as this is likely a first release
236
-
237
- return local_version, online_version, publish
@@ -0,0 +1,70 @@
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ # from actions.utils.version_utils import check_pypi_version
4
+ # check_pypi_version()
5
+
6
+ import re
7
+ from pathlib import Path
8
+
9
+ import requests
10
+ import tomllib
11
+
12
+
13
+ def should_publish(local_version, remote_version):
14
+ """Determine if version should be published based on semver rules."""
15
+ if remote_version:
16
+ local_ver, remote_ver = [tuple(map(int, v.split("."))) for v in [local_version, remote_version]]
17
+ major_diff, minor_diff, patch_diff = [l - r for l, r in zip(local_ver, remote_ver)]
18
+ return (
19
+ (major_diff == 0 and minor_diff == 0 and 0 < patch_diff <= 2) # patch diff <=2
20
+ or (major_diff == 0 and minor_diff == 1 and local_ver[2] == 0) # new minor version
21
+ or (major_diff == 1 and local_ver[1] == 0 and local_ver[2] == 0) # new major version
22
+ ) # should publish an update
23
+ else:
24
+ return True # possible first release
25
+
26
+
27
+ def check_pypi_version(pyproject_toml="pyproject.toml"):
28
+ """Compare local and PyPI package versions to determine if a new version should be published."""
29
+ with open(pyproject_toml, "rb") as f:
30
+ pyproject = tomllib.load(f)
31
+
32
+ package_name = pyproject["project"]["name"]
33
+ local_version = pyproject["project"].get("version", "dynamic")
34
+
35
+ if local_version == "dynamic":
36
+ attr = pyproject["tool"]["setuptools"]["dynamic"]["version"]["attr"]
37
+ module_path, attr_name = attr.rsplit(".", 1)
38
+ init_file = Path(module_path.replace(".", "/")) / "__init__.py"
39
+ local_version = next(
40
+ line.split("=")[1].strip().strip("'\"")
41
+ for line in init_file.read_text().splitlines()
42
+ if line.startswith(attr_name)
43
+ )
44
+
45
+ if not re.match(r"^\d+\.\d+\.\d+$", local_version):
46
+ print(f"WARNING: Incorrect version pattern: {local_version}")
47
+ return local_version, None, False
48
+
49
+ response = requests.get(f"https://pypi.org/pypi/{package_name}/json")
50
+ remote_version = response.json()["info"]["version"] if response.status_code == 200 else None
51
+ print(f"Local: {local_version}, PyPI: {remote_version or 'Not Found'}")
52
+
53
+ return local_version, remote_version, should_publish(local_version, remote_version)
54
+
55
+
56
+ def check_pubdev_version(pubspec_yaml="pubspec.yaml"):
57
+ """Compare local and pub.dev package versions to determine if a new version should be published."""
58
+ content = Path(pubspec_yaml).read_text()
59
+ package_name = re.search(r"^name:\s*(.+)$", content, re.MULTILINE).group(1).strip()
60
+ local_version = re.search(r"^version:\s*(.+)$", content, re.MULTILINE).group(1).strip()
61
+
62
+ if not re.match(r"^\d+\.\d+\.\d+$", local_version):
63
+ print(f"WARNING: Incorrect version pattern: {local_version}")
64
+ return local_version, None, False
65
+
66
+ response = requests.get(f"https://pub.dev/api/packages/{package_name}")
67
+ remote_version = response.json()["latest"]["version"] if response.status_code == 200 else None
68
+ print(f"Local: {local_version}, pub.dev: {remote_version or 'Not Found'}")
69
+
70
+ return local_version, remote_version, should_publish(local_version, remote_version)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ultralytics-actions
3
- Version: 0.0.82
3
+ Version: 0.0.84
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,17 +1,18 @@
1
- actions/__init__.py,sha256=eqqnK5wP34xnJW8-UHpug7HwANfVZFBe7m38uZliq5g,742
1
+ actions/__init__.py,sha256=Z5WUMTbBJ3h5WEoPBA-lyplNH4NIRfOdyqwegOy3Yi0,742
2
2
  actions/dispatch_actions.py,sha256=vbA4w_B8vMXMen__ck2WoDsUFCELjXOQbpLzZCmqTXg,4240
3
3
  actions/first_interaction.py,sha256=whphdBrWkcWRt6RgOeK2dUoGq3aBTqttQdokxVjkye4,16309
4
4
  actions/summarize_pr.py,sha256=NCaDSbw4PVoRbPJzji_Ua2HadI2pn7QOE_dy3VK9_cc,10463
5
5
  actions/summarize_release.py,sha256=OncODHx7XsmB-nPf-B1tnxUTcaJx6hM4JAMa9frypzM,7922
6
6
  actions/update_file_headers.py,sha256=dAu8RWOn-CkuFZHa5LT1-BvNxYX4FRQe2B1UDAjvG3I,6648
7
7
  actions/update_markdown_code_blocks.py,sha256=9PL7YIQfApRNAa0que2hYHv7umGZTZoHlblesB0xFj4,8587
8
- actions/utils/__init__.py,sha256=TXYvhFgDeAnosePM4jfOrEd6PlC7tWC-WMOgCB_T6Tw,728
8
+ actions/utils/__init__.py,sha256=7k4cmFX0Td99Uzgsd8Mm-E0xq5kQ5ZJoPM_oGCVD4CU,804
9
9
  actions/utils/common_utils.py,sha256=2eNwGJFigl9bBXcyWzdr8mr97Lrx7zFKWIFYugZcUJw,11736
10
- actions/utils/github_utils.py,sha256=gdObDzOGmoLl8LXJ-fza7Dr2qLKfDsX2HbpcyFBEMtE,10097
10
+ actions/utils/github_utils.py,sha256=JQivk6IW2UBeHGx7adIuWjId7D03AWziF6fOfG-Ad6A,8171
11
11
  actions/utils/openai_utils.py,sha256=09kW4K2LOc6KsWz5tijf2Piinhu3PIKPDVkRC3KyIxU,2943
12
- ultralytics_actions-0.0.82.dist-info/licenses/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
13
- ultralytics_actions-0.0.82.dist-info/METADATA,sha256=wDjVgIAJ4DIum6Tnfnk2ftzXY1iZspXBBLktB3-o6gY,11638
14
- ultralytics_actions-0.0.82.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
15
- ultralytics_actions-0.0.82.dist-info/entry_points.txt,sha256=rvqr6Juj7lCJL1DQLwMmOrA8R2Q8tyR_dvCe0mYuJ8s,441
16
- ultralytics_actions-0.0.82.dist-info/top_level.txt,sha256=5apM5x80QlJcGbACn1v3fkmIuL1-XQCKcItJre7w7Tw,8
17
- ultralytics_actions-0.0.82.dist-info/RECORD,,
12
+ actions/utils/version_utils.py,sha256=oCFPrdzzzkORaT02JAfb9GcPFOIncTU1v_AXAfR8W6I,3157
13
+ ultralytics_actions-0.0.84.dist-info/licenses/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
14
+ ultralytics_actions-0.0.84.dist-info/METADATA,sha256=3ifMiF4wPn5FGY2OpOdnucXZdE8PUFGZhA2AfXkZZSo,11638
15
+ ultralytics_actions-0.0.84.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
16
+ ultralytics_actions-0.0.84.dist-info/entry_points.txt,sha256=rvqr6Juj7lCJL1DQLwMmOrA8R2Q8tyR_dvCe0mYuJ8s,441
17
+ ultralytics_actions-0.0.84.dist-info/top_level.txt,sha256=5apM5x80QlJcGbACn1v3fkmIuL1-XQCKcItJre7w7Tw,8
18
+ ultralytics_actions-0.0.84.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.7.1)
2
+ Generator: setuptools (80.8.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5