Skip to content

Commit

Permalink
Handle non-existing retries within Session object (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
fatihkurtoglu authored Jun 4, 2024
1 parent aea93db commit 7fc823d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion scaleapi/_version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = "2.15.6"
__version__ = "2.15.7"
__package_name__ = "scaleapi"
11 changes: 7 additions & 4 deletions scaleapi/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,10 @@ def _api_request(
# Some endpoints only return 'OK' message without JSON
return json
elif res.status_code == 409 and "task" in endpoint and body.get("unique_id"):
retry_history = res.raw.retries.history
retry_history = None
if "retries" in res.raw and "history" in res.raw.retries:
retry_history = res.raw.retries.history

# Example RequestHistory tuple
# RequestHistory(method='POST',
# url='/v1/task/imageannotation',
Expand Down Expand Up @@ -184,9 +187,9 @@ def post_request(self, endpoint, body=None, files=None, data=None):
return self._api_request(
"POST",
endpoint,
headers=self._headers
if files is None
else self._headers_multipart_form_data,
headers=(
self._headers if files is None else self._headers_multipart_form_data
),
auth=self._auth,
body=body,
files=files,
Expand Down

0 comments on commit 7fc823d

Please sign in to comment.