Fix sending empty reports, issue #205

This commit is contained in:
allegroai 2020-09-09 22:09:49 +03:00
parent f4917572bb
commit 299ce14515
2 changed files with 11 additions and 9 deletions

View File

@ -314,6 +314,7 @@ class Metrics(InterfaceBase):
except Exception as ex: except Exception as ex:
warning('Failed reporting metric, line {} [{}]'.format(i, ex)) warning('Failed reporting metric, line {} [{}]'.format(i, ex))
batch_requests = api_events.AddBatchRequest(requests=list_requests) batch_requests = api_events.AddBatchRequest(requests=list_requests)
if batch_requests.requests:
res = task.session.send(batch_requests) res = task.session.send(batch_requests)
if res and not res.ok(): if res and not res.ok():
warning("failed logging metric task to backend ({:d} lines, {})".format( warning("failed logging metric task to backend ({:d} lines, {})".format(

View File

@ -151,7 +151,7 @@ class TaskHandler(BufferingHandler):
self.__log_stderr("WARNING: trains.log - Failed logging task to backend ({:d} lines)".format(len(buffer))) self.__log_stderr("WARNING: trains.log - Failed logging task to backend ({:d} lines)".format(len(buffer)))
batch_requests = None batch_requests = None
if batch_requests: if batch_requests and batch_requests.requests:
self._pending += 1 self._pending += 1
self._add_to_queue(batch_requests) self._add_to_queue(batch_requests)
@ -276,6 +276,7 @@ class TaskHandler(BufferingHandler):
warning('Failed reporting log, line {} [{}]'.format(i, ex)) warning('Failed reporting log, line {} [{}]'.format(i, ex))
batch_requests = events.AddBatchRequest( batch_requests = events.AddBatchRequest(
requests=[events.TaskLogEvent(task=task.id, **r) for r in list_requests]) requests=[events.TaskLogEvent(task=task.id, **r) for r in list_requests])
if batch_requests.requests:
res = task.session.send(batch_requests) res = task.session.send(batch_requests)
if res and not res.ok(): if res and not res.ok():
warning("failed logging task to backend ({:d} lines, {})".format( warning("failed logging task to backend ({:d} lines, {})".format(