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._requires_authorization = True
|
||||||
self._host = host
|
self._host = host
|
||||||
self._auth_cookie = auth_cookie
|
self._auth_cookie = auth_cookie
|
||||||
|
self._json_flags = {}
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def id(self):
|
def id(self):
|
||||||
@ -579,6 +580,10 @@ class APICall(DataContainer):
|
|||||||
def auth_cookie(self):
|
def auth_cookie(self):
|
||||||
return self._auth_cookie
|
return self._auth_cookie
|
||||||
|
|
||||||
|
@property
|
||||||
|
def json_flags(self):
|
||||||
|
return self._json_flags
|
||||||
|
|
||||||
def mark_end(self):
|
def mark_end(self):
|
||||||
self._end_ts = time.time()
|
self._end_ts = time.time()
|
||||||
self._duration = int((self._end_ts - self._start_ts) * 1000)
|
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:
|
if self.content_type.lower() == JSON_CONTENT_TYPE:
|
||||||
try:
|
try:
|
||||||
res = json.dumps(res)
|
res = json.dumps(res, **(self._json_flags or {}))
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
# JSON serialization may fail, probably problem with data or error_data so pop it and try again
|
# 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):
|
if not (self.result.data or self.result.error_data):
|
||||||
|
Loading…
Reference in New Issue
Block a user