Skip to content

Commit

Permalink
fix: Throw 'exit_task cannot depend on any other tasks.' error when a…
Browse files Browse the repository at this point in the history
…n ExitHandler has a parameter dependent on other task

Signed-off-by: hbelmiro <helber.belmiro@gmail.com>
  • Loading branch information
hbelmiro committed Jul 15, 2024
1 parent 4930bee commit d7006ab
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions sdk/python/kfp/dsl/tasks_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from kfp.dsl import pipeline_channel
from kfp.dsl import pipeline_context
from kfp.dsl import pipeline_task
from kfp.dsl.pipeline_channel import PipelineParameterChannel


class TasksGroupType(str, enum.Enum):
Expand Down Expand Up @@ -130,7 +131,9 @@ def __init__(
is_root=False,
)

if exit_task.dependent_tasks:
self.exit_task = exit_task

if self.__has_dependent_tasks():
raise ValueError('exit_task cannot depend on any other tasks.')

# Removing exit_task form any group
Expand All @@ -140,7 +143,14 @@ def __init__(
# Set is_exit_handler since the compiler might be using this attribute.
exit_task.is_exit_handler = True

self.exit_task = exit_task
def __has_dependent_tasks(self) -> bool:
if self.exit_task.dependent_tasks:
return True

if not self.exit_task.inputs:
return False

return any(type(task_input) is PipelineParameterChannel for task_input in self.exit_task.inputs.values())


class ConditionBranches(TasksGroup):
Expand Down

0 comments on commit d7006ab

Please sign in to comment.