Skip to content

Commit 1baa8db

Browse files
committed
code review suggestions
1 parent 7260baf commit 1baa8db

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

mara_pipelines/pipelines.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,26 +83,26 @@ def html_doc_items(self) -> List[Tuple[str, str]]:
8383
class Task(Node):
8484
def __init__(self, id: str, description: str, commands: Optional[Union[Callable, List[Command]]] = None, max_retries: Optional[int] = None) -> None:
8585
super().__init__(id, description)
86-
self.callable_commands = callable(commands)
86+
self.is_dynamic_commands = callable(commands)
8787
self.max_retries = max_retries
8888

89-
if self.callable_commands:
89+
if self.is_dynamic_commands:
9090
self._commands = None
91-
self.__commands_callable = commands
91+
self.__dynamic_commands_generator_func = commands
9292
else:
9393
self._commands = []
9494
self._add_commands(commands or [])
9595

96-
def _test_is_not_dynamic(self):
97-
if self.callable_commands:
96+
def _assert_is_not_dynamic(self):
97+
if self.is_dynamic_commands:
9898
raise Exception('You cannot use add_command when the task is constructed with a callable commands function.')
9999

100100
@property
101101
def commands(self) -> List:
102-
if not self._commands:
102+
if self._commands is None:
103103
self._commands = []
104104
# execute the callable command function and cache the result
105-
for command in self.__commands_callable() or []:
105+
for command in self.__dynamic_commands_generator_func() or []:
106106
self._add_command(command)
107107
return self._commands
108108

@@ -118,11 +118,11 @@ def _add_commands(self, commands: List[Command]):
118118
self._add_command(command)
119119

120120
def add_command(self, command: Command, prepend=False):
121-
self._test_is_not_dynamic()
121+
self._assert_is_not_dynamic()
122122
self._add_command(command, prepend=prepend)
123123

124124
def add_commands(self, commands: List[Command]):
125-
self._test_is_not_dynamic()
125+
self._assert_is_not_dynamic()
126126
self._add_commands(commands)
127127

128128
def run(self):

mara_pipelines/ui/node_page.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def __(pipeline: pipelines.Pipeline):
8080
def __(task: pipelines.Task):
8181
if not acl.current_user_has_permission(views.acl_resource):
8282
return bootstrap.card(header_left='Commands', body=acl.inline_permission_denied_message())
83-
elif task.callable_commands:
83+
elif task.is_dynamic_commands:
8484
return bootstrap.card(
8585
header_left='Commands',
8686
body=f"""<span style="font-style:italic;color:#aaa"><span class="fa fa-lightbulb"> </span> {"... are defined dynamically during execution"}</span>""")

tests/test_pipeline_tasks.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def python_test_function(result: _PythonFuncTestResult):
3131
assert test_result.has_run
3232

3333

34-
def test_run_task_callable_commands():
34+
def test_run_task_dynamic_commands():
3535
"""
3636
A simple test executing a task with callable commands
3737
"""
@@ -48,8 +48,8 @@ def generate_command_list() -> List:
4848
assert not test_result.has_run
4949

5050
task = Task(
51-
id='run_task_callable_commands',
52-
description="Unit test test_run_task_callable_commands",
51+
id='run_task_dynamic_commands',
52+
description="Unit test test_run_task_dynamic_commands",
5353
commands=generate_command_list)
5454

5555
assert not test_result.has_run

0 commit comments

Comments
 (0)