Пример #1
0
    def set_response(self, trainer, response_status, response_body):
        response = {
            'executed_at': datetime.now().isoformat(),
            'epoch': trainer.updater.epoch,
            'iteration': trainer.updater.iteration,
            'elapsed_time': trainer.elapsed_time,
            'status': response_status
        }

        if not is_jsonable(response_body):
            response['body'] = None
        else:
            response['body'] = response_body

        self._response = response
        return response
Пример #2
0
    def set_request(self, request_status, request_body, schedule):
        request = {
            'created_at': datetime.now().isoformat(),
            'status': request_status
        }

        if is_jsonable(request_body):
            request['body'] = request_body
        else:
            request['body'] = None

        if self.is_valid_schedule(schedule):
            request['schedule'] = schedule
        else:
            request['schedule'] = None

        self._request = request
        return request