Skip to content

Commit

Permalink
change BinaryOperation to ConditionOperation
Browse files Browse the repository at this point in the history
  • Loading branch information
connor-mccarthy committed Sep 11, 2023
1 parent 3eebc74 commit fdde042
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion sdk/python/kfp/compiler/compiler_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def _get_parent_groups_helper(


def get_channels_from_condition(
operations: List[pipeline_channel.BinaryOperation],
operations: List[pipeline_channel.ConditionOperation],
collected_channels: list,
) -> None:
"""Appends to collected_channels each pipeline channels used in each
Expand Down
10 changes: 5 additions & 5 deletions sdk/python/kfp/compiler/pipeline_spec_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -710,9 +710,9 @@ def _update_task_spec_for_loop_group(


def _binary_operations_to_cel_conjunctive(
operations: List[pipeline_channel.BinaryOperation]) -> str:
"""Converts a list of BinaryOperation to a CEL string with placeholders.
Each BinaryOperation will be joined the others via the conjunctive (&&).
operations: List[pipeline_channel.ConditionOperation]) -> str:
"""Converts a list of ConditionOperation to a CEL string with placeholders.
Each ConditionOperation will be joined the others via the conjunctive (&&).
Args:
operations: The binary operations to convert to convert and join.
Expand All @@ -728,8 +728,8 @@ def _binary_operations_to_cel_conjunctive(


def _single_binary_operation_to_cel_condition(
operation: pipeline_channel.BinaryOperation) -> str:
"""Converts a BinaryOperation to a CEL string with placeholders.
operation: pipeline_channel.ConditionOperation) -> str:
"""Converts a ConditionOperation to a CEL string with placeholders.
Args:
operation: The binary operation to convert to a string.
Expand Down
14 changes: 7 additions & 7 deletions sdk/python/kfp/dsl/pipeline_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@


@dataclasses.dataclass
class BinaryOperation:
class ConditionOperation:
"""Represents a condition expression to be used in condition control flow
group.
Expand Down Expand Up @@ -152,22 +152,22 @@ def __hash__(self) -> int:
return hash(self.pattern)

def __eq__(self, other):
return BinaryOperation('==', self, other)
return ConditionOperation('==', self, other)

def __ne__(self, other):
return BinaryOperation('!=', self, other)
return ConditionOperation('!=', self, other)

def __lt__(self, other):
return BinaryOperation('<', self, other)
return ConditionOperation('<', self, other)

def __le__(self, other):
return BinaryOperation('<=', self, other)
return ConditionOperation('<=', self, other)

def __gt__(self, other):
return BinaryOperation('>', self, other)
return ConditionOperation('>', self, other)

def __ge__(self, other):
return BinaryOperation('>=', self, other)
return ConditionOperation('>=', self, other)


class PipelineParameterChannel(PipelineChannel):
Expand Down
10 changes: 5 additions & 5 deletions sdk/python/kfp/dsl/tasks_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,15 +151,15 @@ class _ConditionBase(TasksGroup):

def __init__(
self,
conditions: List[pipeline_channel.BinaryOperation],
conditions: List[pipeline_channel.ConditionOperation],
name: Optional[str] = None,
) -> None:
super().__init__(
group_type=TasksGroupType.CONDITION,
name=name,
is_root=False,
)
self.conditions: List[pipeline_channel.BinaryOperation] = conditions
self.conditions: List[pipeline_channel.ConditionOperation] = conditions


class If(_ConditionBase):
Expand Down Expand Up @@ -315,9 +315,9 @@ class InvalidControlFlowException(Exception):


def _shallow_copy_list_of_binary_operations(
operations: List[pipeline_channel.BinaryOperation]
) -> List[pipeline_channel.BinaryOperation]:
# shallow copy is sufficient to allow us to invert the negate flag of a BinaryOperation without affecting copies. deep copy not needed and would result in many copies of the full pipeline since PipelineChannels hold references to the pipeline.
operations: List[pipeline_channel.ConditionOperation]
) -> List[pipeline_channel.ConditionOperation]:
# shallow copy is sufficient to allow us to invert the negate flag of a ConditionOperation without affecting copies. deep copy not needed and would result in many copies of the full pipeline since PipelineChannels hold references to the pipeline.
return [copy.copy(operation) for operation in operations]


Expand Down

0 comments on commit fdde042

Please sign in to comment.