Skip to content

Commit

Permalink
Add parent attribute to class
Browse files Browse the repository at this point in the history
  • Loading branch information
Snarr committed Nov 27, 2024
1 parent cdf2d4c commit 08e1e49
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions sdk-python/littlehorse/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ def __init__(
self,
variable_name: str,
variable_type: VariableType,
parent: WorkflowThread,
default_value: Any = None,
access_level: Optional[
Union[WfRunVariableAccessLevel, str]
Expand All @@ -377,6 +378,7 @@ def __init__(
Args:
variable_name (str): The name of the variable.
variable_type (VariableType): The variable type.
parent (WorkflowThread): The parent WorkflowThread of this WfRunVariable.
default_value (Any, optional): A default value. Defaults to None.
access_level (WfRunVariableAccessLevel): Sets the access level of a WfRunVariable. Defaults to PRIVATE_VAR.
Expand All @@ -388,6 +390,7 @@ def __init__(
"""
self.name = variable_name
self.type = variable_type
self.parent = parent
self.default_value: Optional[VariableValue] = None
self._json_path: Optional[str] = None
self._required = False
Expand Down Expand Up @@ -554,34 +557,34 @@ def compile(self) -> ThreadVarDef:
)

def is_equal_to(self, rhs: Any) -> WorkflowCondition:
return WorkflowCondition(self, Comparator.EQUALS, rhs)
return self.parent.condition(self, Comparator.EQUALS, rhs)

def is_not_equal_to(self, rhs: Any) -> WorkflowCondition:
return WorkflowCondition(self, Comparator.NOT_EQUALS, rhs)
return self.parent.condition(self, Comparator.NOT_EQUALS, rhs)

def is_greater_than(self, rhs: Any) -> WorkflowCondition:
return WorkflowCondition(self, Comparator.GREATER_THAN, rhs)
return self.parent.condition(self, Comparator.GREATER_THAN, rhs)

def is_greater_than_eq(self, rhs: Any) -> WorkflowCondition:
return WorkflowCondition(self, Comparator.GREATER_THAN_EQ, rhs)
return self.parent.condition(self, Comparator.GREATER_THAN_EQ, rhs)

def is_less_than_eq(self, rhs: Any) -> WorkflowCondition:
return WorkflowCondition(self, Comparator.LESS_THAN_EQ, rhs)
return self.parent.condition(self, Comparator.LESS_THAN_EQ, rhs)

def is_less_than(self, rhs: Any) -> WorkflowCondition:
return WorkflowCondition(self, Comparator.LESS_THAN, rhs)
return self.parent.condition(self, Comparator.LESS_THAN, rhs)

def does_contain(self, rhs: Any) -> WorkflowCondition:
return WorkflowCondition(self, Comparator.IN, rhs)
return self.parent.condition(self, Comparator.IN, rhs)

def does_not_contain(self, rhs: Any) -> WorkflowCondition:
return WorkflowCondition(self, Comparator.NOT_IN, rhs)
return self.parent.condition(self, Comparator.NOT_IN, rhs)

def is_in(self, rhs: Any) -> WorkflowCondition:
return WorkflowCondition(self, Comparator.IN, rhs)
return self.parent.condition(self, Comparator.IN, rhs)

def is_not_in(self, rhs: Any) -> WorkflowCondition:
return WorkflowCondition(self, Comparator.NOT_IN, rhs)
return self.parent.condition(self, Comparator.NOT_IN, rhs)

def assign_to(self, rhs: Any) -> None:
self.parent.mutate(self, VariableMutationType.ASSIGN, rhs)
Expand Down

0 comments on commit 08e1e49

Please sign in to comment.