Skip to content

Commit 8d11302

Browse files
Merge pull request #2 from Vectorworks/improvement/composite-sub-task-flag
(s2s) New sub_task to list method for overriding purposes
2 parents fa0fbd6 + 4644c35 commit 8d11302

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

taskflow/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
__title__ = "Taskflow"
2-
__version__ = "0.2.0"
2+
__version__ = "0.2.1"
33

44
from .flow import * # noqa
55
from .tasks import * # noqa

taskflow/tasks.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,13 @@ def __init__(self, *sub_tasks, needs_prev_result=True, name=None):
251251
# not a standalone task, so only the calculated property makes sense
252252
self._status = None
253253

254+
def sub_tasks_to_list(self):
255+
result = []
256+
for sub_task in self._sub_tasks:
257+
result.extend(sub_task.to_list())
258+
259+
return result
260+
254261
@property
255262
def status(self):
256263
if any(sub_task.leaf.status == self.STATUS_HALTED for sub_task in self._sub_tasks):
@@ -285,14 +292,12 @@ def run(self, **kwargs):
285292
raise RuntimeError("Composite tasks cannot be run directly")
286293

287294
def to_list(self):
288-
result = []
289-
for sub_task in self._sub_tasks:
290-
result += sub_task.to_list()
295+
sub_tasks_result = self.sub_tasks_to_list()
291296

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

295-
return result + base_list
300+
return sub_tasks_result + base_list
296301

297302
@classmethod
298303
def from_data(cls, task_data):

0 commit comments

Comments
 (0)