diff --git a/taskflow/__init__.py b/taskflow/__init__.py index 904659b..ba7bbbc 100644 --- a/taskflow/__init__.py +++ b/taskflow/__init__.py @@ -1,5 +1,5 @@ __title__ = "Taskflow" -__version__ = "0.2.0" +__version__ = "0.2.1" from .flow import * # noqa from .tasks import * # noqa diff --git a/taskflow/tasks.py b/taskflow/tasks.py index 5157da8..e63b778 100644 --- a/taskflow/tasks.py +++ b/taskflow/tasks.py @@ -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): @@ -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):