From 385aef856ea7799eab9f1310d68dcbfc94c76a77 Mon Sep 17 00:00:00 2001 From: Felipe Martin Date: Sat, 9 May 2020 21:06:58 +0200 Subject: [PATCH] Provide current execution to action execute method --- jeeves/core/executor.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/jeeves/core/executor.py b/jeeves/core/executor.py index cdc845e..425386f 100644 --- a/jeeves/core/executor.py +++ b/jeeves/core/executor.py @@ -10,12 +10,16 @@ class Executor: defined_arguments = defined_arguments or {} self.step_count = len(flow.tasks) self._flow: Flow = flow - self._execution = Execution(flow=flow, steps=self._generate_execution_steps(flow)) + self._execution = Execution( + flow=flow, steps=self._generate_execution_steps(flow) + ) self._arguments = {} if self._flow.arguments: for argument in self._flow.arguments: # TODO: What happens if not default? - self._arguments[argument.name] = defined_arguments.get(argument.name, argument.default) + self._arguments[argument.name] = defined_arguments.get( + argument.name, argument.default + ) self._execution.arguments = self._arguments @property @@ -29,9 +33,17 @@ class Executor: def execute_step(self, step: ExecutionStep): try: - action = ActionRegistry.get_action(action_id=step.task.type, parameters=step.task.parameters) - action.parse_parameters(current_execution=self._execution, **self._arguments) - step.result = action.execute(workspace=self._execution.workspace, arguments=self._arguments) + action = ActionRegistry.get_action( + action_id=step.task.type, parameters=step.task.parameters + ) + action.parse_parameters( + current_execution=self._execution, **self._arguments + ) + step.result = action.execute( + workspace=self._execution.workspace, + arguments=self._arguments, + execution=self._execution, + ) except Exception as error: # Catch unhandled exceptions, mark the result as unsuccessful # and append the error as output.