-
Notifications
You must be signed in to change notification settings - Fork 33
False 500 testing #57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+20
−1
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b2fbbcc
push wip code for handling false 500s
kevin-xu-scale eca2153
query task response via uuid
kevin-xu-scale bfe891a
cleaning up, remove print statements
kevin-xu-scale 244245c
raise 409 error when retry history is empty
kevin-xu-scale 1740d96
small changes
jonathanfeng-scale 51c18a3
Update api.py
jonathanfeng-scale 5141ff2
more formatting
jonathanfeng-scale f994a6e
Update api.py
jonathanfeng-scale b485dbf
fomatting
jonathanfeng-scale File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -109,9 +109,28 @@ def _api_request( | |
json = None | ||
if res.status_code == 200: | ||
json = res.json() | ||
elif res.status_code == 409 and "task" in endpoint and body.get("unique_id"): | ||
retry_history = res.raw.retries.history | ||
# Example RequestHistory tuple | ||
# RequestHistory(method='POST', | ||
# url='/v1/task/imageannotation', | ||
# error=None, | ||
# status=409, | ||
# redirect_location=None) | ||
if retry_history != (): | ||
# See if the first retry was a 500 error | ||
if retry_history[0][3] == 500: | ||
uuid = body["unique_id"] | ||
newUrl = f"{self.base_api_url}/tasks?unique_id={uuid}" | ||
# grab task from api | ||
newRes = self._http_request( | ||
"GET", newUrl, headers=headers, auth=auth | ||
) | ||
json = newRes.json()["docs"][0] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To confirm, will this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yep |
||
else: | ||
self._raise_on_respose(res) | ||
else: | ||
self._raise_on_respose(res) | ||
|
||
return json | ||
|
||
def get_request(self, endpoint, params=None): | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to confirm (since I'm not super sure) but is
500
the only error returned from our API for those race conditions? (and not other 5xx errors).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, the exact error is task creation taking longer than our timeout, so Scale sends a 500 back in the response