コード例 #1
0
 def StopTask(self, request, context):
     task_id: int = request.task_id
     resp = self.runtime.stop_task(task_id).resp
     if resp.code != 0:
         return task_controller_pb2.StopTaskReq(
             resp=task_controller_pb2.Response(code=resp.code,
                                               message=resp.message))
     resp = self.db.stop_task(task_id, int(time.time()))
     return task_controller_pb2.StopTaskReq(
         resp=task_controller_pb2.Response(code=resp.code,
                                           message=resp.message))
コード例 #2
0
 def StartTask(self, request, context):
     task_id: int = request.task_id
     print("start task task id:" + str(task_id))
     resp = self.db.start_task(task_id, int(time.time())).resp
     resp = self.runtime.start_task(task_id).resp
     print("start task runtime code:" + str(resp.code))
     if resp.code != 0:
         return task_controller_pb2.StartTaskResp(
             resp=task_controller_pb2.Response(code=resp.code,
                                               message=resp.message))
     return task_controller_pb2.StartTaskResp(
         resp=task_controller_pb2.Response(code=resp.code,
                                           message=resp.message))
コード例 #3
0
 def AddCustomLogCallback(self, request, context):
     log: CustomLog = request.custom_log
     resp = self.db.add_custom_log(log).resp
     return task_controller_pb2.AddCustomLogCallbackResp(
         resp=task_controller_pb2.Response(
             code=resp.code,
             message=resp.message,
         ))
コード例 #4
0
    def AddTaskByGit(self, request, context):
        request_task: task_controller_pb2.Task = request.task
        # wrap to task
        task: Task = Task(
            task_id=request_task.task_id,
            name=request_task.name,
            create_time=request_task.create_time,
            start_time=request_task.start_time,
            end_time=request_task.end_time,
            union_train=request_task.union_train,
            edge_nodes=request_task.edge_nodes,
            file=request_task.file,
            status=0,
        )

        # add to db
        self.tasks.append(task)
        resp = self.db.add_task(task).resp
        print("add task by git:" + resp.message)
        print(resp)
        if resp.code != 0:
            return task_controller_pb2.AddTaskByGitResp(
                resp=task_controller_pb2.Response(
                    code=resp.code,
                    message="add task to db fail",
                ))

        # get id from db
        task.task_id = json.loads(resp.message)['id']

        # clone
        self.runtime.add_task_by_git(task)

        # response
        return task_controller_pb2.AddTaskByGitResp(
            resp=task_controller_pb2.Response(
                code=0,
                message="start cloning",
            ))
コード例 #5
0
 def AddTask(self, request, context):
     request_task = request.task
     task: Task = Task(task_id=request_task.task_id,
                       name=request_task.name,
                       create_time=request_task.create_time,
                       start_time=request_task.start_time,
                       end_time=request_task.end_time,
                       union_train=request_task.union_train,
                       edge_nodes=request_task.edge_nodes,
                       file=request_task.file,
                       status=0)
     self.tasks.append(task)
     resp = self.db.add_task(task).resp
     print("add task:" + resp.message)
     return task_controller_pb2.AddTaskResp(
         resp=task_controller_pb2.Response(
             code=resp.code,
             message=resp.message,
         ))
コード例 #6
0
 def SendMessage(self, request, context):
     print("get message: " + request.message)
     return task_controller_pb2.SendMessageResp(
         resp=task_controller_pb2.Response(code=0, message="success"))
コード例 #7
0
 def FinishTask(self, request, context):
     task_id: int = request.task_id
     resp = self.db.finish_task(task_id, int(time.time())).resp
     return task_controller_pb2.FinishTaskResp(
         resp=task_controller_pb2.Response(code=resp.code,
                                           message=resp.message))