Skip to content

Commit 756ff76

Browse files
authored
Merge pull request #1774 from ynput/enhancement/bump-required-launcher
Chore: Bump required AYON launcher
2 parents cd4ba22 + 6f04caa commit 756ff76

5 files changed

Lines changed: 68 additions & 189 deletions

File tree

client/ayon_core/plugins/publish/collect_addons.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import os
44

55
import pyblish.api
6+
import ayon_api
67

78
from ayon_core.lib.ayon_info import (
89
get_settings_variant,
@@ -43,11 +44,14 @@ def process(self, context):
4344
else:
4445
settings_variant = get_settings_variant()
4546

47+
server_version = ayon_api.get_server_version()
48+
4649
ayon_info = get_ayon_info()
4750
launcher_version = ayon_info["ayon_launcher_version"]
4851
launcher_type = ayon_info["version_type"]
4952
lines = [
5053
"Basic AYON information:",
54+
f"AYON server: {server_version}",
5155
f"Bundle: {bundle_name} ({settings_variant})",
5256
f"AYON launcher: {launcher_version} ({launcher_type})",
5357
"Addons:",

client/ayon_core/plugins/publish/integrate_review.py

Lines changed: 32 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,13 @@
22
import time
33

44
import ayon_api
5-
from ayon_api import TransferProgress
6-
from ayon_api.server_api import RequestTypes
75
import pyblish.api
86

97
from ayon_core.lib import get_media_mime_type, format_file_size
108
from ayon_core.pipeline.publish import (
119
PublishXmlValidationError,
1210
get_publish_repre_path,
1311
)
14-
import requests.exceptions
1512

1613

1714
class IntegrateAYONReview(pyblish.api.InstancePlugin):
@@ -34,15 +31,6 @@ def process(self, instance):
3431
self._upload_reviewable(project_name, version_id, instance)
3532

3633
def _upload_reviewable(self, project_name, version_id, instance):
37-
ayon_con = ayon_api.get_server_api_connection()
38-
major, minor, _, _, _ = ayon_con.get_server_version_tuple()
39-
if (major, minor) < (1, 3):
40-
self.log.info(
41-
"Skipping reviewable upload, supported from server 1.3.x."
42-
f" Current server version {ayon_con.get_server_version()}"
43-
)
44-
return
45-
4634
uploaded_labels = set()
4735
for repre in instance.data["representations"]:
4836
repre_tags = repre.get("tags") or []
@@ -73,22 +61,40 @@ def _upload_reviewable(self, project_name, version_id, instance):
7361
continue
7462

7563
label = self._get_review_label(repre, uploaded_labels)
76-
query = ""
77-
if label:
78-
query = f"?label={label}"
7964

80-
endpoint = (
81-
f"/projects/{project_name}"
82-
f"/versions/{version_id}/reviewables{query}"
83-
)
84-
self.log.info(f"Uploading reviewable {repre_path}")
85-
# Upload with retries and clear help if it keeps failing
86-
self._upload_with_retries(
87-
ayon_con,
88-
endpoint,
89-
repre_path,
90-
content_type,
65+
size = os.path.getsize(repre_path)
66+
start = time.time()
67+
self.log.info(
68+
f"Uploading '{repre_path}' (size: {format_file_size(size)})"
9169
)
70+
try:
71+
ayon_api.upload_reviewable(
72+
project_name,
73+
version_id,
74+
repre_path,
75+
content_type=content_type,
76+
label=label,
77+
# Pass headers to fix bug in ayon-api (fixed in 1.2.15)
78+
headers={},
79+
)
80+
except Exception as exc:
81+
self.log.warning(
82+
f"Review upload failed after {time.time() - start}s.",
83+
exc_info=True,
84+
)
85+
raise PublishXmlValidationError(
86+
self,
87+
(
88+
"Upload of reviewable timed out or failed after"
89+
" multiple attempts. Please try publishing again."
90+
),
91+
formatting_data={
92+
"upload_type": "Review",
93+
"file": repre_path,
94+
"error": str(exc),
95+
},
96+
help_filename="upload_file.xml",
97+
)
9298

9399
def _get_review_label(self, repre, uploaded_labels):
94100
# Use output name as label if available
@@ -101,74 +107,3 @@ def _get_review_label(self, repre, uploaded_labels):
101107
idx += 1
102108
label = f"{orig_label}_{idx}"
103109
return label
104-
105-
def _upload_with_retries(
106-
self,
107-
ayon_con: ayon_api.ServerAPI,
108-
endpoint: str,
109-
repre_path: str,
110-
content_type: str,
111-
):
112-
"""Upload file with simple retries."""
113-
filename = os.path.basename(repre_path)
114-
115-
headers = ayon_con.get_headers(content_type)
116-
headers["x-file-name"] = filename
117-
max_retries = ayon_con.get_default_max_retries()
118-
# Retries are already implemented in 'ayon_api.upload_file'
119-
# - added in ayon api 1.2.7
120-
if hasattr(TransferProgress, "get_attempt"):
121-
max_retries = 1
122-
123-
size = os.path.getsize(repre_path)
124-
self.log.info(
125-
f"Uploading '{repre_path}' (size: {format_file_size(size)})"
126-
)
127-
128-
# How long to sleep before next attempt
129-
wait_time = 1
130-
last_error = None
131-
for attempt in range(max_retries):
132-
attempt += 1
133-
start = time.time()
134-
try:
135-
output = ayon_con.upload_file(
136-
endpoint,
137-
repre_path,
138-
headers=headers,
139-
request_type=RequestTypes.post,
140-
)
141-
self.log.debug(f"Uploaded in {time.time() - start}s.")
142-
return output
143-
144-
except (
145-
requests.exceptions.Timeout,
146-
requests.exceptions.ConnectionError
147-
) as exc:
148-
# Log and retry with backoff if attempts remain
149-
if attempt >= max_retries:
150-
last_error = exc
151-
break
152-
153-
self.log.warning(
154-
f"Review upload failed ({attempt}/{max_retries})"
155-
f" after {time.time() - start}s."
156-
f" Retrying in {wait_time}s...",
157-
exc_info=True,
158-
)
159-
time.sleep(wait_time)
160-
161-
# Exhausted retries - raise a user-friendly validation error with help
162-
raise PublishXmlValidationError(
163-
self,
164-
(
165-
"Upload of reviewable timed out or failed after multiple"
166-
" attempts. Please try publishing again."
167-
),
168-
formatting_data={
169-
"upload_type": "Review",
170-
"file": repre_path,
171-
"error": str(last_error),
172-
},
173-
help_filename="upload_file.xml",
174-
)

client/ayon_core/plugins/publish/integrate_thumbnail.py

Lines changed: 31 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,10 @@
2727
import time
2828

2929
import ayon_api
30-
from ayon_api import RequestTypes, TransferProgress
3130
from ayon_api.operations import OperationsSession
3231
import pyblish.api
33-
import requests
3432

35-
from ayon_core.lib import get_media_mime_type, format_file_size
33+
from ayon_core.lib import format_file_size
3634
from ayon_core.pipeline.publish import PublishXmlValidationError
3735

3836

@@ -170,19 +168,40 @@ def _get_instance_thumbnail_path(
170168

171169
def _create_thumbnail(self, project_name: str, src_filepath: str) -> str:
172170
"""Upload thumbnail to AYON and return its id."""
173-
mime_type = get_media_mime_type(src_filepath)
174-
if mime_type is None:
175-
return ayon_api.create_thumbnail(
171+
size = os.path.getsize(src_filepath)
172+
self.log.info(
173+
f"Uploading '{src_filepath}' (size: {format_file_size(size)})"
174+
)
175+
176+
start = time.time()
177+
try:
178+
thubmnail_id = ayon_api.create_thumbnail(
176179
project_name, src_filepath
177180
)
181+
self.log.debug(f"Uploaded in {time.time() - start}s.")
182+
return thubmnail_id
183+
184+
except Exception as exc:
185+
last_error = exc
186+
self.log.warning(
187+
f"Review upload failed after {time.time() - start}s.",
188+
exc_info=True,
189+
)
178190

179-
response = self._upload_with_retries(
180-
f"projects/{project_name}/thumbnails",
181-
src_filepath,
182-
mime_type,
191+
# Exhausted retries - raise a user-friendly validation error with help
192+
raise PublishXmlValidationError(
193+
self,
194+
(
195+
"Upload of thumbnail timed out or failed after multiple"
196+
" attempts. Please try publishing again."
197+
),
198+
formatting_data={
199+
"upload_type": "Thumbnail",
200+
"file": src_filepath,
201+
"error": str(last_error),
202+
},
203+
help_filename="upload_file.xml",
183204
)
184-
response.raise_for_status()
185-
return response.json()["id"]
186205

187206
def _integrate_thumbnails(
188207
self,
@@ -245,71 +264,3 @@ def _get_instance_label(self, instance):
245264
or instance.data.get("name")
246265
or "N/A"
247266
)
248-
249-
def _upload_with_retries(
250-
self,
251-
endpoint: str,
252-
repre_path: str,
253-
content_type: str,
254-
):
255-
"""Upload file with simple retries."""
256-
ayon_con = ayon_api.get_server_api_connection()
257-
headers = ayon_con.get_headers(content_type)
258-
max_retries = ayon_con.get_default_max_retries()
259-
# Retries are already implemented in 'ayon_api.upload_file'
260-
# - added in ayon api 1.2.7
261-
if hasattr(TransferProgress, "get_attempt"):
262-
max_retries = 1
263-
264-
size = os.path.getsize(repre_path)
265-
self.log.info(
266-
f"Uploading '{repre_path}' (size: {format_file_size(size)})"
267-
)
268-
269-
# How long to sleep before next attempt
270-
wait_time = 1
271-
last_error = None
272-
for attempt in range(max_retries):
273-
attempt += 1
274-
start = time.time()
275-
try:
276-
output = ayon_con.upload_file(
277-
endpoint,
278-
repre_path,
279-
headers=headers,
280-
request_type=RequestTypes.post,
281-
)
282-
self.log.debug(f"Uploaded in {time.time() - start}s.")
283-
return output
284-
285-
except (
286-
requests.exceptions.Timeout,
287-
requests.exceptions.ConnectionError
288-
) as exc:
289-
# Log and retry with backoff if attempts remain
290-
if attempt >= max_retries:
291-
last_error = exc
292-
break
293-
294-
self.log.warning(
295-
f"Review upload failed ({attempt}/{max_retries})"
296-
f" after {time.time() - start}s."
297-
f" Retrying in {wait_time}s...",
298-
exc_info=True,
299-
)
300-
time.sleep(wait_time)
301-
302-
# Exhausted retries - raise a user-friendly validation error with help
303-
raise PublishXmlValidationError(
304-
self,
305-
(
306-
"Upload of thumbnail timed out or failed after multiple"
307-
" attempts. Please try publishing again."
308-
),
309-
formatting_data={
310-
"upload_type": "Thumbnail",
311-
"file": repre_path,
312-
"error": str(last_error),
313-
},
314-
help_filename="upload_file.xml",
315-
)

client/ayon_core/settings/lib.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -69,23 +69,12 @@ def _get_addons_settings(
6969

7070

7171
class _AyonSettingsCache:
72-
use_bundles = None
7372
variant = None
7473
addon_versions = CacheItem.create_outdated()
7574
studio_settings = CacheItem.create_outdated()
7675
cache_by_project_name = collections.defaultdict(
7776
CacheItem.create_outdated)
7877

79-
@classmethod
80-
def _use_bundles(cls):
81-
if _AyonSettingsCache.use_bundles is None:
82-
major, minor, _, _, _ = ayon_api.get_server_version_tuple()
83-
use_bundles = True
84-
if (major, minor) < (0, 3):
85-
use_bundles = False
86-
_AyonSettingsCache.use_bundles = use_bundles
87-
return _AyonSettingsCache.use_bundles
88-
8978
@classmethod
9079
def _get_variant(cls):
9180
if _AyonSettingsCache.variant is None:

package.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
project_can_override_addon_version = True
1010

1111
ayon_server_version = ">=1.8.4,<2.0.0"
12-
ayon_launcher_version = ">=1.0.2"
12+
ayon_launcher_version = ">=1.5.3"
1313
ayon_required_addons = {}
1414
ayon_compatible_addons = {
1515
"ayon_third_party": ">=1.3.0",

0 commit comments

Comments
 (0)