Skip to content

Commit cb029db

Browse files
author
Brady Endres
committed
use async for flattened sketches
1 parent 5d32a76 commit cb029db

File tree

9 files changed

+102
-18
lines changed

9 files changed

+102
-18
lines changed

__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# @Author: Philip Floetotto
33
# @Date: 2015-06-07 10:01:57
44
# @Last Modified by: Brady Endres
5-
# @Last Modified time: 2025-04-01
5+
# @Last Modified time: 2025-07-07
66

77
"""
88
SyncSketch Python API

build/lib/syncsketch/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
# @Author: yafes
33
# @Date: 2018-11-20 17:39:54
44
# @Last Modified by: Brady Endres
5-
# @Last Modified time: 2025-04-01
5+
# @Last Modified time: 2025-07-07
66

77
from __future__ import absolute_import
88

99
from .syncsketch import SyncSketchAPI
1010

11-
__version__ = "1.0.11.1"
11+
__version__ = "1.0.11.2"
1212
__author__ = "SyncSketch Dev Team"
1313
__credits__ = "Philip Floetotto, Yafes Sahin, Brady Endres, Eric Palakovich Carr"

build/lib/syncsketch/syncsketch.py

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# @Author: floepi
33
# @Date: 2015-06-04 17:42:44
44
# @Last Modified by: Brady Endres
5-
# @Last Modified time: 2025-04-01
5+
# @Last Modified time: 2025-07-07
66

77
from __future__ import absolute_import, division, print_function
88

@@ -154,6 +154,9 @@ def join_url_path(base, *path_segments):
154154
return "/".join(path_segments)
155155

156156
def _get_unversioned_api_url(self, path):
157+
if "http" in path:
158+
# If the path is already a full URL, return it as is
159+
return path
157160
return self.join_url_path(self.HOST, path)
158161

159162
def _get_json_response(
@@ -1628,16 +1631,48 @@ def get_flattened_annotations(
16281631
:param bool raw_response: Get whole response from REST API.
16291632
:return: List of sketches as signed urls from s3 or base64 encoded strings
16301633
"""
1631-
getData = {
1634+
get_data = {
16321635
"include_data": 1,
16331636
"tracingpaper": 1 if with_tracing_paper else 0,
16341637
"base64": 1 if return_as_base64 else 0,
1635-
"async": 0,
1638+
"async": 1,
16361639
}
1640+
get_data.update(self.api_params)
16371641

1638-
url = "/api/v2/downloads/flattenedSketches/{}/{}/".format(review_id, item_id)
1642+
url = "{}/api/v2/downloads/flattenedSketches/{}/{}/".format(self.HOST, review_id, item_id)
16391643

1640-
return self._get_json_response(url, method="post", getData=getData, raw_response=raw_response)
1644+
r = requests.post(url, params=get_data, headers=self.headers)
1645+
celery_task_id = r.json()
1646+
1647+
if self.debug:
1648+
print("Flattened annotations download started with celery task ID: %s", celery_task_id)
1649+
1650+
# check the celery task
1651+
request_processing = True
1652+
check_celery_url = "{host}/api/v2/downloads/flattenedSketches/{celery_task_id}/".format(
1653+
host=self.HOST, celery_task_id=celery_task_id
1654+
)
1655+
1656+
r = requests.get(check_celery_url, params=self.api_params, headers=self.headers)
1657+
1658+
while request_processing:
1659+
if self.debug:
1660+
print("Checking celery task status at: %s" % check_celery_url)
1661+
1662+
result = r.json()
1663+
1664+
if result.get("status") == "done":
1665+
return result
1666+
1667+
if result.get("status") == "failed":
1668+
return None
1669+
1670+
# wait a bit
1671+
time.sleep(1)
1672+
1673+
# check the url again
1674+
r = requests.get(check_celery_url, params=self.api_params, headers=self.headers)
1675+
return
16411676

16421677
def get_grease_pencil_overlays(self, review_id, item_id, homedir=None):
16431678
"""
@@ -1665,6 +1700,9 @@ def get_grease_pencil_overlays(self, review_id, item_id, homedir=None):
16651700
r = requests.post(url, params=self.api_params, headers=self.headers)
16661701
celery_task_id = r.json()
16671702

1703+
if self.debug:
1704+
print("Grease Pencil download started with celery task ID: %s", celery_task_id)
1705+
16681706
# check the celery task
16691707
request_processing = True
16701708
check_celery_url = "%s/api/v2/downloads/greasePencil/%s/" % (
@@ -1675,6 +1713,9 @@ def get_grease_pencil_overlays(self, review_id, item_id, homedir=None):
16751713
r = requests.get(check_celery_url, params=self.api_params, headers=self.headers)
16761714

16771715
while request_processing:
1716+
if self.debug:
1717+
print("Checking celery task status at: %s" % check_celery_url)
1718+
16781719
result = r.json()
16791720

16801721
if result.get("status") == "done":
@@ -1702,6 +1743,7 @@ def get_grease_pencil_overlays(self, review_id, item_id, homedir=None):
17021743

17031744
# check the url again
17041745
r = requests.get(check_celery_url, params=self.api_params, headers=self.headers)
1746+
return
17051747

17061748
"""
17071749
Users
20.4 KB
Binary file not shown.

dist/syncsketch-1.0.11.2.tar.gz

22.5 KB
Binary file not shown.

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# @Author: yafes
22
# @Date: 2018-11-20 17:36:16
33
# @Last Modified by: Brady Endres
4-
# @Last Modified time: 2025-04-01
4+
# @Last Modified time: 2025-07-07
55

66
from setuptools import setup, find_packages
77

@@ -10,7 +10,7 @@
1010

1111
setup(
1212
name="syncsketch",
13-
version="1.0.11.1",
13+
version="1.0.11.2",
1414
description="SyncSketch Python API",
1515
author="Philip Floetotto",
1616
author_email="phil@syncsketch.com",

syncsketch.egg-info/PKG-INFO

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Metadata-Version: 2.2
22
Name: syncsketch
3-
Version: 1.0.11.1
3+
Version: 1.0.11.2
44
Summary: SyncSketch Python API
55
Home-page: https://github.com/syncsketch/python-api
66
Author: Philip Floetotto

syncsketch/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
# @Author: yafes
33
# @Date: 2018-11-20 17:39:54
44
# @Last Modified by: Brady Endres
5-
# @Last Modified time: 2025-04-01
5+
# @Last Modified time: 2025-07-07
66

77
from __future__ import absolute_import
88

99
from .syncsketch import SyncSketchAPI
1010

11-
__version__ = "1.0.11.1"
11+
__version__ = "1.0.11.2"
1212
__author__ = "SyncSketch Dev Team"
1313
__credits__ = "Philip Floetotto, Yafes Sahin, Brady Endres, Eric Palakovich Carr"

syncsketch/syncsketch.py

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# @Author: floepi
33
# @Date: 2015-06-04 17:42:44
44
# @Last Modified by: Brady Endres
5-
# @Last Modified time: 2025-04-01
5+
# @Last Modified time: 2025-07-07
66

77
from __future__ import absolute_import, division, print_function
88

@@ -154,6 +154,9 @@ def join_url_path(base, *path_segments):
154154
return "/".join(path_segments)
155155

156156
def _get_unversioned_api_url(self, path):
157+
if "http" in path:
158+
# If the path is already a full URL, return it as is
159+
return path
157160
return self.join_url_path(self.HOST, path)
158161

159162
def _get_json_response(
@@ -1628,16 +1631,48 @@ def get_flattened_annotations(
16281631
:param bool raw_response: Get whole response from REST API.
16291632
:return: List of sketches as signed urls from s3 or base64 encoded strings
16301633
"""
1631-
getData = {
1634+
get_data = {
16321635
"include_data": 1,
16331636
"tracingpaper": 1 if with_tracing_paper else 0,
16341637
"base64": 1 if return_as_base64 else 0,
1635-
"async": 0,
1638+
"async": 1,
16361639
}
1640+
get_data.update(self.api_params)
16371641

1638-
url = "/api/v2/downloads/flattenedSketches/{}/{}/".format(review_id, item_id)
1642+
url = "{}/api/v2/downloads/flattenedSketches/{}/{}/".format(self.HOST, review_id, item_id)
16391643

1640-
return self._get_json_response(url, method="post", getData=getData, raw_response=raw_response)
1644+
r = requests.post(url, params=get_data, headers=self.headers)
1645+
celery_task_id = r.json()
1646+
1647+
if self.debug:
1648+
print("Flattened annotations download started with celery task ID: %s", celery_task_id)
1649+
1650+
# check the celery task
1651+
request_processing = True
1652+
check_celery_url = "{host}/api/v2/downloads/flattenedSketches/{celery_task_id}/".format(
1653+
host=self.HOST, celery_task_id=celery_task_id
1654+
)
1655+
1656+
r = requests.get(check_celery_url, params=self.api_params, headers=self.headers)
1657+
1658+
while request_processing:
1659+
if self.debug:
1660+
print("Checking celery task status at: %s" % check_celery_url)
1661+
1662+
result = r.json()
1663+
1664+
if result.get("status") == "done":
1665+
return result
1666+
1667+
if result.get("status") == "failed":
1668+
return None
1669+
1670+
# wait a bit
1671+
time.sleep(1)
1672+
1673+
# check the url again
1674+
r = requests.get(check_celery_url, params=self.api_params, headers=self.headers)
1675+
return
16411676

16421677
def get_grease_pencil_overlays(self, review_id, item_id, homedir=None):
16431678
"""
@@ -1665,6 +1700,9 @@ def get_grease_pencil_overlays(self, review_id, item_id, homedir=None):
16651700
r = requests.post(url, params=self.api_params, headers=self.headers)
16661701
celery_task_id = r.json()
16671702

1703+
if self.debug:
1704+
print("Grease Pencil download started with celery task ID: %s", celery_task_id)
1705+
16681706
# check the celery task
16691707
request_processing = True
16701708
check_celery_url = "%s/api/v2/downloads/greasePencil/%s/" % (
@@ -1675,6 +1713,9 @@ def get_grease_pencil_overlays(self, review_id, item_id, homedir=None):
16751713
r = requests.get(check_celery_url, params=self.api_params, headers=self.headers)
16761714

16771715
while request_processing:
1716+
if self.debug:
1717+
print("Checking celery task status at: %s" % check_celery_url)
1718+
16781719
result = r.json()
16791720

16801721
if result.get("status") == "done":
@@ -1702,6 +1743,7 @@ def get_grease_pencil_overlays(self, review_id, item_id, homedir=None):
17021743

17031744
# check the url again
17041745
r = requests.get(check_celery_url, params=self.api_params, headers=self.headers)
1746+
return
17051747

17061748
"""
17071749
Users

0 commit comments

Comments
 (0)