Beispiel #1
0
    def get(self, participant_id, job_id):
        parser = reqparse.RequestParser()
        parser.add_argument('start_time',
                            type=int,
                            location='args',
                            required=False,
                            help='project_id must be timestamp')
        parser.add_argument('max_lines',
                            type=int,
                            location='args',
                            required=True,
                            help='max_lines is required')
        data = parser.parse_args()
        start_time = data['start_time']
        max_lines = data['max_lines']
        job = _get_job(job_id)
        if start_time is None:
            start_time = job.workflow.start_at

        workflow = job.workflow
        project_config = workflow.project.get_config()
        party = project_config.participants[participant_id]
        client = RpcClient(project_config, party)
        resp = client.get_job_events(job_name=job.name,
                                     start_time=start_time,
                                     max_lines=max_lines)
        if resp.status.code != common_pb2.STATUS_SUCCESS:
            raise InternalException(resp.status.msg)
        peer_events = MessageToDict(resp.logs,
                                    preserving_proto_field_name=True,
                                    including_default_value_fields=True)
        return {'data': peer_events}
Beispiel #2
0
 def get(self, workflow_uuid, participant_id, job_name):
     parser = reqparse.RequestParser()
     parser.add_argument('start_time', type=int, location='args',
                         required=False,
                         help='project_id must be timestamp')
     parser.add_argument('max_lines', type=int, location='args',
                         required=True,
                         help='max_lines is required')
     data = parser.parse_args()
     start_time = data['start_time']
     max_lines = data['max_lines']
     workflow = Workflow.query.filter_by(uuid=workflow_uuid).first()
     if workflow is None:
         raise NotFoundException(
             f'Failed to find workflow: {workflow_uuid}')
     if start_time is None:
         start_time = workflow.start_at
     project_config = workflow.project.get_config()
     party = project_config.participants[participant_id]
     client = RpcClient(project_config, party)
     resp = client.get_job_events(job_name=job_name,
                                  start_time=start_time,
                                  max_lines=max_lines)
     if resp.status.code != common_pb2.STATUS_SUCCESS:
         raise InternalException(resp.status.msg)
     peer_events = MessageToDict(
         resp,
         preserving_proto_field_name=True,
         including_default_value_fields=True)['logs']
     return {'data': peer_events}