fmartingr
/
jeeves
Archived
1
0
Fork 0

Provide current execution to action execute method

This commit is contained in:
Felipe Martin 2020-05-09 21:06:58 +02:00
parent cc76871b6d
commit 385aef856e
Signed by: fmartingr
GPG Key ID: 716BC147715E716F
1 changed files with 17 additions and 5 deletions

View File

@ -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.