Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions deepomatic/api/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def __init__(self, task):
self.task = task

def __str__(self):
return "Error on task:\n{}".format(json.dumps(self.task))
return "Error on task: {}".format(json.dumps(self.task))

def get_task_id(self):
return self.task['id']
Expand All @@ -108,7 +108,7 @@ def __init__(self, task, retry_error=None):
self.retry_error = retry_error

def __str__(self):
return "Timeout on task:\n{}".format(json.dumps(self.task))
return "Timeout on task: {}".format(json.dumps(self.task))

def get_task_id(self):
return self.task['id']
Expand Down
2 changes: 1 addition & 1 deletion deepomatic/api/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def __repr__(self):
pk = 'id={pk} '.format(pk=self._pk) if self._pk else ''
string = '<{classname} object {pk}at {addr}>'.format(classname=self.__class__.__name__, pk=pk, addr=hex(id(self)))
if self._data is not None:
string += ' JSON: ' + json.dumps(self._data, indent=4, separators=(',', ': '))
string += ' JSON: ' + json.dumps(self._data)
return string

@classmethod
Expand Down
10 changes: 9 additions & 1 deletion tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import requests
import six
from deepomatic.api.client import Client
from deepomatic.api.exceptions import ServerError, ClientError, TaskTimeout, HTTPRetryError, TaskRetryError
from deepomatic.api.exceptions import ServerError, ClientError, TaskError, TaskTimeout, HTTPRetryError, TaskRetryError
from deepomatic.api.http_retry import HTTPRetry
from deepomatic.api.inputs import ImageInput
from deepomatic.api.version import __title__, __version__
Expand Down Expand Up @@ -301,6 +301,14 @@ def test_batch_wait(self, client):
assert(tasks[pos].pk == success.pk)
assert inference_schema(2, 0, 'golden retriever', 0.8) == success['data']

# Task* str(): oneliners (easier to parse in log tooling)
task = success_tasks[0][1]
task_error = TaskError(task._data)
task_timeout = TaskTimeout(task._data)
assert '\n' not in str(task)
assert '\n' not in str(task_error)
assert '\n' not in str(task_timeout)

def test_client_error(self, client):
spec = client.RecognitionSpec.retrieve('imagenet-inception-v3')
with pytest.raises(ClientError) as exc:
Expand Down