mirror of
https://github.com/clearml/clearml-server
synced 2025-01-31 10:56:48 +00:00
Add JSON flags support to APICall
This commit is contained in:
parent
3a3b57c15f
commit
54326f707b
@ -387,6 +387,7 @@ class APICall(DataContainer):
|
||||
self._requires_authorization = True
|
||||
self._host = host
|
||||
self._auth_cookie = auth_cookie
|
||||
self._json_flags = {}
|
||||
|
||||
@property
|
||||
def id(self):
|
||||
@ -579,6 +580,10 @@ class APICall(DataContainer):
|
||||
def auth_cookie(self):
|
||||
return self._auth_cookie
|
||||
|
||||
@property
|
||||
def json_flags(self):
|
||||
return self._json_flags
|
||||
|
||||
def mark_end(self):
|
||||
self._end_ts = time.time()
|
||||
self._duration = int((self._end_ts - self._start_ts) * 1000)
|
||||
@ -629,7 +634,7 @@ class APICall(DataContainer):
|
||||
}
|
||||
if self.content_type.lower() == JSON_CONTENT_TYPE:
|
||||
try:
|
||||
res = json.dumps(res)
|
||||
res = json.dumps(res, **(self._json_flags or {}))
|
||||
except Exception as ex:
|
||||
# JSON serialization may fail, probably problem with data or error_data so pop it and try again
|
||||
if not (self.result.data or self.result.error_data):
|
||||
|
Loading…
Reference in New Issue
Block a user