Skip to content
2 changes: 1 addition & 1 deletion taskflow/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
__title__ = "Taskflow"
__version__ = "0.2.0"
__version__ = "0.2.1"

from .flow import * # noqa
from .tasks import * # noqa
13 changes: 9 additions & 4 deletions taskflow/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,13 @@ def __init__(self, *sub_tasks, needs_prev_result=True, name=None):
# not a standalone task, so only the calculated property makes sense
self._status = None

def sub_tasks_to_list(self):
result = []
for sub_task in self._sub_tasks:
result.extend(sub_task.to_list())

return result

@property
def status(self):
if any(sub_task.leaf.status == self.STATUS_HALTED for sub_task in self._sub_tasks):
Expand Down Expand Up @@ -285,14 +292,12 @@ def run(self, **kwargs):
raise RuntimeError("Composite tasks cannot be run directly")

def to_list(self):
result = []
for sub_task in self._sub_tasks:
result += sub_task.to_list()
sub_tasks_result = self.sub_tasks_to_list()

base_list = super().to_list()
base_list[0].update({"sub_tasks": [sub_task.id for sub_task in self._sub_tasks]})

return result + base_list
return sub_tasks_result + base_list

@classmethod
def from_data(cls, task_data):
Expand Down