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
77from __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