Deepomatic / deepomatic-client-python

Python Client
Other
14 stars 0 forks source link

Normalize str and repr, notably in Task* #73

Open thomas-riccardi opened 4 years ago

thomas-riccardi commented 4 years ago

Currently we have very similar str and repr, notably for Task exceptions:

(Pdb) repr(task_timeout)
"TaskTimeout({'id': '348848920', 'status': 'success', 'error': None, 'date_created': '2019-10-22T12:03:16.413978+02:00', 'date_updated': '2019-10-22T12:03:16.546879+02:00', 'data': {'outputs': [{'labels': {'discarded': [], 'predicted': [{'score': 0.808144927, 'label_id': 207, 'threshold': 0.025, 'label_name': 'golden retriever'}, {'score': 0.0409193039, 'label_id': 257, 'threshold': 0.025, 'label_name': 'Great Pyrenees'}]}}]}, 'subtasks': None},)"
(Pdb) str(task_timeout)
'Timeout on task: {"id": "348848920", "status": "success", "error": null, "date_created": "2019-10-22T12:03:16.413978+02:00", "date_updated": "2019-10-22T12:03:16.546879+02:00", "data": {"outputs": [{"labels": {"discarded": [], "predicted": [{"score": 0.808144927, "label_id": 207, "threshold": 0.025, "label_name": "golden retriever"}, {"score": 0.0409193039, "label_id": 257, "threshold": 0.025, "label_name": "Great Pyrenees"}]}}]}, "subtasks": null}'

It may be better to log less things in str: maybe just the task id, status and error?

For Task we should maybe do the same: implement a shorter str.

The issue is probably the same for other resources.