From ad780aba55c3ba101ebf74604122c9e4bf6ae6fa Mon Sep 17 00:00:00 2001 From: Felipe Martin Date: Sat, 9 May 2020 16:55:36 +0200 Subject: [PATCH] Name changes --- jeeves/core/actions/base.py | 10 ++++++---- jeeves/core/executor.py | 6 +++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/jeeves/core/actions/base.py b/jeeves/core/actions/base.py index 8a47363..8697960 100644 --- a/jeeves/core/actions/base.py +++ b/jeeves/core/actions/base.py @@ -16,17 +16,19 @@ class Action: self.parameters = self.Parameters(**(parameters or {})) self.parsed_parameters = {} - def parse_parameters_with_arguments(self, **arguments): + def parse_parameters(self, current_execution=None, **arguments): """ - Returns a dict with the parameters parsed in base of the provided arguments. + Returns a dict with the parameters parsed in base of the provided arguments and context. Parsing using jinja2 template themes only on the fields defined on the `Parameters.PARSE_WITH_ARGUMENTS`. """ for parameter_name in self.parameters.PARSE_WITH_ARGUMENTS: - self.parsed_parameters[parameter_name] = Template(self.parameters.dict()[parameter_name]).render(**arguments) + self.parsed_parameters[parameter_name] = Template( + self.parameters.dict()[parameter_name] + ).render(current_execution=current_execution, **arguments) @abstractmethod def execute(self, workspace, **kwargs): """ Main method to override that handles the work for the defining action. """ - pass + pass \ No newline at end of file diff --git a/jeeves/core/executor.py b/jeeves/core/executor.py index dbb381c..325f93e 100644 --- a/jeeves/core/executor.py +++ b/jeeves/core/executor.py @@ -10,7 +10,7 @@ class Executor: defined_arguments = defined_arguments or {} self.step_count = len(flow.tasks) self._flow: Flow = flow - self._execution = Execution(flow=flow, steps=self._get_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: @@ -23,14 +23,14 @@ class Executor: for step in self._execution.steps: yield step - def _get_steps(self, flow: Flow): + def _generate_execution_steps(self, flow: Flow): for task in flow.tasks: yield ExecutionStep(task=task, result=Result()) def execute_step(self, step: ExecutionStep): try: action = ActionRegistry.get_action_cls(step.task.type)(parameters=step.task.parameters) - action.parse_parameters_with_arguments(**self._arguments) + action.parse_parameters(current_execution=self._execution, **self._arguments) step.result = action.execute(workspace=self._execution.workspace, arguments=self._arguments) except Exception as error: # Catch unhandled exceptions, mark the result as unsuccessful