Skip to content

Commit

Permalink
fix(sdk): Throw 'exit_task cannot depend on any other tasks.' error w…
Browse files Browse the repository at this point in the history
…hen an ExitHandler has a parameter dependent on other task (#11005)

Signed-off-by: hbelmiro <helber.belmiro@gmail.com>
  • Loading branch information
hbelmiro authored Jul 25, 2024
1 parent 39fbd60 commit 08185e7
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 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,19 @@ 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

for task_input in self.exit_task.inputs.values():
if isinstance(
task_input,
PipelineParameterChannel) and task_input.task is not None:
return True
return False


class ConditionBranches(TasksGroup):
Expand Down

0 comments on commit 08185e7

Please sign in to comment.