Skip to content

Commit

Permalink
make is_dynamic_commands a getter-property
Browse files Browse the repository at this point in the history
  • Loading branch information
leo-schick committed Nov 23, 2023
1 parent 1baa8db commit 60bcf9b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions mara_pipelines/pipelines.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,20 @@ def html_doc_items(self) -> List[Tuple[str, str]]:
class Task(Node):
def __init__(self, id: str, description: str, commands: Optional[Union[Callable, List[Command]]] = None, max_retries: Optional[int] = None) -> None:
super().__init__(id, description)
self.is_dynamic_commands = callable(commands)
self.max_retries = max_retries

if self.is_dynamic_commands:
if callable(commands):
self._commands = None
self.__dynamic_commands_generator_func = commands
else:
self._commands = []
self._add_commands(commands or [])

@property
def is_dynamic_commands(self) -> bool:
"""if the command list is generated dynamically via a function"""
return self.__dynamic_commands_generator_func is not None

def _assert_is_not_dynamic(self):
if self.is_dynamic_commands:
raise Exception('You cannot use add_command when the task is constructed with a callable commands function.')
Expand Down

0 comments on commit 60bcf9b

Please sign in to comment.