def updateCompletionAndStatus(self):
        '''
        Evaluate new value for completion and status of a particular TaskNode
        '''
        self.updateAllocation()

        if not self.invalidated:
            return
        if self.task is None:
            self.status = NODE_CANCELED
            return
        completion = 0.0
        status = defaultdict(int)
        self.readyCommandCount = 0
        self.doneCommandCount = 0
        self.commandCount = len(self.task.commands)

        for command in self.task.commands:
            completion += command.completion
            status[command.status] += 1
            if command.status == CMD_READY:
                self.readyCommandCount += 1
            if command.status == CMD_DONE:
                self.doneCommandCount += 1

        if self.task.commands:
            self.completion = completion / len(self.task.commands)
        else:
            self.completion = 1.0

        if CMD_CANCELED in status:
            self.status = NODE_CANCELED
        elif self.paused:
            self.status = NODE_PAUSED
        elif CMD_ERROR in status:
            self.status = NODE_ERROR
        elif CMD_TIMEOUT in status:
            self.status = NODE_ERROR
        elif CMD_RUNNING in status:
            self.status = NODE_RUNNING
        elif CMD_ASSIGNED in status:
            self.status = NODE_READY
        elif CMD_FINISHING in status:
            self.status = NODE_RUNNING
        elif CMD_READY in status:
            self.status = NODE_READY
        elif CMD_BLOCKED in status:
            self.status = NODE_BLOCKED
        else:
            # all commands are DONE, ensure the completion is at 1.0 (in case of failed completion update from some workers)
            self.completion = 1.0
            self.status = NODE_DONE

        times = [command.creationTime for command in self.task.commands if command.creationTime is not None]
        if times:
            self.creationTime = min(times)

        times = [command.startTime for command in self.task.commands if command.startTime is not None]
        if times:
            self.startTime = min(times)

        times = [command.updateTime for command in self.task.commands if command.updateTime is not None]
        if times:
            self.updateTime = max(times)

        # only set the endTime on the node if it's done
        if self.status == NODE_DONE:
            times = [command.endTime for command in self.task.commands if command.endTime is not None]
            if times:
                self.endTime = max(times)
        else:
            self.endTime = None

        self.task.status = self.status
        self.task.completion = self.completion
        self.task.creationTime = self.creationTime
        self.task.startTime = self.startTime
        self.task.updateTime = self.updateTime
        self.task.endTime = self.endTime

        self.timer = self.task.timer

        self.invalidated = False
dataset/ETHPy150Open mikrosimage/OpenRenderManagement/src/octopus/dispatcher/model/node.py/TaskNode.updateCompletionAndStatus/original