MCPcopy Index your code
hub / github.com/sartography/SpiffWorkflow / Task

Class Task

SpiffWorkflow/task.py:33–437  ·  view source on GitHub ↗

Used internally for composing a tree that represents possible paths through a Workflow. Attributes: id (UUID): a unique identifierfor this task workflow (`Workflow`): the workflow associated with this task parent (`Task`): the parent of this task children (list(`

Source from the content-addressed store, hash-verified

31
32
33class Task(object):
34 """Used internally for composing a tree that represents possible paths through a Workflow.
35
36 Attributes:
37 id (UUID): a unique identifierfor this task
38 workflow (`Workflow`): the workflow associated with this task
39 parent (`Task`): the parent of this task
40 children (list(`Task`)): the children of this task
41 triggered (bool): True if the task is not part of output specification of the task spec
42 task_spec (`TaskSpec`): the spec associated with this task
43 thread_id (int): a thread id for this task
44 data (dict): a dictionary containing data for this task
45 internal_data (dict): a dictionary containing information relevant to the task state or execution
46 last_state_change (float): the timestamp when this task last changed state
47 thread_id (int): a thread identifier
48
49 Note:
50 The `thread_id` attribute might be more accurately named `branch_id`, as it pertains only to workflow
51 structure (eg, branches between split and merge tasks) rather than anything to do with threaded execution.
52
53 Warning:
54 The `data` attribute represents the state of the data as this particular task is executed. It is copied from
55 its parent when the task is updated (this can behavior can be modified in the `TaskSpec.update` method).
56 This can be VERY resource intensive in large workflows or with lots of data.
57 """
58
59 thread_id_pool = 0 # Pool for assigning a unique thread id to every new Task.
60
61 def __init__(self, workflow, task_spec, parent=None, state=TaskState.MAYBE, id=None):
62 """
63 Args:
64 workflow (`Workflow`): the workflow this task should be added to
65 task_spec (`TaskSpec`): the spec associated with this task
66
67 Keyword Args:
68 parent (`Task`): the parent of this task
69 state (`TaskState`): the state of this task (default MAYBE)
70 id: an optional id (defaults to a random UUID)
71 """
72 self.id = id or uuid4()
73 workflow.tasks[self.id] = self
74 self.workflow = workflow
75
76 self._parent = parent.id if parent is not None else None
77 self._children = []
78 self._state = state
79
80 self.triggered = False
81 self.task_spec = task_spec
82
83 self.thread_id = self.__class__.thread_id_pool
84 self.data = {}
85 self.internal_data = {}
86 self.last_state_change = time.time()
87 if parent is not None:
88 self.parent._child_added_notify(self)
89
90 @property

Callers 6

testTreeMethod · 0.90
__init__Method · 0.70
_add_childMethod · 0.70
deserialize_taskMethod · 0.50
deserialize_taskMethod · 0.50

Calls

no outgoing calls

Tested by 1

testTreeMethod · 0.72