Provide current execution to action execute method
This commit is contained in:
parent
cc76871b6d
commit
385aef856e
|
@ -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.
|
||||
|
|
Reference in New Issue