def test(self): """ Checks whether all required attributes are set. Throws an exception if an error was detected. """ if len(self.inputs) != 0: raise WorkflowException(self, 'StartTask with an input.') elif len(self.outputs) < 1: raise WorkflowException(self, 'No output task connected.')
def test(self): """ Checks whether all required attributes are set. Throws an exception if an error was detected. """ TaskSpec.test(self) if len(self.cond_task_specs) < 1: raise WorkflowException(self, 'At least one output required.') for condition, task in self.cond_task_specs: if task is None: raise WorkflowException(self, 'Condition with no task.') if condition is None: continue if condition is None: raise WorkflowException(self, 'Condition is None.')
def test(self): """ Checks whether all required attributes are set. Throws an exception if an error was detected. """ TaskSpec.test(self) if len(self.outputs) > 0: raise WorkflowException(self, 'Cancel with an output.')
def test(self): """ Checks whether all required attributes are set. Throws an exception if an error was detected. """ MultiChoice.test(self) if self.default_task_spec is None: raise WorkflowException(self, 'A default output is required.')
def try_fire(self, my_task): # If the threshold was already reached, there is nothing else to do. if my_task._has_state(Task.COMPLETED): return False if my_task._has_state(Task.READY): return True # Retrieve a list of all activated tasks from the associated # task that did the conditional parallel split. split_task = my_task._find_ancestor_from_name(self.split_task) if split_task is None: msg = 'Join with %s, which was not reached' % self.split_task raise WorkflowException(self, msg) tasks = split_task.task_spec._get_activated_threads(split_task) # The default threshold is the number of threads that were started. threshold = valueof(my_task, self.threshold) if threshold is None: threshold = len(tasks) # Look up which tasks have already completed. waiting_tasks = [] completed = 0 for task in tasks: # Refresh path prediction. task.task_spec._predict(task) if self._branch_is_complete(task): completed += 1 else: waiting_tasks.append(task) # If the threshold was reached, get ready to fire. if completed >= threshold: # If this is a cancelling join, cancel all incoming branches, # except for the one that just completed. if self.cancel_remaining: for task in waiting_tasks: task.cancel() return True # We do NOT set the task state to COMPLETED, because in # case all other incoming tasks get cancelled (or never reach # the ThreadMerge for other reasons, such as reaching a stub branch), # we need to revisit it. return False
def _connect_notify(self, task_spec): """ Called by the previous task to let us know that it exists. """ raise WorkflowException(self, 'StartTask can not have any inputs.')
def test(self): TaskSpec.test(self) if self.file is not None and not os.path.exists(self.file): raise WorkflowException(self, 'File does not exist: %s' % self.file)