From 80de886e7e586d3ec75a0a7f8d49bc5773a7affe Mon Sep 17 00:00:00 2001 From: Leo Schick Date: Tue, 14 Feb 2023 16:08:22 +0100 Subject: [PATCH] add before/after task to ParallelTask only when not command list is not empty --- mara_pipelines/pipelines.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mara_pipelines/pipelines.py b/mara_pipelines/pipelines.py index aec1272..fa4f6ed 100644 --- a/mara_pipelines/pipelines.py +++ b/mara_pipelines/pipelines.py @@ -133,8 +133,10 @@ def add_parallel_tasks(self, sub_pipeline: 'Pipeline') -> None: def launch(self) -> 'Pipeline': sub_pipeline = Pipeline(self.id, description=f'Runs f{self.id} in parallel', max_number_of_parallel_tasks=self.max_number_of_parallel_tasks) - sub_pipeline.add_initial(Task(id='before', description='Runs commands-before', commands=self.commands_before)) - sub_pipeline.add_final(Task(id='after', description='Runs commands-after', commands=self.commands_after)) + if self.commands_before: + sub_pipeline.add_initial(Task(id='before', description='Runs commands-before', commands=self.commands_before)) + if self.commands_after: + sub_pipeline.add_final(Task(id='after', description='Runs commands-after', commands=self.commands_after)) self.add_parallel_tasks(sub_pipeline)