Skip to content

Commit 196a1ca

Browse files
author
Dario Varotto
committed
Merge branch 'TA-1188_use_status_endpoint' into 'master'
Switching get_status method to use new status endpoint which should be faster See merge request python/ravenpack-api!2
2 parents 36da18b + c049bfa commit 196a1ca

File tree

4 files changed

+25
-4
lines changed

4 files changed

+25
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## v1.0.56 (2021-11-04)
4+
5+
Internal changes to speed up get_status and wait_for_completion file methods
6+
37
## v1.0.53 (2021-08-26)
48

59
Product aware instance: allows to access edge just instanciating your api with

ravenpackapi/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from ravenpackapi.utils.dynamic_sessions import DynamicSession
1616

1717
_VALID_METHODS = ('get', 'post', 'put', 'delete', 'patch')
18-
VERSION = '1.0.55'
18+
VERSION = '1.0.56'
1919

2020
logger = logging.getLogger("ravenpack.core")
2121

ravenpackapi/upload/models.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from time import sleep
22

3-
from ravenpackapi.exceptions import api_method
3+
from ravenpackapi.exceptions import api_method, APIException
44
from ravenpackapi.upload.upload_utils import retry_on_too_early
55

66
FILE_FIELDS = (
@@ -46,7 +46,24 @@ def __str__(self):
4646

4747
@api_method
4848
def get_status(self):
49-
self.get_metadata(force_refresh=True)
49+
response = retry_on_too_early(
50+
self.api.request,
51+
'%s/files/%s/status' % (self.api._UPLOAD_BASE_URL, self.file_id)
52+
)
53+
api_status = response.json()
54+
response.raise_for_status()
55+
56+
self.status = None
57+
if api_status.get('error'):
58+
raise APIException(
59+
'Got an error {status}: body was \'{error_message}\''.format(
60+
status=response.status_code,
61+
error_message=api_status['error']
62+
), response=response
63+
)
64+
if api_status.get('status'):
65+
self.status = api_status['status']
66+
5067
return self.status
5168

5269
@api_method

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from setuptools import setup, find_packages
22

3-
VERSION = '1.0.55'
3+
VERSION = '1.0.56'
44

55
with open('README.rst') as readme_file:
66
readme = readme_file.read()

0 commit comments

Comments
 (0)